Skip to content

Instantly share code, notes, and snippets.

@shiena
Last active May 21, 2022 09:57
Show Gist options
  • Save shiena/a4770088464ca13f6e38def252aaccea to your computer and use it in GitHub Desktop.
Save shiena/a4770088464ca13f6e38def252aaccea to your computer and use it in GitHub Desktop.
build script for armorpaint
@echo off
rem build script for https://github.com/armory3d/armorpaint
rem build only armorcore module
rem Parameters:
rem clean, git clean and restore
rem update, git pull
rem rebase, git rebase
rem locale, update locale
rem win, build for Windows
rem dxr, build for Windows DXR
rem vr, build for Windows VR
rem run, run armorpaint
setlocal
set REPO=%CD%
set VSDEVCMD="C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\VsDevCmd.bat"
set RUN=%0
set ARG=%1
set OPT=%2
if "%ARG%"=="run" (
pushd %REPO%
if not exist build\krom (
exit
)
pushd build\krom
if exist ArmorPaint.exe (
start ArmorPaint.exe
)
popd
popd
exit
)
if "%ARG%"=="locale" (
if "%OPT%"=="" (
echo Require locale
goto :EOF
)
call :CHECK_PIP
if %errorlevel% neq 0 (
goto :EOF
)
pushd %REPO%
pip3 install typing_extensions -t ./Assets/locale/tools
python3 ./Assets/locale/tools/extract_locales.py %OPT%
popd
exit
)
if "%ARG%"=="update" (
call :CHECK_GIT
if %errorlevel% neq 0 (
goto :EOF
)
)
if "%ARG%"=="clean" (
call :CHECK_GIT
if %errorlevel% neq 0 (
goto :EOF
)
)
if "%ARG%"=="win" (
call :CHECK_WIN
if %errorlevel% neq 0 (
goto :EOF
)
)
if "%ARG%"=="dxr" (
call :CHECK_WIN
if %errorlevel% neq 0 (
goto :EOF
)
)
if "%ARG%"=="vr" (
call :CHECK_WIN
if %errorlevel% neq 0 (
goto :EOF
)
)
call :BUILD %REPO%
if %errorlevel% neq 0 (
goto :EOF
)
if not "%ARG%"=="update" (
rem start /b "" %RUN% run
)
goto :EOF
:BUILD
set DRIVE=%~d1
%DRIVE%
cd %REPO%
if "%ARG%"=="clean" (
rem clean git repo
git restore *
git clean -dfx
git submodule foreach --recursive git clean -dfx
git submodule foreach --recursive git restore -- .
goto :EOF
)
if "%ARG%"=="update" (
rem clean git repo
git clean -dfx
git submodule foreach --recursive git clean -dfx
rem update git repo
git switch main
git pull origin main
git submodule update --recursive --init
goto :EOF
)
if "%ARG%"=="rebase" (
rem clean git repo
git clean -dfx
git submodule foreach --recursive git clean -dfx
rem update git repo
git fetch origin
git rebase origin/main
goto :EOF
)
call :CHECK_NODEJS
if %errorlevel% neq 0 (
goto :EOF
)
if "%ARG%"=="win" (
call :UNPACK_V8
rem build Kinc
@rem begin direct3d11
armorcore\Kinc\make --from armorcore -g direct3d11
if %errorlevel% neq 0 exit /b
@rem end direct3d11
call :BUILD_ARMORPAINT
call :DELETE_V8
exit /b
)
if "%ARG%"=="dxr" (
call :UNPACK_V8
@rem begin direct3d12
git apply armorcore/patch/d3d12_raytrace.diff --directory=armorcore/Kinc
armorcore\Kinc\make --from armorcore -g direct3d12 --raytrace dxr
if %errorlevel% neq 0 exit /b
@rem end direct3d12
call :BUILD_ARMORPAINT
call :DELETE_V8
call :UNPATCH_DXR
exit /b
)
if "%ARG%"=="vr" (
call :UNPACK_V8
rem build Kinc
@rem begin direct3d11
armorcore\Kinc\make --from armorcore -g direct3d11 --vr oculus
if %errorlevel% neq 0 exit /b
@rem end direct3d11
call :BUILD_ARMORPAINT
call :DELETE_V8
exit /b
)
:CHECK_NODEJS
where /q node.exe
if %errorlevel% neq 0 (
echo Please install nodejs
exit /b 1
)
exit /b
:CHECK_GIT
where /q git.exe
if %errorlevel% neq 0 (
echo Please install git
exit /b 1
)
exit /b
:CHECK_7Z
where /q 7z.exe
if %errorlevel% neq 0 (
echo Please install 7z
exit /b 1
)
exit /b
:CHECK_VS
if not exist %VSDEVCMD% (
echo Please install Visual Studio 2019
exit /b 1
)
exit /b
:CHECK_PIP
where /q pip.exe
if %errorlevel% neq 0 (
echo Please install python/pip
exit /b 1
)
exit /b
:CHECK_WIN
call :CHECK_GIT
if %errorlevel% neq 0 (
exit /b 1
)
call :CHECK_7Z
if %errorlevel% neq 0 (
exit /b 1
)
call :CHECK_VS
if %errorlevel% neq 0 (
exit /b 1
)
call %VSDEVCMD%
if %errorlevel% neq 0 (
echo Please install Visual Studio 2019
exit /b 1
)
exit /b
:UNPACK_V8
rem unpack v8_monolith
pushd armorcore\v8\libraries\win32\release
7z x -aoa v8_monolith.7z
if %errorlevel% neq 0 exit /b
popd
exit /b
:DELETE_V8
rem delete v8_monolith
pushd armorcore\v8\libraries\win32\release
del v8_monolith.lib
if %errorlevel% neq 0 exit /b
popd
exit /b
:UNPATCH_WIN
rem unpatch
git apply -R armorcore/patch/window_handling.diff --directory=armorcore/Kinc
exit /b
:UNPATCH_DXR
rem unpatch
git apply -R armorcore/patch/d3d12_raytrace.diff --directory=armorcore/Kinc
exit /b
:BUILD_ARMORPAINT
rem build ArmorPaint
msbuild build\ArmorPaint.sln -property:Configuration=Release -verbosity:diag
if %errorlevel% neq 0 exit /b
if exist build\krom\ (
rem copy font_cjk
if exist Assets\common\extra\font_cjk.ttc (
copy /y Assets\common\extra\font_cjk.ttc build\krom\data\
)
rem copy ArmorPaint
if exist build\x64\Release\ArmorPaint.exe (
copy /y build\x64\Release\ArmorPaint.exe build\krom\ArmorPaint.exe
)
)
exit /b
endlocal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment