diff --git a/adm/scripts/wasm_build.bat b/adm/scripts/wasm_build.bat index 219ab93310..c3ee490a66 100644 --- a/adm/scripts/wasm_build.bat +++ b/adm/scripts/wasm_build.bat @@ -4,36 +4,90 @@ rem Auxiliary script for semi-automated building of OCCT for WASM platform. rem wasm_custom.bat should be configured with paths to CMake, 3rd-parties and Emscripten SDK. rem FreeType should be specified as mandatory dependency. -set "aSrcRoot=%~dp0..\.." -set "aBuildRoot=work" +set "aCasSrc=%~dp0..\.." +set "aBuildRoot=%aCasSrc%\work" set aNbJobs=%NUMBER_OF_PROCESSORS% +rem Paths to 3rd-party tools and libraries +set "aCmakeBin=" +set "aFreeType=" +set "aRapidJson=" + +rem Build stages to perform set "toCMake=1" set "toClean=0" set "toMake=1" set "toInstall=1" +set "toPack=0" +set "toBuildSample=0" +rem OCCT Modules to build set "BUILD_ModelingData=ON" set "BUILD_ModelingAlgorithms=ON" set "BUILD_Visualization=ON" set "BUILD_ApplicationFramework=ON" set "BUILD_DataExchange=ON" +rem Optional 3rd-party libraries to enable +set "USE_RAPIDJSON=OFF" + +rem Archive tool +set "THE_7Z_PARAMS=-t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on" +set "THE_7Z_PATH=%ProgramW6432%\7-Zip\7z.exe" + rem Configuration file if exist "%~dp0wasm_custom.bat" call "%~dp0wasm_custom.bat" call "%EMSDK_ROOT%\emsdk_env.bat" set "aToolchain=%EMSDK%/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake" +if not ["%aCmakeBin%"] == [""] ( set "PATH=%aCmakeBin%;%PATH%" ) set "anOcctVerSuffix=" set "anOcctVersion=0.0.0" set "aGitBranch=" -for /f tokens^=2^ delims^=^" %%i in ('findstr /b /c:"#define OCC_VERSION_DEVELOPMENT" "%aSrcRoot%\src\Standard\Standard_Version.hxx"') do ( set "anOcctVerSuffix=%%i" ) -for /f tokens^=2^ delims^=^" %%i in ('findstr /b /c:"#define OCC_VERSION_COMPLETE" "%aSrcRoot%\src\Standard\Standard_Version.hxx"') do ( set "anOcctVersion=%%i" ) +for /f tokens^=2^ delims^=^" %%i in ('findstr /b /c:"#define OCC_VERSION_DEVELOPMENT" "%aCasSrc%\src\Standard\Standard_Version.hxx"') do ( set "anOcctVerSuffix=%%i" ) +for /f tokens^=2^ delims^=^" %%i in ('findstr /b /c:"#define OCC_VERSION_COMPLETE" "%aCasSrc%\src\Standard\Standard_Version.hxx"') do ( set "anOcctVersion=%%i" ) for /f %%i in ('git symbolic-ref --short HEAD') do ( set "aGitBranch=%%i" ) call :cmakeGenerate +if errorlevel 1 ( + if not ["%1"] == ["-nopause"] ( + pause + ) + exit /B 1 + goto :eof +) + +for /F "skip=1 delims=" %%F in (' + wmic PATH Win32_LocalTime GET Day^,Month^,Year /FORMAT:TABLE +') do ( + for /F "tokens=1-3" %%L in ("%%F") do ( + set DAY00=0%%L + set MONTH00=0%%M + set YEAR=%%N + ) +) +set DAY00=%DAY00:~-2% +set MONTH00=%MONTH00:~-2% +set "aRevision=-%YEAR%-%MONTH00%-%DAY00%" +rem set "aRevision=-%aGitBranch%" +set "anArchName=occt-%anOcctVersion%%anOcctVerSuffix%%aRevision%-wasm32" +set "aTarget=%aBuildRoot%\%anArchName%" +if ["%toPack%"] == ["1"] ( + echo Creating archive %anArchName%.7z + rmdir /S /Q "%aTarget%" + if not exist "%aTarget%" ( mkdir "%aTarget%" ) + if exist "%aBuildRoot%/%anArchName%.7z" del "%aBuildRoot%/%anArchName%.7z" + xcopy /S /Y "%aDestDir%\*" "%aTarget%\" + + if ["%toBuildSample%"] == ["1"] ( + if not exist "%aTarget%\sample" ( mkdir "%aTarget%\sample" ) + xcopy /S /Y "%aDestDirSmpl%\*" "%aTarget%\sample\" + ) + + "%THE_7Z_PATH%" a -r %THE_7Z_PARAMS% "%aBuildRoot%/%anArchName%.7z" "%aTarget%" +) if not ["%1"] == ["-nopause"] ( pause ) @@ -41,13 +95,34 @@ if not ["%1"] == ["-nopause"] ( goto :eof :cmakeGenerate -set "aPlatformAndCompiler=wasm" -set "aWorkDir=%aSrcRoot%\%aBuildRoot%\%aPlatformAndCompiler%-make" -set "aDestDir=%aSrcRoot%\%aBuildRoot%\%aPlatformAndCompiler%" -set "aLogFile=%aSrcRoot%\%aBuildRoot%\build-%aPlatformAndCompiler%.log" +set "aPlatformAndCompiler=wasm32" +set "aWorkDir=%aBuildRoot%\%aPlatformAndCompiler%-make" +set "aDestDir=%aBuildRoot%\%aPlatformAndCompiler%" +set "aLogFile=%aBuildRoot%\build-%aPlatformAndCompiler%.log" +if ["%toCMake%"] == ["1"] ( + if ["%toClean%"] == ["1"] ( + rmdir /S /Q %aWorkDir%" + rmdir /S /Q %aDestDir%" + ) +) if not exist "%aWorkDir%" ( mkdir "%aWorkDir%" ) if exist "%aLogFile%" ( del "%aLogFile%" ) +set "aSrcRootSmpl=%aCasSrc%\samples\webgl" +set "aWorkDirSmpl=%aBuildRoot%\%aPlatformAndCompiler%-sample-make" +set "aDestDirSmpl=%aBuildRoot%\%aPlatformAndCompiler%-sample" +set "aLogFileSmpl=%aBuildRoot%\build-%aPlatformAndCompiler%-sample.log" +if ["%toBuildSample%"] == ["1"] ( + if ["%toCMake%"] == ["1"] ( + if ["%toClean%"] == ["1"] ( + rmdir /S /Q %aWorkDirSmpl%" + rmdir /S /Q %aDestDirSmpl%" + ) + ) + if not exist "%aWorkDirSmpl%" ( mkdir "%aWorkDirSmpl%" ) + if exist "%aLogFileSmpl%" ( del "%aLogFileSmpl%" ) +) + rem include some information about OCCT into archive echo ^
> "%aWorkDir%\VERSION.html"
git status >> "%aWorkDir%\VERSION.html"
@@ -59,9 +134,9 @@ echo Start building OCCT for %aPlatformAndCompiler%>> %aLogFile%
pushd "%aWorkDir%"
-set aTimeZERO=%TIME%
+set "aTimeZERO=%TIME%"
if ["%toCMake%"] == ["1"] (
- echo "Configuring OCCT for WASM..."
+ echo Configuring OCCT for WASM...
cmake -G "MinGW Makefiles" ^
-D CMAKE_TOOLCHAIN_FILE:FILEPATH="%aToolchain%" ^
-D CMAKE_BUILD_TYPE:STRING="Release" ^
@@ -80,7 +155,10 @@ if ["%toCMake%"] == ["1"] (
-D BUILD_MODULE_DataExchange:BOOL="%BUILD_DataExchange%" ^
-D BUILD_MODULE_Draw:BOOL="OFF" ^
-D BUILD_DOC_Overview:BOOL="OFF" ^
- "%aSrcRoot%"
+ -D USE_RAPIDJSON:BOOL="%USE_RAPIDJSON%" ^
+ -D 3RDPARTY_RAPIDJSON_DIR:PATH="%aRapidJson%" ^
+ -D 3RDPARTY_RAPIDJSON_INCLUDE_DIR:PATH="%aRapidJson%/include" ^
+ "%aCasSrc%"
if errorlevel 1 (
popd
@@ -88,61 +166,113 @@ if ["%toCMake%"] == ["1"] (
goto :eof
)
)
-set aTimeGEN=%TIME%
+set "aTimeGEN=%TIME%"
call :computeDuration %aTimeZERO% %aTimeGEN%
if ["%toCMake%"] == ["1"] (
echo Generation time: %DURATION%
echo Generation time: %DURATION%>> "%aLogFile%"
)
-if "%toClean%"=="1" (
+if ["%toClean%"] == ["1"] (
mingw32-make clean
)
-if "%toMake%"=="1" (
+if ["%toMake%"] == ["1"] (
echo Building...
mingw32-make -j %aNbJobs% 2>> "%aLogFile%"
if errorlevel 1 (
+ type "%aLogFile%"
popd
exit /B 1
goto :eof
)
type "%aLogFile%"
)
-set aTimeBUILD=%TIME%
+set "aTimeBUILD=%TIME%"
call :computeDuration %aTimeGEN% %aTimeBUILD%
-if "%toMake%"=="1" (
+if ["%toMake%"] == ["1"] (
echo Building time: %DURATION%
echo Building time: %DURATION%>> "%aLogFile%"
)
call :computeDuration %aTimeZERO% %aTimeBUILD%
-if "%toMake%"=="1" (
+if ["%toMake%"] == ["1"] (
echo Total building time: %DURATION%
echo Total building time: %DURATION%>> "%aLogFile%"
)
-if "%toInstall%"=="1" (
+if ["%toInstall%"] == ["1"] (
echo Installing into %aDestDir%...
mingw32-make install 2>> "%aLogFile%"
copy /Y "%aWorkDir%\VERSION.html" "%aDestDir%\VERSION.html"
)
-set aTimeINSTALL=%TIME%
-call :computeDuration %aTimeBUILD% %aTimeINSTALL%
-if "%toInstall%"=="1" (
+set "aTimeINSTALL=%TIME%"
+call :computeDuration "%aTimeBUILD%" "%aTimeINSTALL%"
+if ["%toInstall%"] == ["1"] (
echo Install time: %DURATION%
echo Install time: %DURATION%>> "%aLogFile%"
)
-call :computeDuration %aTimeZERO% %aTimeINSTALL%
+call :computeDuration "%aTimeZERO%" "%aTimeINSTALL%"
echo Total time: %DURATION%
echo Total time: %DURATION%>> "%aLogFile%"
popd
+if ["%toBuildSample%"] == ["0"] (
+ goto :eof
+)
+
+pushd "%aWorkDirSmpl%"
+
+if ["%toCMake%"] == ["1"] (
+ cmake -G "MinGW Makefiles" ^
+ -D CMAKE_TOOLCHAIN_FILE:FILEPATH="%aToolchain%" ^
+ -D CMAKE_BUILD_TYPE:STRING="Release" ^
+ -D CMAKE_INSTALL_PREFIX:PATH="%aDestDirSmpl%" ^
+ -D OpenCASCADE_DIR:PATH="%aDestDir%/lib/cmake/opencascade" ^
+ -D freetype_DIR:PATH="%aFreeType%/lib/cmake/freetype" ^
+ "%aSrcRootSmpl%"
+
+ if errorlevel 1 (
+ popd
+ pause
+ exit /B
+ goto :eof
+ )
+)
+if ["%toClean%"] == ["1"] (
+ mingw32-make clean
+)
+
+if ["%toMake%"] == ["1"] (
+ echo Building...
+ mingw32-make -j %aNbJobs% 2>> "%aLogFileSmpl%"
+ if errorlevel 1 (
+ type "%aLogFileSmpl%"
+ popd
+ pause
+ exit /B
+ goto :eof
+ )
+ type "%aLogFileSmpl%"
+)
+
+if ["%toInstall%"] == ["1"] (
+ mingw32-make install 2>> "%aLogFileSmpl%"
+ if errorlevel 1 (
+ type "%aLogFileSmpl%"
+ popd
+ pause
+ exit /B
+ goto :eof
+ )
+)
+popd
+
goto :eof
:computeDuration
-set aTimeFrom=%1
-set aTimeEnd=%2
+set "aTimeFrom=%~1"
+set "aTimeEnd=%~2"
rem handle time before 10AM (win10 - remove empty space at the beginning)
if "%aTimeFrom:~0,1%"==" " set "aTimeFrom=%aTimeFrom:~1%"
if "%aTimeEnd:~0,1%"==" " set "aTimeEnd=%aTimeEnd:~1%"
diff --git a/adm/scripts/wasm_custom.bat.template b/adm/scripts/wasm_custom.bat.template
index 5b21b7ad13..a9ef56f60d 100644
--- a/adm/scripts/wasm_custom.bat.template
+++ b/adm/scripts/wasm_custom.bat.template
@@ -1,6 +1,8 @@
-rem Environment configuration template for occ_build_wasm.bat (to be renamed as wasm_custom_env.bat)
-set "aFreeType=%aSrcRoot%\..\3rdparty\freetype-2.7.1-wasm"
-set "EMSDK_ROOT=%aSrcRoot%\..\emsdk"
+rem Environment configuration template for wasm_build.bat (to be renamed as wasm_custom.bat)
+set "EMSDK_ROOT=%aCasSrc%\..\emsdk"
+set "aFreeType=%aCasSrc%\..\3rdparty\freetype-2.7.1-wasm"
+rem set "aRapidJson=%aCasSrc%\..\3rdparty\rapidjson-1.1.0"
+rem set "aCmakeBin=%ProgramW6432%\CMake\bin"
rem Uncomment to customize building steps
rem set "aBuildRoot=work"
@@ -8,9 +10,13 @@ rem set "toCMake=1"
rem set "toClean=0"
rem set "toMake=1"
rem set "toInstall=1"
+rem set "toPack=0"
+rem set "toBuildSample=1"
rem set "BUILD_ModelingData=ON"
rem set "BUILD_ModelingAlgorithms=ON"
rem set "BUILD_Visualization=ON"
rem set "BUILD_ApplicationFramework=ON"
rem set "BUILD_DataExchange=ON"
+
+rem set "USE_RAPIDJSON=OFF"
diff --git a/adm/scripts/wasm_sample_build.bat b/adm/scripts/wasm_sample_build.bat
new file mode 100644
index 0000000000..84c917e33f
--- /dev/null
+++ b/adm/scripts/wasm_sample_build.bat
@@ -0,0 +1,99 @@
+@echo OFF
+
+rem Auxiliary script for semi-automated building of WebGL sample.
+rem wasm_custom.bat should be configured with paths to CMake, 3rd-parties and Emscripten SDK.
+rem FreeType should be specified as mandatory dependency.
+
+set "aCasSrc=%~dp0..\.."
+set "aBuildRoot=%aCasSrc%\work"
+
+set aNbJobs=%NUMBER_OF_PROCESSORS%
+
+rem Paths to 3rd-party tools and libraries
+set "aCmakeBin="
+set "aFreeType="
+
+rem Build stages to perform
+set "toCMake=1"
+set "toClean=0"
+set "toMake=1"
+set "toInstall=1"
+
+rem Configuration file
+if exist "%~dp0wasm_custom.bat" call "%~dp0wasm_custom.bat"
+
+call "%EMSDK_ROOT%\emsdk_env.bat"
+set "aToolchain=%EMSDK%/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake"
+if not ["%aCmakeBin%"] == [""] ( set "PATH=%aCmakeBin%;%PATH%" )
+
+call :cmakeGenerate
+if not ["%1"] == ["-nopause"] (
+ pause
+)
+
+goto :eof
+
+:cmakeGenerate
+set "aPlatformAndCompiler=wasm32"
+set "aDestDirOcct=%aBuildRoot%\%aPlatformAndCompiler%"
+set "aSrcRootSmpl=%aCasSrc%\samples\webgl"
+set "aWorkDirSmpl=%aBuildRoot%\%aPlatformAndCompiler%-sample-make"
+set "aDestDirSmpl=%aBuildRoot%\%aPlatformAndCompiler%-sample"
+set "aLogFileSmpl=%aBuildRoot%\build-%aPlatformAndCompiler%-sample.log"
+if ["%toCMake%"] == ["1"] (
+ if ["%toClean%"] == ["1"] (
+ rmdir /S /Q %aWorkDirSmpl%"
+ rmdir /S /Q %aDestDirSmpl%"
+ )
+)
+if not exist "%aWorkDirSmpl%" ( mkdir "%aWorkDirSmpl%" )
+if exist "%aLogFileSmpl%" ( del "%aLogFileSmpl%" )
+
+pushd "%aWorkDirSmpl%"
+
+if ["%toCMake%"] == ["1"] (
+ cmake -G "MinGW Makefiles" ^
+ -D CMAKE_TOOLCHAIN_FILE:FILEPATH="%aToolchain%" ^
+ -D CMAKE_BUILD_TYPE:STRING="Release" ^
+ -D CMAKE_INSTALL_PREFIX:PATH="%aDestDirSmpl%" ^
+ -D OpenCASCADE_DIR:PATH="%aDestDirOcct%/lib/cmake/opencascade" ^
+ -D freetype_DIR:PATH="%aFreeType%/lib/cmake/freetype" ^
+ "%aSrcRootSmpl%"
+
+ if errorlevel 1 (
+ popd
+ pause
+ exit /B
+ goto :eof
+ )
+)
+if ["%toClean%"] == ["1"] (
+ mingw32-make clean
+)
+
+if ["%toMake%"] == ["1"] (
+ echo Building...
+ mingw32-make -j %aNbJobs% 2>> "%aLogFileSmpl%"
+ if errorlevel 1 (
+ type "%aLogFileSmpl%"
+ popd
+ pause
+ exit /B
+ goto :eof
+ )
+ type "%aLogFileSmpl%"
+)
+
+if ["%toInstall%"] == ["1"] (
+ mingw32-make install 2>> "%aLogFileSmpl%"
+ if errorlevel 1 (
+ type "%aLogFileSmpl%"
+ popd
+ pause
+ exit /B
+ goto :eof
+ )
+)
+popd
+
+goto :eof