Skip to content

Commit

Permalink
Optimize the web-side compilation process. (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
lvpengwei authored Feb 11, 2022
1 parent 2ec80e3 commit 7cb116e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ local.properties

/third_party
/out
cmake-build-debug
cmake-build-release
cmake-build-*
node_modules
Build/
test/out/
Expand Down
12 changes: 9 additions & 3 deletions web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,7 @@ $ npm install

### Debug

Remove `cmake-build-debug` folder that in libpag root folder, run `build.sh debug` to build `libpag.wasm` file.

If you use CLion IDE, you cloud reload the project by `Tools->CMake->Reload CMake Project`.
Execute `build.sh debug` to get `libpag.wasm` file.

```bash
# ./web/script/
Expand Down Expand Up @@ -140,3 +138,11 @@ $ cd script
$ chmod +x ./build.sh
$ ./build.sh
```

### Build with CLion

Create a new profile, and use the following **CMake options**(find them under **CLion** > **Preferences** > **Build, Execution, Deployment** > **CMake**

```
CMAKE_TOOLCHAIN_FILE=path/to/emscripten/emscripten/version/cmake/Modules/Platform/Emscripten.cmake
```
10 changes: 9 additions & 1 deletion web/README.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ $ npm install

### 开发流程

删除项目根目录的 `cmake-build-debug`执行 `build.sh debug` 打包 C++ 代码,每次改动 C++ 代码都需要重新打包新的 `libpag.wasm` 文件,执行完成之后可以通过 `Tools->CMake->Reload CMake Project` 刷新项目
执行 `build.sh debug` 来获得 `libpag.wasm` 文件

```bash
# web/script目录下
Expand Down Expand Up @@ -147,3 +147,11 @@ $ chmod +x ./build.sh
# 打包
$ ./build.sh
```

### CLion 编译

创建一个新的 profile,然后使用下面的 **CMake options**(位置在 **CLion** > **Preferences** > **Build, Execution, Deployment** > **CMake**

```
CMAKE_TOOLCHAIN_FILE=path/to/emscripten/emscripten/version/cmake/Modules/Platform/Emscripten.cmake
```
6 changes: 2 additions & 4 deletions web/script/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@ fi
RELEASE_CONF="-Oz -s"
CMAKE_BUILD_TYPE=Relese
if [[ $@ == *debug* ]]; then
BUILD_DIR=../../cmake-build-debug
CMAKE_BUILD_TYPE=Debug
RELEASE_CONF="-O0 -g3 -s SAFE_HEAP=1"
BUILD_TS=""
fi

emcmake cmake -S $SOURCE_DIR -B $BUILD_DIR \
-DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE"
emcmake cmake -S $SOURCE_DIR -B $BUILD_DIR -G Ninja -DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE"

cmake --build $BUILD_DIR --target pag -- -j 12
cmake --build $BUILD_DIR --target pag

emcc $RELEASE_CONF -std=c++17 \
-I$SOURCE_DIR/include/ \
Expand Down

0 comments on commit 7cb116e

Please sign in to comment.