Skip to content

Commit

Permalink
build both js and module.js
Browse files Browse the repository at this point in the history
  • Loading branch information
fraguada committed Jul 16, 2024
1 parent 8fb5940 commit 63ab28c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 10 deletions.
24 changes: 16 additions & 8 deletions .github/workflows/workflow_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,21 +131,29 @@ jobs:
run: git submodule update --init
- name: bootstrap
run: python3 script/bootstrap.py -p js
- name: setup
run: python3 script/setup.py -p js -o -v -d
- name: build js
- name: setup js module
run: python3 script/setup.py -p js -o -v -d -m
- name: build js module
run: python3 script/build.py -p js -o -v
- name: copy files
shell: bash
run: |
cp src/build/javascript/rhino3dm.wasm.map src/build/javascript/artifacts_js/rhino3dm.wasm.map
mv src/build/javascript/rhino3dm.js src/build/javascript/artifacts_js/rhino3dm.module.js
cp package.json src/build/javascript/artifacts_js
cp docs/javascript/RHINO3DM.JS.md src/build/javascript/artifacts_js/README.md
cp src/js/rhino3dm.debug.js src/build/javascript/artifacts_js/rhino3dm.js
cp src/js/rhino3dm.debug.min.js src/build/javascript/artifacts_js/rhino3dm.min.js
cp src/js/rhino3dm.debug.module.js src/build/javascript/artifacts_js/rhino3dm.module.js
cp src/js/rhino3dm.debug.module.min.js src/build/javascript/artifacts_js/rhino3dm.module.min.js
#cp src/js/rhino3dm.debug.js src/build/javascript/artifacts_js/rhino3dm.js
#cp src/js/rhino3dm.debug.min.js src/build/javascript/artifacts_js/rhino3dm.min.js
#cp src/js/rhino3dm.debug.module.js src/build/javascript/artifacts_js/rhino3dm.module.js
#cp src/js/rhino3dm.debug.module.min.js src/build/javascript/artifacts_js/rhino3dm.module.min.js
cp src/js/rhino3dm.d.ts src/build/javascript/artifacts_js/rhino3dm.d.ts
- name: setup js
run: python3 script/setup.py -p js -o -v -d
- name: build js
run: python3 script/build.py -p js -o -v
- name: copy files
shell: bash
run: |
mv src/build/javascript/rhino3dm.js src/build/javascript/artifacts_js
- name: artifacts
uses: actions/[email protected]
with:
Expand Down
9 changes: 9 additions & 0 deletions script/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,10 @@ def setup_js():
os.chdir(target_path)
cmakecommand = "emcmake cmake "

if module:
print("ES6 module build")
cmakecommand = cmakecommand + "-D MODULE=TRUE "

if node:
print("generating node build")
cmakecommand = cmakecommand + "-D NODE=TRUE "
Expand Down Expand Up @@ -605,6 +609,8 @@ def main():
help="generate Xcode-compatible log messages (no colors or other Terminal-friendly gimmicks)")
parser.add_argument('--debug', '-d', action='store_true',
help="generate a debug build (wasm only)")
parser.add_argument('--module', '-m', action='store_true',
help="generate a ES6 module build (wasm only)")
parser.add_argument('--library', '-l', action='store_true',
help="skip building and running .net projects (methodgen). Useful for generating librhino3dm_native in release workflow")

Expand Down Expand Up @@ -633,6 +639,9 @@ def main():
global debug
debug = args.debug

global module
module = args.module

global node
node = False
if "nodejs" in args.platform:
Expand Down
12 changes: 10 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ if( NODE )
message("NODE evaluates to True")
endif()

message("MODULE=${MODULE}")
if( MODULE )
message("MODULE evaluates to True")
endif()

# Add draco add_library
include_directories(${PROJECT_NAME} PUBLIC lib/draco/src ${CMAKE_BINARY_DIR})

Expand All @@ -48,14 +53,17 @@ if(${RHINO3DM_JS})
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-overloaded-virtual -Wno-switch -Wno-unknown-pragmas -Wno-unused-private-field")
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
message("debug mode")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -gsource-map")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
else()
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Oz")
endif()
if(NODE)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s MEMORY64=1")
endif()
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s MODULARIZE=1 -s EXPORT_NAME=rhino3dm -s EXPORT_ES6=1 -s ALLOW_MEMORY_GROWTH=1 --bind")
if(MODULE)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s EXPORT_ES6=1")
endif()
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s MODULARIZE=1 -s EXPORT_NAME=rhino3dm -s ALLOW_MEMORY_GROWTH=1 --bind")
endif()

add_definitions(-D_GNU_SOURCE)
Expand Down

0 comments on commit 63ab28c

Please sign in to comment.