Skip to content

Commit

Permalink
update dependencies to latest versions and fix linker warnings (#22)
Browse files Browse the repository at this point in the history
* update yarn dependencies to latest versions

* update C++ dependencies and fix unused linker settings warning
  • Loading branch information
TheLartians authored Oct 9, 2021
1 parent a1bd01b commit 2631c8e
Show file tree
Hide file tree
Showing 8 changed files with 1,102 additions and 2,226 deletions.
12 changes: 5 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ on:
branches:
- master

env:
CTEST_OUTPUT_ON_FAILURE: 1
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -29,6 +25,11 @@ jobs:
with:
version: 2.0.31

- name: Install C++/CMake style checkers
run: |
brew install clang-format
pip3 install cmake_format==0.6.11 pyyaml
- name: install
env:
CPM_SOURCE_CACHE: ${{ github.workspace }}/cpm_modules
Expand All @@ -37,8 +38,5 @@ jobs:
- name: test
run: yarn run test

- name: install clang-format
run: sudo apt install clang-format

- name: check style
run: yarn run check:style
4 changes: 0 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ on:
push:
branches:
- master

env:
CTEST_OUTPUT_ON_FAILURE: 1
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

jobs:
build:
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
"url": "https://github.com/TheLartians/modern-wasm-starter.git"
},
"devDependencies": {
"@types/jest": "^26.0.20",
"jest": "^26.6.3",
"@types/jest": "^27.0.2",
"jest": "^27.2.5",
"prettier": "^2.2.1",
"ts-jest": "^26.4.4",
"ts-jest": "^27.0.5",
"typescript": "^4.1.3"
},
"files": [
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"rootDir": "source",
"outDir": "dist",
"declaration": true,
"allowJs": true,
},
"include": ["source"],
"exclude": ["node_modules", "dist"],
Expand Down
65 changes: 33 additions & 32 deletions wasm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,35 +1,32 @@
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)

project(TypeScriptXX
LANGUAGES CXX
)
project(TypeScriptXX LANGUAGES CXX)

# ---- Setup ----

set(CMAKE_CXX_FLAGS_RELEASE "-Oz -g0")

# ---- Dependencies ----
# Add C++ dependencies through CPM.cmake.
# See https://github.com/TheLartians/CPM.cmake for more info.
# Add C++ dependencies through CPM.cmake. See
# https://github.com/TheLartians/CPM.cmake for more info.
include(cmake/CPM.cmake)

# exact package versions are defined in package-lock.cmake
# this helps us specify exact versions of transitive dependencies
CPMUsePackageLock(package-lock.cmake)
# Update transitive dependencies to more recent versions (this has to be done
# before adding derived projects)
cpmaddpackage("gh:TheLartians/[email protected]")
cpmaddpackage("gh:TheLartians/[email protected]")

# using the ModernCppStarter as an example project
# replace this with your library
CPMAddPackage(
NAME Greeter
GITHUB_REPOSITORY TheLartians/ModernCppStarter
VERSION 0.16.1
)
# Format.cmake is used to run clang-format
cpmaddpackage("gh:TheLartians/[email protected]")

# EmGlue is used to create the TypeScript declarations and the JavaScript bindings
CPMAddPackage("gh:TheLartians/[email protected]")
# EmGlue is used to create the TypeScript declarations and the JavaScript
# bindings
cpmaddpackage("gh:TheLartians/[email protected]")

# Format.cmake is used to run clang-format
CPMAddPackage("gh:[email protected]")
# using the ModernCppStarter as an example project for JS bindings replace this
# with the library you want to use
cpmaddpackage(NAME Greeter GITHUB_REPOSITORY TheLartians/ModernCppStarter
VERSION 0.17.3)

# ---- Create wams glue library ----

Expand All @@ -41,15 +38,15 @@ target_link_libraries(wasmGlue PUBLIC Glue Greeter::Greeter)

# ---- Create main library ----

set(EMSCRIPTEN_FLAGS "-s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s \"EXTRA_EXPORTED_RUNTIME_METHODS=['addOnPostRun','callMain']\" -s MODULARIZE=1 -s SINGLE_FILE=1 -s INVOKE_RUN=0")
set(EMSCRIPTEN_FLAGS
"-s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s \"EXPORTED_RUNTIME_METHODS=['addOnPostRun','callMain']\" -s MODULARIZE=1 -s SINGLE_FILE=1 -s INVOKE_RUN=0"
)

add_executable(WasmModule source/main.cpp)
target_link_libraries(WasmModule wasmGlue EmGlue ${EMSCRIPTEN_FLAGS})
set_target_properties(WasmModule PROPERTIES
CXX_STANDARD 17
OUTPUT_NAME WasmModule
COMPILE_FLAGS ${EMSCRIPTEN_FLAGS}
)

set_target_properties(WasmModule PROPERTIES CXX_STANDARD 17 OUTPUT_NAME
WasmModule)

# ---- Create declarations printer ----

Expand All @@ -59,10 +56,14 @@ target_link_libraries(WasmModuleDeclarations wasmGlue)

# ---- Move library and declarations into place ----

add_custom_command(TARGET WasmModule POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/WasmModule.js ${CMAKE_CURRENT_LIST_DIR}/../source/WasmModule.js
)

add_custom_command(TARGET WasmModuleDeclarations POST_BUILD
COMMAND node ${CMAKE_CURRENT_BINARY_DIR}/WasmModuleDeclarations.js > ${CMAKE_CURRENT_LIST_DIR}/../source/WasmModule.d.ts
)
add_custom_command(
TARGET WasmModule
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/WasmModule.js
${CMAKE_CURRENT_LIST_DIR}/../source/WasmModule.js)

add_custom_command(
TARGET WasmModuleDeclarations
POST_BUILD
COMMAND node ${CMAKE_CURRENT_BINARY_DIR}/WasmModuleDeclarations.js >
${CMAKE_CURRENT_LIST_DIR}/../source/WasmModule.d.ts)
20 changes: 12 additions & 8 deletions wasm/cmake/CPM.cmake
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
set(CPM_DOWNLOAD_VERSION 0.34.0)

if(CPM_SOURCE_CACHE)
# Expand relative path. This is important if the provided path contains a tilde (~)
# Expand relative path. This is important if the provided path contains a
# tilde (~)
get_filename_component(CPM_SOURCE_CACHE ${CPM_SOURCE_CACHE} ABSOLUTE)
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
set(CPM_DOWNLOAD_LOCATION
"${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
set(CPM_DOWNLOAD_LOCATION
"$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
else()
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
set(CPM_DOWNLOAD_LOCATION
"${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
endif()

if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}")
file(DOWNLOAD
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
${CPM_DOWNLOAD_LOCATION}
)
file(
DOWNLOAD
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
${CPM_DOWNLOAD_LOCATION})
endif()

include(${CPM_DOWNLOAD_LOCATION})
19 changes: 0 additions & 19 deletions wasm/package-lock.cmake

This file was deleted.

Loading

0 comments on commit 2631c8e

Please sign in to comment.