feat(physics): wire physx sdk into build
This commit is contained in:
113
engine/third_party/physx/buildtools/steps/build_linux.sh
vendored
Normal file
113
engine/third_party/physx/buildtools/steps/build_linux.sh
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
#!/bin/bash +x
|
||||
|
||||
set -e
|
||||
|
||||
# Function to display an error and exit
|
||||
error_exit() {
|
||||
echo "$1" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Check if two arguments are passed
|
||||
if [ "$#" -ne 2 ]; then
|
||||
error_exit "Usage: $0 <preset> <build_config>. Example: $0 linux-aarch64-gcc debug"
|
||||
fi
|
||||
|
||||
# Assign arguments
|
||||
PRESET="$1"
|
||||
BUILD_CONFIG="$2"
|
||||
|
||||
# Validate build configuration
|
||||
if [[ ! "checked debug profile release all" =~ (^|[[:space:]])$BUILD_CONFIG($|[[:space:]]) ]]; then
|
||||
error_exit "Invalid build configuration. Use one of: checked, debug, profile, release, all."
|
||||
fi
|
||||
|
||||
# Get number of CPU cores
|
||||
if [ -f /proc/cpuinfo ]; then
|
||||
CPUS=$(grep processor /proc/cpuinfo | wc -l)
|
||||
else
|
||||
CPUS=1
|
||||
fi
|
||||
|
||||
# Stackoverflow suggests jobs count of (CPU cores + 1) as a good number!
|
||||
JOBS=$(expr $CPUS + 1)
|
||||
|
||||
# Define build function for presets other than linux-carbonite and linux-aarch64-carbonite (no install)
|
||||
build() {
|
||||
CONFIG=$1
|
||||
BUILD_DIR="$(dirname "$0")/../../compiler/$PRESET-$CONFIG"
|
||||
pushd "$BUILD_DIR" || error_exit "Directory not found for build: $BUILD_DIR"
|
||||
make -j$JOBS || error_exit "Build failed for $PRESET-$CONFIG"
|
||||
popd
|
||||
}
|
||||
|
||||
# Function to handle file copying for linux-aarch64-carbonite and linux-carbonite debug builds
|
||||
copy_vhacd_files() {
|
||||
CONFIG=$1
|
||||
if [[ "$CONFIG" == "debug" ]]; then
|
||||
if [[ "$PRESET" == "linux-aarch64-carbonite" ]]; then
|
||||
TARGET_PATH="install/$PRESET/VHACD/bin/linux.aarch64/debug/"
|
||||
SRC_PATH="bin/linux.aarch64/debug/"
|
||||
elif [[ "$PRESET" == "linux-carbonite" ]]; then
|
||||
TARGET_PATH="install/$PRESET/VHACD/bin/linux.x86_64/debug/"
|
||||
SRC_PATH="bin/linux.x86_64/debug/"
|
||||
fi
|
||||
mkdir -p "$TARGET_PATH" || error_exit "Failed to create directory $TARGET_PATH"
|
||||
|
||||
# Check if VHACD files exist before attempting to copy
|
||||
if ls "$SRC_PATH"*VHACD* 1> /dev/null 2>&1; then
|
||||
cp "$SRC_PATH"*VHACD* "$TARGET_PATH" || error_exit "Failed to copy VHACD files"
|
||||
else
|
||||
echo "Warning: No VHACD files found in $SRC_PATH. Skipping copy operation."
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Define build function for linux-aarch64-carbonite and linux-carbonite (with install)
|
||||
build_with_install() {
|
||||
CONFIG=$1
|
||||
BUILD_DIR="$(dirname "$0")/../../compiler/$PRESET-$CONFIG"
|
||||
pushd "$BUILD_DIR" || error_exit "Directory not found for build: $BUILD_DIR"
|
||||
make -j$JOBS install || error_exit "Build and install failed for $PRESET-$CONFIG"
|
||||
popd
|
||||
|
||||
copy_vhacd_files $CONFIG
|
||||
}
|
||||
|
||||
# Build process based on the preset and configuration
|
||||
if [[ "$PRESET" == "linux-aarch64-carbonite" || "$PRESET" == "linux-carbonite" ]]; then
|
||||
# Build with install for linux-aarch64-carbonite and linux-carbonite
|
||||
if [ "$BUILD_CONFIG" = "all" ]; then
|
||||
build_with_install debug
|
||||
build_with_install checked
|
||||
build_with_install profile
|
||||
build_with_install release
|
||||
else
|
||||
build_with_install $BUILD_CONFIG
|
||||
fi
|
||||
|
||||
# Additional installations not specific to any build
|
||||
INSTALL_PATH="install/$PRESET"
|
||||
|
||||
pushd "$(dirname "$0")/../.." || error_exit "Failed to enter base directory"
|
||||
mkdir -p "$INSTALL_PATH/PhysX/PACKAGE-LICENSES/" "$INSTALL_PATH/VHACD/" "$INSTALL_PATH/VHACD/include/" "$INSTALL_PATH/VHACD/PACKAGE-LICENSES/" || error_exit "Failed to create installation directories"
|
||||
|
||||
cp "documentation/license/PACKAGE-LICENSES/LICENSE.md" "$INSTALL_PATH/PhysX/PACKAGE-LICENSES/physxsdk-LICENSE.md" || error_exit "Failed to copy PhysX license"
|
||||
cp "documentation/license/PACKAGE-LICENSES/vhacd-LICENSE.md" "$INSTALL_PATH/VHACD/PACKAGE-LICENSES/vhacd-LICENSE.md" || error_exit "Failed to copy VHACD license"
|
||||
|
||||
cp "documentation/license/physxsdk-PACKAGE-INFO.yaml" "$INSTALL_PATH/PhysX/PACKAGE-INFO.yaml" || error_exit "Failed to copy PhysX package info"
|
||||
cp "documentation/license/vhacd-PACKAGE-INFO.yaml" "$INSTALL_PATH/VHACD/PACKAGE-INFO.yaml" || error_exit "Failed to copy VHACD package info"
|
||||
|
||||
cp "externals/VHACD/public/"* "$INSTALL_PATH/VHACD/include/" || error_exit "Failed to copy VHACD include files"
|
||||
popd
|
||||
else
|
||||
# Build without install for other presets
|
||||
if [ "$BUILD_CONFIG" = "all" ]; then
|
||||
build checked
|
||||
build debug
|
||||
build profile
|
||||
build release
|
||||
else
|
||||
build $BUILD_CONFIG
|
||||
fi
|
||||
fi
|
||||
189
engine/third_party/physx/buildtools/steps/build_win_x86_64.bat
vendored
Normal file
189
engine/third_party/physx/buildtools/steps/build_win_x86_64.bat
vendored
Normal file
@@ -0,0 +1,189 @@
|
||||
@echo off
|
||||
SETLOCAL EnableDelayedExpansion
|
||||
|
||||
:: Check if at least one argument is provided (preset)
|
||||
if "%~1"=="" (
|
||||
echo You must specify a preset: e.g. vc17win64...
|
||||
exit /B 1
|
||||
)
|
||||
|
||||
:: Set the preset based on the argument
|
||||
set "PRESET=%1"
|
||||
|
||||
:: Extract the Visual Studio version from the preset
|
||||
set "VS_PREFIX=%PRESET:~0,4%" :: Get the first 4 characters (vc15, vc16, vc17)
|
||||
|
||||
:: Determine the correct Visual Studio version based on the preset prefix
|
||||
if "%VS_PREFIX%" == "vc15" (
|
||||
set "VS_VERSION=[15.0,16.0)"
|
||||
) else if "%VS_PREFIX%" == "vc16" (
|
||||
set "VS_VERSION=[16.0,17.0)"
|
||||
) else if "%VS_PREFIX%" == "vc17" (
|
||||
set "VS_VERSION=[17.0,18.0)"
|
||||
) else (
|
||||
echo Unsupported Visual Studio version in preset: %PRESET%
|
||||
exit /B 1
|
||||
)
|
||||
|
||||
:: Check if a build configuration is provided, default to 'all' if not
|
||||
if "%~2" == "" (
|
||||
set "BUILD_CONFIG=all"
|
||||
) else (
|
||||
set "BUILD_CONFIG=%2"
|
||||
)
|
||||
|
||||
:: Validate BUILD_CONFIG
|
||||
if not "%BUILD_CONFIG%"=="debug" if not "%BUILD_CONFIG%"=="release" if not "%BUILD_CONFIG%"=="checked" if not "%BUILD_CONFIG%"=="profile" if not "%BUILD_CONFIG%"=="all" (
|
||||
echo Invalid build configuration. Use one of: debug, release, checked, profile, all.
|
||||
exit /B 1
|
||||
)
|
||||
|
||||
:: Locate Visual Studio using vswhere
|
||||
IF EXIST "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer" (
|
||||
set "VS_INSTALLER_DIR=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer"
|
||||
echo VS_INSTALLER_DIR: "!VS_INSTALLER_DIR!"
|
||||
|
||||
:: Check if VS_INSTALLER_DIR is already in PATH
|
||||
echo !PATH! | findstr /i /c:"!VS_INSTALLER_DIR!" >nul
|
||||
if errorlevel 1 (
|
||||
set "PATH=!PATH!;!VS_INSTALLER_DIR!"
|
||||
echo Updated PATH: !PATH!
|
||||
) else (
|
||||
echo VS_INSTALLER_DIR is already in PATH
|
||||
)
|
||||
)
|
||||
|
||||
:: Use vswhere to locate the specified Visual Studio installation
|
||||
for /f "usebackq tokens=*" %%i in (`vswhere -version "%VS_VERSION%" -latest -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do (
|
||||
set "VSINSTALLPATH=%%i"
|
||||
echo VSINSTALLPATH: "!VSINSTALLPATH!"
|
||||
)
|
||||
|
||||
:: Check if VSINSTALLPATH is set
|
||||
if not defined VSINSTALLPATH (
|
||||
echo Visual Studio installation not found.
|
||||
exit /B 1
|
||||
)
|
||||
|
||||
:: Set COMNTOOLS to point to the correct path
|
||||
set "COMNTOOLS=!VSINSTALLPATH!\VC\Auxiliary\Build\vcvarsx86_amd64.bat"
|
||||
echo COMNTOOLS: "!COMNTOOLS!"
|
||||
call "!COMNTOOLS!"
|
||||
if errorlevel 1 (
|
||||
echo Failed to initialize Visual Studio environment.
|
||||
exit /B 1
|
||||
)
|
||||
|
||||
:: Safely handle directory changes
|
||||
pushd "%~dp0\..\..\compiler"
|
||||
set "ROOT_PATH=%CD%"
|
||||
popd
|
||||
|
||||
:: Build configurations
|
||||
if "%BUILD_CONFIG%" == "all" (
|
||||
call :BUILD debug
|
||||
if errorlevel 1 goto ERROR
|
||||
|
||||
call :BUILD release
|
||||
if errorlevel 1 goto ERROR
|
||||
|
||||
call :BUILD checked
|
||||
if errorlevel 1 goto ERROR
|
||||
|
||||
call :BUILD profile
|
||||
if errorlevel 1 goto ERROR
|
||||
) else (
|
||||
call :BUILD %BUILD_CONFIG%
|
||||
if errorlevel 1 goto ERROR
|
||||
)
|
||||
|
||||
:: Success
|
||||
echo Build completed successfully.
|
||||
exit /B 0
|
||||
|
||||
:ERROR
|
||||
echo Failure while building *Windows %VS_PREFIX%* targets!
|
||||
exit /B 1
|
||||
|
||||
:: Build subroutine
|
||||
:BUILD
|
||||
echo ** Building %PRESET% %1 ... **
|
||||
|
||||
:: Check if PRESET ends with -carbonite using string manipulation
|
||||
setlocal enabledelayedexpansion
|
||||
set "SUFFIX=-carbonite"
|
||||
set "PRESET_LENGTH=!PRESET:~-10!"
|
||||
|
||||
if "%PRESET_LENGTH%" == "%SUFFIX%" (
|
||||
:: Build INSTALL.vcxproj when the preset ends with -carbonite
|
||||
msbuild /property:configuration=%1 "%ROOT_PATH%\%PRESET%\INSTALL.vcxproj" /maxcpucount /t:Rebuild /v:m
|
||||
) else (
|
||||
:: Build PhysXSDK.sln when the preset does not end with -carbonite
|
||||
msbuild /property:configuration=%1 "%ROOT_PATH%\%PRESET%\PhysXSDK.sln" /maxcpucount /t:Rebuild /v:m
|
||||
)
|
||||
|
||||
if errorlevel 1 (
|
||||
echo Build failed for %1.
|
||||
exit /B 1
|
||||
)
|
||||
echo ** End of %PRESET% %1 **
|
||||
echo.
|
||||
goto :EOF
|
||||
|
||||
|
||||
|
||||
@REM This is for binary distro only (carbonite). Keeping it here in case we need it.
|
||||
@REM However if we need the licenses and the logic below, it will be probably better to do that in the zipup script not here
|
||||
|
||||
|
||||
:: Copying licenses and files directly, similar to individual scripts
|
||||
:: Ensure that destination directories exist by creating them before copying
|
||||
|
||||
@REM echo Copying LICENSE.md to PhysX...
|
||||
@REM mkdir "%ROOT_PATH%\..\install\%INSTALL_PATH%\PhysX\PACKAGE-LICENSES" 2>nul
|
||||
@REM echo f | xcopy /S /Y /I "%ROOT_PATH%\..\documentation\license\PACKAGE-LICENSES\LICENSE.md" "%ROOT_PATH%\..\install\%INSTALL_PATH%\PhysX\PACKAGE-LICENSES\physxsdk-LICENSE.md"
|
||||
@REM if errorlevel 1 (
|
||||
@REM echo Failed to copy LICENSE.md to PhysX.
|
||||
@REM goto ERROR
|
||||
@REM )
|
||||
|
||||
@REM echo Copying vhacd-LICENSE.md to VHACD...
|
||||
@REM mkdir "%ROOT_PATH%\..\install\%INSTALL_PATH%\VHACD\PACKAGE-LICENSES" 2>nul
|
||||
@REM echo f | xcopy /S /Y /I "%ROOT_PATH%\..\documentation\license\PACKAGE-LICENSES\vhacd-LICENSE.md" "%ROOT_PATH%\..\install\%INSTALL_PATH%\VHACD\PACKAGE-LICENSES\vhacd-LICENSE.md"
|
||||
@REM if errorlevel 1 (
|
||||
@REM echo Failed to copy vhacd-LICENSE.md to VHACD.
|
||||
@REM goto ERROR
|
||||
@REM )
|
||||
|
||||
@REM echo Copying physxsdk-PACKAGE-INFO.yaml to PhysX...
|
||||
@REM mkdir "%ROOT_PATH%\..\install\%INSTALL_PATH%\PhysX" 2>nul
|
||||
@REM echo f | xcopy /S /Y /I "%ROOT_PATH%\..\documentation\license\physxsdk-PACKAGE-INFO.yaml" "%ROOT_PATH%\..\install\%INSTALL_PATH%\PhysX\PACKAGE-INFO.yaml"
|
||||
@REM if errorlevel 1 (
|
||||
@REM echo Failed to copy physxsdk-PACKAGE-INFO.yaml to PhysX.
|
||||
@REM goto ERROR
|
||||
@REM )
|
||||
|
||||
@REM echo Copying vhacd-PACKAGE-INFO.yaml to VHACD...
|
||||
@REM mkdir "%ROOT_PATH%\..\install\%INSTALL_PATH%\VHACD" 2>nul
|
||||
@REM echo f | xcopy /S /Y /I "%ROOT_PATH%\..\documentation\license\vhacd-PACKAGE-INFO.yaml" "%ROOT_PATH%\..\install\%INSTALL_PATH%\VHACD\PACKAGE-INFO.yaml"
|
||||
@REM if errorlevel 1 (
|
||||
@REM echo Failed to copy vhacd-PACKAGE-INFO.yaml to VHACD.
|
||||
@REM goto ERROR
|
||||
@REM )
|
||||
|
||||
@REM :: Copying VHACD binaries and includes
|
||||
@REM echo Copying VHACD debug binaries...
|
||||
@REM mkdir "%ROOT_PATH%\..\install\%INSTALL_PATH%\VHACD\bin\%BINARY_PATH%\debug" 2>nul
|
||||
@REM xcopy /Y "%ROOT_PATH%\..\bin\%BINARY_PATH%\debug\VHACD*.*" "%ROOT_PATH%\..\install\%INSTALL_PATH%\VHACD\bin\%BINARY_PATH%\debug\"
|
||||
@REM if errorlevel 1 (
|
||||
@REM echo Failed to copy VHACD debug binaries.
|
||||
@REM goto ERROR
|
||||
@REM )
|
||||
|
||||
@REM echo Copying VHACD includes...
|
||||
@REM mkdir "%ROOT_PATH%\..\install\%INSTALL_PATH%\VHACD\include" 2>nul
|
||||
@REM xcopy /Y "%ROOT_PATH%\..\externals\VHACD\public\*.*" "%ROOT_PATH%\..\install\%INSTALL_PATH%\VHACD\include\"
|
||||
@REM if errorlevel 1 (
|
||||
@REM echo Failed to copy VHACD includes.
|
||||
@REM goto ERROR
|
||||
@REM )
|
||||
Reference in New Issue
Block a user