Skip to content

Commit

Permalink
JavaScript: create a .tgz file that can then be yarn added.
Browse files Browse the repository at this point in the history
  • Loading branch information
agarny authored Dec 28, 2024
2 parents 7592a5c + 1908f8a commit 124b3af
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: WebAssembly
path: ./build/libOpenCOR-*
path: ./build/libopencor-*
- name: Release WebAssembly
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
uses: softprops/action-gh-release@v2
with:
files: ./build/libOpenCOR-*
files: ./build/libopencor-*
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ jobs:
cd build
ninja
- name: Unit testing
if: ${{ (matrix.unit_testing == 'ON') || (matrix.code_analysis == 'OFF') || (matrix.code_coverage == 'ON') || (matrix.memory_checks == 'ON') }}
if: ${{ ((matrix.unit_testing == 'ON') && (matrix.code_analysis == 'OFF')) || (matrix.code_coverage == 'ON') || (matrix.memory_checks == 'ON') }}
run: |
cd build
ninja ${{ matrix.target }}
Expand Down Expand Up @@ -432,13 +432,13 @@ jobs:
run: |
cd build
ninja
- name: Coverage
- name: Code coverage
if: ${{ matrix.code_coverage == 'ON' }}
run: |
cd build
ninja ${{ matrix.target }}
if [ `ninja ${{ matrix.target }} | grep TOTAL | sed 's/ /\n/g' | grep "100.00%" | wc -l | sed 's/ //g'` -eq 4 ]; then exit 0; else exit 1; fi
- name: Coverage report
- name: Code coverage report
if: ${{ matrix.code_coverage == 'ON' }}
run: |
cd build
Expand Down
18 changes: 11 additions & 7 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -295,23 +295,27 @@ if(EMSCRIPTEN)
COMPILE_FLAGS "-O3"
LINK_FLAGS "-O3 -sALLOW_MEMORY_GROWTH -sEXPORT_ES6=1 -sEXPORTED_FUNCTIONS=[_malloc,_free] -sINLINING_LIMIT -sSINGLE_FILE=1 -sSTACK_SIZE=4MB --bind")

# Create a ZIP file for our generated .js file.
# Create a .tgz file for our generated .js file that can be used to distribute our JavaScript bindings.

set(TGZ_FILE ${CMAKE_BINARY_DIR}/../../../../${REAL_CMAKE_PROJECT_NAME}-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}.tgz)

add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E tar "-cfv" "${CMAKE_BINARY_DIR}/../../../../${REAL_CMAKE_PROJECT_NAME}-${PROJECT_VERSION_MAJOR}-${PROJECT_VERSION_MINOR}-${PROJECT_VERSION_PATCH}-WebAssembly.zip" --format=zip
"${CMAKE_PROJECT_NAME}.js")
COMMAND ${CMAKE_COMMAND} -E make_directory package
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_PROJECT_NAME}.js package
COMMAND ${CMAKE_COMMAND} -E copy package.json package
COMMAND ${CMAKE_COMMAND} -E tar czf ${TGZ_FILE} package)

# Copy our generated .js file over.
# Copy our generated .js file over so that it can be used by our test Web page.

add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}.js
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_PROJECT_NAME}.js
${JAVASCRIPT_BINDINGS_DIR}/${CMAKE_PROJECT_NAME}.js)

# Let people know how to run our test web page.
# Let people know how to run our test Web page.

if(LIBOPENCOR_JAVASCRIPT_UNIT_TESTING)
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "-- JavaScript test web page has been copied to: ${JAVASCRIPT_BINDINGS_DIR}/index.html"
COMMAND ${CMAKE_COMMAND} -E echo "-- JavaScript test Web page has been copied to: ${JAVASCRIPT_BINDINGS_DIR}/index.html"
COMMAND ${CMAKE_COMMAND} -E echo " and can be run using: emrun --browser chrome ${JAVASCRIPT_BINDINGS_DIR}/index.html")
endif()
else()
Expand Down
2 changes: 1 addition & 1 deletion src/bindings/javascript/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ if(EMSCRIPTEN OR LIBOPENCOR_JAVASCRIPT_BINDINGS)
-DLIBOPENCOR_PREBUILT_ZIPPER=${LIBOPENCOR_PREBUILT_ZIPPER}
-DLIBOPENCOR_PREBUILT_ZLIB=${LIBOPENCOR_PREBUILT_ZLIB}
-DONLY_BUILD_THIRD_PARTY_LIBRARIES=${ONLY_BUILD_THIRD_PARTY_LIBRARIES}
-DREAL_CMAKE_PROJECT_NAME=${CMAKE_PROJECT_NAME}
-DREAL_CMAKE_PROJECT_NAME=${CMAKE_PROJECT_NAME_LC}
COMMAND ${CMAKE_COMMAND} --build build)

add_dependencies(${CMAKE_PROJECT_NAME} ${JAVASCRIPT_BINDINGS_TARGET})
Expand Down

0 comments on commit 124b3af

Please sign in to comment.