diff --git a/.gitignore b/.gitignore index 9b59c1d4dd..20c08e65eb 100644 --- a/.gitignore +++ b/.gitignore @@ -44,8 +44,7 @@ local.properties /third_party /out -cmake-build-debug -cmake-build-release +cmake-build-* node_modules Build/ test/out/ diff --git a/web/README.md b/web/README.md index a150fece30..2a6d0f94cf 100644 --- a/web/README.md +++ b/web/README.md @@ -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/ @@ -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 +``` diff --git a/web/README.zh_CN.md b/web/README.zh_CN.md index 111270a228..c9537eb243 100644 --- a/web/README.zh_CN.md +++ b/web/README.zh_CN.md @@ -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目录下 @@ -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 +``` diff --git a/web/script/build.sh b/web/script/build.sh index cedaa0c01a..a25149527d 100755 --- a/web/script/build.sh +++ b/web/script/build.sh @@ -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/ \