0032536: Configuration - extend adm/scripts with USE_DRACO option
[occt.git] / adm / scripts / wasm_sample_build.bat
1 @echo OFF
2
3 rem Auxiliary script for semi-automated building of WebGL sample.
4 rem wasm_custom.bat should be configured with paths to CMake, 3rd-parties and Emscripten SDK.
5 rem FreeType should be specified as mandatory dependency.
6
7 set "aCasSrc=%~dp0..\.."
8 set "aBuildRoot=%aCasSrc%\work"
9
10 set aNbJobs=%NUMBER_OF_PROCESSORS%
11
12 rem Paths to 3rd-party tools and libraries
13 set "aCmakeBin="
14 set "aFreeType="
15
16 rem Build stages to perform
17 set "toCMake=1"
18 set "toClean=0"
19 set "toMake=1"
20 set "toInstall=1"
21 set "toDebug=0"
22 set "sourceMapBase="
23
24 rem Configuration file
25 if exist "%~dp0wasm_custom.bat" call "%~dp0wasm_custom.bat"
26
27 call "%EMSDK_ROOT%\emsdk_env.bat"
28 set "aToolchain=%EMSDK%/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake"
29 if not ["%aCmakeBin%"] == [""] ( set "PATH=%aCmakeBin%;%PATH%" )
30
31 set "aBuildType=Release"
32 set "aBuildTypePrefix="
33 if ["%toDebug%"] == ["1"] (
34   set "aBuildType=Debug"
35   set "aBuildTypePrefix=-debug"
36 )
37
38 call :cmakeGenerate
39 if not ["%1"] == ["-nopause"] (
40   pause
41 )
42
43 goto :eof
44
45 :cmakeGenerate
46 set "aPlatformAndCompiler=wasm32%aBuildTypePrefix%"
47 set "aDestDirOcct=%aBuildRoot%\occt-%aPlatformAndCompiler%"
48 set "aSrcRootSmpl=%aCasSrc%\samples\webgl"
49 set "aWorkDirSmpl=%aBuildRoot%\sample-%aPlatformAndCompiler%-make"
50 set "aDestDirSmpl=%aBuildRoot%\sample-%aPlatformAndCompiler%"
51 set "aLogFileSmpl=%aBuildRoot%\sample-%aPlatformAndCompiler%-build.log"
52 if ["%toCMake%"] == ["1"] (
53   if ["%toClean%"] == ["1"] (
54     rmdir /S /Q %aWorkDirSmpl%"
55     rmdir /S /Q %aDestDirSmpl%"
56   )
57 )
58 if not exist "%aWorkDirSmpl%" ( mkdir "%aWorkDirSmpl%" )
59 if     exist "%aLogFileSmpl%" ( del   "%aLogFileSmpl%" )
60
61 pushd "%aWorkDirSmpl%"
62
63 if ["%toCMake%"] == ["1"] (
64   cmake -G "MinGW Makefiles" ^
65  -D CMAKE_TOOLCHAIN_FILE:FILEPATH="%aToolchain%" ^
66  -D CMAKE_BUILD_TYPE:STRING="%aBuildType%" ^
67  -D CMAKE_INSTALL_PREFIX:PATH="%aDestDirSmpl%" ^
68  -D SOURCE_MAP_BASE:STRING="%sourceMapBase%" ^
69  -D OpenCASCADE_DIR:PATH="%aDestDirOcct%/lib/cmake/opencascade" ^
70  -D freetype_DIR:PATH="%aFreeType%/lib/cmake/freetype" ^
71  "%aSrcRootSmpl%"
72
73   if errorlevel 1 (
74     popd
75     pause
76     exit /B
77     goto :eof
78   )
79 )
80 if ["%toClean%"] == ["1"] (
81   mingw32-make clean
82 )
83
84 if ["%toMake%"] == ["1"] (
85   echo Building...
86   mingw32-make -j %aNbJobs% 2>> "%aLogFileSmpl%"
87   if errorlevel 1 (
88     type "%aLogFileSmpl%"
89     popd
90     pause
91     exit /B
92     goto :eof
93   )
94   type "%aLogFileSmpl%"
95 )
96
97 if ["%toInstall%"] == ["1"] (
98   mingw32-make install 2>> "%aLogFileSmpl%"
99   if errorlevel 1 (
100     type "%aLogFileSmpl%"
101     popd
102     pause
103     exit /B
104     goto :eof
105   )
106 )
107 popd
108
109 goto :eof