diff --git a/build.bat b/build.bat index 9a8c81cd..684a30d3 100644 --- a/build.bat +++ b/build.bat @@ -27,6 +27,7 @@ cd /D "%~dp0" :: - `ubsan`: enable undefined-behavior sanitizer :: - `telemetry`: enable RAD telemetry profiling support :: - `spall`: enable spall profiling support +:: - `oodle`: enable Oodle from local\oodle2*\win or an explicit OODLE_SDK_DIR :: --- Unpack Arguments ------------------------------------------------------- for %%a in (%*) do set "%%~a=1" @@ -154,6 +155,38 @@ if not exist build\blake3.lib if "%VSCMD_ARG_TGT_ARCH%" equ "x64" ( popd ) +:: --- Set up Oodle SDK ------------------------------------------------------- +if "%oodle%"=="1" ( + set "oodle_sdk_path=%OODLE_SDK_DIR%" + if not defined oodle_sdk_path ( + for /d %%d in ("%~dp0local\oodle2*") do ( + if exist "%%~fd\win\include\oodle2.h" ( + if defined oodle_sdk_path ( + echo Multiple Oodle SDKs found: "!oodle_sdk_path!" and "%%~fd\win" + echo Set OODLE_SDK_DIR to select the SDK root. + exit /b 1 + ) + set "oodle_sdk_path=%%~fd\win" + ) + ) + ) + if not defined oodle_sdk_path ( + echo Oodle SDK not found. Put an oodle2* SDK with a win subdirectory in "%~dp0local" or set OODLE_SDK_DIR. + exit /b 1 + ) + if exist "!oodle_sdk_path!\win\include\oodle2.h" set "oodle_sdk_path=!oodle_sdk_path!\win" + for %%d in ("!oodle_sdk_path!") do set "oodle_sdk_path=%%~fd" + if not exist "!oodle_sdk_path!\include\oodle2.h" ( + echo Oodle SDK directory "!oodle_sdk_path!" must contain include\oodle2.h + exit /b 1 + ) + echo [Oodle SDK: !oodle_sdk_path!] + set "compile=!compile! -DOODLE_SDK=1 -I"!oodle_sdk_path!\include"" + if exist "!oodle_sdk_path!\redist\oo2core_*_win64.dll" ( + copy /y "!oodle_sdk_path!\redist\oo2core_*_win64.dll" "%~dp0build\" >nul || exit /b 1 + ) +) + :: --- Build Everything (@build_targets) -------------------------------------- pushd build if "%raddbg%"=="1" set didbuild=1 && %compile% ..\src\raddbg\raddbg_main.c %compile_link% %link_icon% %out%raddbg.exe || exit /b 1 diff --git a/build.sh b/build.sh index c481af6e..4f015187 100755 --- a/build.sh +++ b/build.sh @@ -49,8 +49,9 @@ if [[ "${release:-0}" == "1" ]]; then echo "[release mode]"; compile="$compile elif [[ "${debug:-1}" == "1" ]]; then echo "[debug mode]"; compile="$compiler $cc_debug"; fi +oodle_flags=() compile() { - $compile -Wl,--start-group "$@" blake3.a -latomic -Wl,--end-group + $compile "${oodle_flags[@]}" -Wl,--start-group "$@" blake3.a -latomic -Wl,--end-group } # --- Prep Directories -------------------------------------------------------- @@ -77,6 +78,43 @@ then $ar rs build/blake3.a build/blake3_*_unix.o fi +# --- Set up Oodle SDK ------------------------------------------------------- +if [[ "${oodle:-0}" == "1" ]]; then + oodle_sdk_path="${OODLE_SDK_DIR:-}" + if [[ -z "$oodle_sdk_path" ]]; then + for sdk in "$PWD"/local/oodle2*; do + if [[ -f "$sdk/linux/include/oodle2.h" ]]; then + if [[ -n "$oodle_sdk_path" ]]; then + echo "Multiple Oodle SDKs found: $oodle_sdk_path and $sdk/linux" >&2 + echo "Set OODLE_SDK_DIR to select the SDK root." >&2 + exit 1 + fi + oodle_sdk_path="$sdk/linux" + fi + done + fi + if [[ -z "$oodle_sdk_path" ]]; then + echo "Oodle SDK not found. Put an oodle2* SDK with a linux subdirectory in $PWD/local or set OODLE_SDK_DIR." >&2 + exit 1 + fi + if [[ -f "$oodle_sdk_path/linux/include/oodle2.h" ]]; then + oodle_sdk_path="$oodle_sdk_path/linux" + fi + if [[ ! -f "$oodle_sdk_path/include/oodle2.h" ]]; then + echo "Oodle SDK directory '$oodle_sdk_path' must contain include/oodle2.h" >&2 + exit 1 + fi + oodle_sdk_path="$(cd "$oodle_sdk_path" && pwd)" + echo "[Oodle SDK: $oodle_sdk_path]" + # Keep the include path as one argument, including when it contains spaces. + oodle_flags=(-DOODLE_SDK=1 "-I$oodle_sdk_path/include") + for library in "$oodle_sdk_path"/lib/liboo2corelinux64.so "$oodle_sdk_path"/lib/liboo2corelinux64.so.*; do + if [[ -f "$library" ]]; then + cp -- "$library" "$PWD/build/" + fi + done +fi + # --- Build Everything (@build_targets) --------------------------------------- cd build if [[ "${raddbg:-0}" == "1" ]]; then didbuild=1 && compile ../src/raddbg/raddbg_main.c $cc_icon $cc_link $cc_os_gfx $cc_render $cc_font_provider -o raddbg; fi