Skip to content

Commit ec1eeb4

Browse files
committed
Switch from makefiles to cmake
1 parent 1289872 commit ec1eeb4

File tree

20 files changed

+161
-132
lines changed

20 files changed

+161
-132
lines changed

wasm/.gitignore

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,14 @@
1-
serve/cockle/
2-
serve/lite/
1+
CMakeCache.txt
2+
CMakeFiles/
3+
Makefile
4+
cmake_install.cmake
5+
cockle-config.json
6+
cockle_wasm_env/
7+
node_modules/
8+
package-lock.json
9+
.jupyterlite.doit.db
10+
11+
recipe/em-forge-recipes/
12+
serve/*/
13+
test/assets/*/
14+
test/lib/

wasm/CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
cmake_minimum_required(VERSION 3.28)
2+
project(git2cpp-wasm)
3+
4+
add_subdirectory(recipe)
5+
add_subdirectory(cockle-deploy)
6+
add_subdirectory(lite-deploy)
7+
add_subdirectory(test)
8+
9+
# Build everything (package, cockle and lite deployments, tests).
10+
add_custom_target(build ALL DEPENDS build-recipe build-cockle build-lite build-test)
11+
12+
# Rebuild after change in C++ code.
13+
add_custom_target(rebuild DEPENDS rebuild-recipe rebuild-cockle rebuild-lite rebuild-test)
14+
15+
# Serve both cockle and JupyterLite deployments.
16+
add_custom_target(serve COMMAND npx static-handler --cors --coop --coep --corp serve)

wasm/Makefile

Lines changed: 0 additions & 28 deletions
This file was deleted.

wasm/README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ It works on Linux and macOS but not Windows.
1010

1111
There are 5 sub-directories:
1212

13-
- `build`: build local `git2cpp` source code into an Emscripten-forge package.
13+
- `recipe`: build local `git2cpp` source code into an Emscripten-forge package.
1414
- `cockle-deploy`: create a `cockle` deployment in the `serve` directory.
1515
- `lite-deploy`: create a JupyterLite `terminal` deployment in the `serve` directory.
1616
- `serve`: where the two deployments are served from.
@@ -29,9 +29,13 @@ micromamba activate git2cpp-wasm
2929
Then to build the WebAssembly package, both deployments and the testing resources use:
3030

3131
```bash
32+
cmake .
3233
make
3334
```
3435

36+
The built emscripten-forge package will be file named something like `git2cpp-0.0.5-h7223423_1.tar.bz2`
37+
in the directory `recipe/em-force-recipes/output/emscripten-wasm32`.
38+
3539
The local deployments in the `serve` directory can be manually checked using:
3640

3741
```bash
@@ -58,7 +62,13 @@ make test
5862
```
5963

6064
This runs (some of) the tests in the top-level `test` directory with various monkey patching so that
61-
`git2cpp` commands are executed in the browser.
65+
`git2cpp` commands are executed in the browser. If there are problems running the tests then ensure
66+
you have the latest `playwright` browser installed:
67+
68+
69+
```bash
70+
playwright install chromium
71+
```
6272

6373
## Rebuild
6474

wasm/build/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

wasm/build/Makefile

Lines changed: 0 additions & 31 deletions
This file was deleted.

wasm/cockle-deploy/.gitignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

wasm/cockle-deploy/CMakeLists.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
cmake_minimum_required(VERSION 3.28)
2+
project(git2cpp-wasm-cockle-deploy)
3+
4+
include("../common.cmake")
5+
6+
set(SERVE_DIR "../serve/cockle")
7+
8+
add_custom_target(build-cockle
9+
DEPENDS build-recipe
10+
COMMAND npm install
11+
COMMAND COCKLE_WASM_EXTRA_CHANNEL=${BUILT_PACKAGE_DIR} npm run build
12+
BYPRODUCTS cockle_wasm_env node_modules ${SERVE_DIR}
13+
)
14+
15+
add_custom_target(rebuild-cockle
16+
DEPENDS rebuild-recipe clean-env-cockle build-cockle
17+
)
18+
19+
add_custom_target(clean-env-cockle
20+
COMMAND ${CMAKE_COMMAND} -E remove_directory cockle_wasm_env
21+
)

wasm/cockle-deploy/Makefile

Lines changed: 0 additions & 16 deletions
This file was deleted.

wasm/common.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Emscripten-forge recipes directory relative to 'recipe' directory
2+
set(EM_FORGE_RECIPES_DIR "em-forge-recipes")
3+
4+
# Output directory for built emscripten-forge packages relative to EM_FORGE_RECIPES_DIR
5+
set(BUILT_PACKAGE_SUBDIR "output")
6+
7+
# Output directory for built emscripten-forge packages relative to subdirectories of this directory
8+
set(BUILT_PACKAGE_DIR "../recipe/${EM_FORGE_RECIPES_DIR}/${BUILT_PACKAGE_SUBDIR}")

0 commit comments

Comments
 (0)