Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize the web-side compilation process. #101

Merged
merged 1 commit into from
Feb 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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