Updated with more clearer intention. Future projects should use this.
git-svn-id: https://svn.tlawal.org/svn/ragar@2 618e81bd-0769-42e7-8608-769e73fecc77
This commit is contained in:
parent
664727ae54
commit
bc2c180bd3
104
build.bat
104
build.bat
@ -2,73 +2,121 @@
|
|||||||
setlocal
|
setlocal
|
||||||
cd /D "%~dp0"
|
cd /D "%~dp0"
|
||||||
|
|
||||||
:: --- Unpack Arguments ---------------------------------------------------------------
|
:: -- Useage Notes (July 25th, 2024) ----------------------------------------------------------
|
||||||
for %%a in (%*) do set "%%a=1"
|
::
|
||||||
|
:: This is a central build script for use in a windows development environment with support
|
||||||
|
:: for msvc(default) and clang, specifically for C/C++ projects. It takes simple alphanumeric
|
||||||
|
:: arguments which controls (1) what compiler & linker is used, (2) what mode the the
|
||||||
|
:: application is built in.
|
||||||
|
::
|
||||||
|
:: By default if no options are passed, everything is built in debug mode with the MSVC
|
||||||
|
:: compiler
|
||||||
|
::
|
||||||
|
:: Possible ways to use:
|
||||||
|
::
|
||||||
|
:: `build debug`
|
||||||
|
:: `build debug msvc`
|
||||||
|
:: `build release clang`
|
||||||
|
::
|
||||||
|
|
||||||
|
:: Unpack Arguments
|
||||||
|
for %%a in (%*) do in set "%%a=1"
|
||||||
if not "%msvc%"=="1" if not "%clang%"=="1" set msvc=1
|
if not "%msvc%"=="1" if not "%clang%"=="1" set msvc=1
|
||||||
if not "%release%"=="1" set debug=1
|
if not "%release%"=="1" set debug=1
|
||||||
if "%debug%"=="1" set release=0 && echo [debug mode]
|
if "%debug%"=="1" set release=0 && echo [debug mode]
|
||||||
if "%release%"=="1" set debug=0 && echo [release mode]
|
if "%release%"=="1" set debug=0 && echo [release mode]
|
||||||
|
|
||||||
if "%msvc%"=="1" set clang=0 && echo [msvc compile]
|
if "%msvc%"=="1" set clang=0 && echo [msvc compile]
|
||||||
if "%clang%"=="1" set msvc=0 && echo [clang compile]
|
if "%clang%"=="1" set msvc=0 && echo [clang compile]
|
||||||
if "%~1"=="" echo [default mode, assuming `goff` build] && set goff=1
|
|
||||||
|
|
||||||
:: --- Compile/Link Line Definitions -------------------------------------------------
|
:: Fix
|
||||||
set cl_common= /I..\src\ /nologo /FC /Z7
|
if "%~1"=="" echo [default mode] && set ragar=1
|
||||||
set cl_out= /out:
|
if "%~1"=="release" if "%~2"=="" echo [default release mode] && set ragar=1
|
||||||
rem Add back resource.res to cl_link
|
|
||||||
set cl_link= /link /MANIFEST:EMBED /INCREMENTAL:NO resource.res
|
:: Third Party libraries
|
||||||
set cl_debug= call cl /Od /DBUILD_DEBUG=1 %cl_common%
|
set third_party_includes="%~dp0\src\\third_party\\SDL2\\include"
|
||||||
|
set third_party_lib="%~dp0\src\\third_party\\SDL2\\lib\\x64"
|
||||||
|
|
||||||
|
:: MSVC
|
||||||
|
set cl_common= /I..\src\ /nologo /FC /Z7 /I%third_party_includes%
|
||||||
|
set cl_debug= call cl /Od /Ob1 /DBUILD_DEBUG=1 %cl_common%
|
||||||
set cl_release= call cl /O2 /DBUILD_DEBUG=0 %cl_common%
|
set cl_release= call cl /O2 /DBUILD_DEBUG=0 %cl_common%
|
||||||
|
set cl_link= /link /INCREMENTAL:NO resource.res /LIBPATH:%third_party_lib% SDL2.lib SDL2main.lib shell32.lib
|
||||||
|
set cl_out= /out:
|
||||||
|
|
||||||
set clang_common=
|
:: Clang
|
||||||
|
set clang_common= -I..\src\ -I..\local\ -gcodeview -fdiagnostics-absolute-paths -Wall -Wno-unknown-warning-option -Wno-missing-braces -Wno-unused-function -Wno-writable-strings -Wno-unused-value -Wno-unused-variable -Wno-unused-local-typedef -Wno-deprecated-register -Wno-deprecated-declarations -Wno-unused-but-set-variable -Wno-single-bit-bitfield-constant-conversion -Wno-compare-distinct-pointer-types -Wno-initializer-overrides -Wno-incompatible-pointer-types-discards-qualifiers -Xclang -flto-visibility-public-std -D_USE_MATH_DEFINES -Dstrdup=_strdup -Dgnu_printf=printf
|
||||||
|
set clang_debug= call clang -g -O0 -DBUILD_DEBUG=1 %clang_common% %auto_compile_flags%
|
||||||
|
set clang_release= call clang -g -O2 -DBUILD_DEBUG=0 %clang_common% %auto_compile_flags%
|
||||||
|
set clang_link= -fuse-ld=lld -Xlinker /MANIFEST:EMBED -Xlinker logo.res
|
||||||
set clang_out= -o
|
set clang_out= -o
|
||||||
set clang_link=
|
|
||||||
set clang_debug= call cl -g -O0 -DBUILD_DEBUG=1 %clang_common%
|
|
||||||
set clang_release= call cl -g -O2 -DBUILD_DEBUG=0 %clang_common%
|
|
||||||
|
|
||||||
:: --- Per-Build Settings ----------------------------------------------------
|
:: Per-Build Setting
|
||||||
:: set link_dll=-DLL
|
|
||||||
|
:: --- Per-Build Settings -----------------------------------------------------
|
||||||
|
set link_dll=-DLL
|
||||||
|
|
||||||
|
:: MSVC
|
||||||
if "%msvc%"=="1" set only_compile=/c
|
if "%msvc%"=="1" set only_compile=/c
|
||||||
if "%msvc%"=="1" set EHsc=/EHsc
|
if "%msvc%"=="1" set EHsc=/EHsc
|
||||||
if "%msvc%"=="1" set rc=rc.exe
|
if "%msvc%"=="1" set no_aslr=/DYNAMICBASE:NO
|
||||||
|
if "%msvc%"=="1" set rc=call rc
|
||||||
|
|
||||||
if "%clang%"=="1" set EHsc=
|
:: Clang
|
||||||
if "%clang%"=="1" set only_compile=-c
|
if "%clang%"=="1" set only_compile=-c
|
||||||
if "%clang%"=="1" set rc=llvm-rc.exe
|
if "%clang%"=="1" set EHsc=
|
||||||
|
if "%clang%"=="1" set no_aslr=-Wl,/DYNAMICBASE:NO
|
||||||
|
if "%clang%"=="1" set rc=call llvm-rc
|
||||||
|
|
||||||
:: --- Choose Compile/Link Lines ---------------------------------------------
|
:: --- Choose Compile/Link Lines ----------------------------------------------
|
||||||
if "%msvc%"=="1" set compile_debug=%cl_debug%
|
if "%msvc%"=="1" set compile_debug=%cl_debug%
|
||||||
if "%msvc%"=="1" set compile_release=%cl_release%
|
if "%msvc%"=="1" set compile_release=%cl_release%
|
||||||
if "%msvc%"=="1" set compile_link=%cl_link%
|
if "%msvc%"=="1" set compile_link=%cl_link%
|
||||||
if "%msvc%"=="1" set out=%cl_out%
|
if "%msvc%"=="1" set out=%cl_out%
|
||||||
|
|
||||||
|
rem if "%clang%"=="1" set compile_debug=%clang_debug%
|
||||||
|
rem if "%clang%"=="1" set compile_release=%clang_release%
|
||||||
|
rem if "%clang%"=="1" set compile_link=%clang_link%
|
||||||
|
rem if "%clang%"=="1" set out=%clang_out%
|
||||||
|
|
||||||
if "%debug%"=="1" set compile=%compile_debug%
|
if "%debug%"=="1" set compile=%compile_debug%
|
||||||
if "%release%"=="1" set compile=%compile_release%
|
if "%release%"=="1" set compile=%compile_release%
|
||||||
|
|
||||||
rem :: --- Get Current SVN Revision ID ---------------------------------------------
|
:: Prep Directory
|
||||||
rem for /f "tokens=2 delims==" %%i in ('svn info --show-item revision') do set compile=%compile% -DBUILD_SVN_REVISION=\"%%i\"
|
|
||||||
|
|
||||||
:: --- Prep Directory --------------------------------------------------------
|
|
||||||
if not exist run_tree (
|
if not exist run_tree (
|
||||||
mkdir run_tree
|
mkdir run_tree
|
||||||
echo "[WARNING] creating run_tree, data files may not exist."
|
echo "[WARNING] creating run_tree, data files may not exist."
|
||||||
)
|
)
|
||||||
|
|
||||||
:: --- Produce Logo Icon File ------------------------------------------------
|
:: Process rc Files
|
||||||
pushd run_tree
|
pushd run_tree
|
||||||
%rc% /nologo /fo resource.res data\resource.rc || exit /b 1
|
%rc% /nologo /fo resource.res data\resource.rc || exit /b 1
|
||||||
popd
|
popd
|
||||||
|
|
||||||
:: --- Build Everything (@build_targets) -------------------------------------
|
:: Get Current SVN/Git Commit ID
|
||||||
|
:: SVN
|
||||||
|
for /f "tokens=2 delims==" %%i in ('svn info --show-item revision') do set compile=%compile% -DBUILD_SVN_REVISION=\"%%i\"
|
||||||
|
:: Git
|
||||||
|
:: for /f %%i in ('call git describe --always --dirty') do set compile=%compile% -DBUILD_GIT_HASH=\"%%i\"
|
||||||
|
|
||||||
|
:: Build
|
||||||
pushd run_tree
|
pushd run_tree
|
||||||
if "%goff%"=="1" %compile% %gfx% ..\src\goff\goff_main.c %compile_link% %out%"Goff Scan.exe" || exit /b 1
|
if "%ragar%"=="1" %compile% ..\src\ragar\ragar_main.c %compile_link% %out%ragar.exe /SUBSYSTEM:WINDOWS || exit /b 1
|
||||||
popd
|
popd
|
||||||
|
|
||||||
:: --- Unset -----------------------------------------------------------------
|
:: Unset
|
||||||
for %%a in (%*) do set "%%a=0"
|
for %%a in (%*) do set "%%a=0"
|
||||||
set goff=
|
set ragar=
|
||||||
set compile=
|
set compile=
|
||||||
set compile_link=
|
set compile_link=
|
||||||
set out=
|
set out=
|
||||||
set msvc=
|
set msvc=
|
||||||
set debug=
|
set debug=
|
||||||
|
set release=
|
||||||
|
|
||||||
|
rem :: Warning
|
||||||
|
rem if "%didbuild%"=="" (
|
||||||
|
rem echo [WARNING] no valid build target specified; must use build target names as arguments to this script, like `build debug` or `build release`.
|
||||||
|
rem exit /b 1
|
||||||
|
rem )
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user