2019-01-08 11:38:48 -05:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
2020-09-01 14:07:48 -04:00
|
|
|
# This script gets called every time Xcode does a build or clean operation. It is similar to Build.sh
|
|
|
|
|
# (and can take the same arguments) but performs some interpretation of arguments that come from Xcode
|
2019-01-08 11:38:48 -05:00
|
|
|
# Values for $ACTION: "" = building, "clean" = cleaning
|
|
|
|
|
|
2022-08-23 15:40:10 -04:00
|
|
|
if [ ["$UE_SKIP_UBT"] == ["1"] ]; then
|
|
|
|
|
echo Skipping UBT per request
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
|
- Made two modes for modern Xcode projects: OneWorkspacePerPlatform and OneRunTargetPerPlatform. The first makes completely separate .xcworkspaces, projects, and targets for each platform (Mac, IOS, TVOS). The second makes one workspace, and one project for each platform, but the platform will have three run targets (but one build and one index target) - useful for single game workspaces. There are a couple nasty things, like the Project has the Editor configs, but the IOS target doesn't want them, but they show up anyway in dropdowns because of the Project config.
- If there are no modern projects, then the mode is ignored, and it's the same old mode. With a mix of modern and legacy, each platform workspace will point to the same legacy projects (not worth retooling Legacy since it's becoming deprecated)
- Added Launch Storyboard support (it will look for uncompiled, compiled, project, and engine fallback locations). Compiled is useful or old storyboards, and for Windows-based (assuming that will work with Modern)
- Other minor things like metadata discovery, etc
#preflight 639a321843330e63e50a21e9
[CL 23517631 by Josh Adams in ue5-main branch]
2022-12-14 15:44:34 -05:00
|
|
|
echo Running Xcodebuild $@
|
|
|
|
|
|
2020-11-03 08:46:05 -04:00
|
|
|
# Setup Environment
|
2020-12-02 06:57:13 -04:00
|
|
|
source Engine/Build/BatchFiles/Mac/SetupEnvironment.sh -dotnet Engine/Build/BatchFiles/Mac
|
2020-11-03 08:46:05 -04:00
|
|
|
|
2020-09-01 14:07:48 -04:00
|
|
|
#echo "Raw Args: $*"
|
|
|
|
|
|
- Made two modes for modern Xcode projects: OneWorkspacePerPlatform and OneRunTargetPerPlatform. The first makes completely separate .xcworkspaces, projects, and targets for each platform (Mac, IOS, TVOS). The second makes one workspace, and one project for each platform, but the platform will have three run targets (but one build and one index target) - useful for single game workspaces. There are a couple nasty things, like the Project has the Editor configs, but the IOS target doesn't want them, but they show up anyway in dropdowns because of the Project config.
- If there are no modern projects, then the mode is ignored, and it's the same old mode. With a mix of modern and legacy, each platform workspace will point to the same legacy projects (not worth retooling Legacy since it's becoming deprecated)
- Added Launch Storyboard support (it will look for uncompiled, compiled, project, and engine fallback locations). Compiled is useful or old storyboards, and for Windows-based (assuming that will work with Modern)
- Other minor things like metadata discovery, etc
#preflight 639a321843330e63e50a21e9
[CL 23517631 by Josh Adams in ue5-main branch]
2022-12-14 15:44:34 -05:00
|
|
|
BUILD_UBT=1
|
|
|
|
|
|
2020-09-01 14:07:48 -04:00
|
|
|
case $1 in
|
|
|
|
|
"clean")
|
|
|
|
|
ACTION="clean"
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
"install")
|
|
|
|
|
ACTION="install"
|
|
|
|
|
;;
|
- Made two modes for modern Xcode projects: OneWorkspacePerPlatform and OneRunTargetPerPlatform. The first makes completely separate .xcworkspaces, projects, and targets for each platform (Mac, IOS, TVOS). The second makes one workspace, and one project for each platform, but the platform will have three run targets (but one build and one index target) - useful for single game workspaces. There are a couple nasty things, like the Project has the Editor configs, but the IOS target doesn't want them, but they show up anyway in dropdowns because of the Project config.
- If there are no modern projects, then the mode is ignored, and it's the same old mode. With a mix of modern and legacy, each platform workspace will point to the same legacy projects (not worth retooling Legacy since it's becoming deprecated)
- Added Launch Storyboard support (it will look for uncompiled, compiled, project, and engine fallback locations). Compiled is useful or old storyboards, and for Windows-based (assuming that will work with Modern)
- Other minor things like metadata discovery, etc
#preflight 639a321843330e63e50a21e9
[CL 23517631 by Josh Adams in ue5-main branch]
2022-12-14 15:44:34 -05:00
|
|
|
|
|
|
|
|
"-nobuildubt")
|
|
|
|
|
BUILD_UBT=0
|
|
|
|
|
;;
|
2020-09-01 14:07:48 -04:00
|
|
|
esac
|
|
|
|
|
|
- Made two modes for modern Xcode projects: OneWorkspacePerPlatform and OneRunTargetPerPlatform. The first makes completely separate .xcworkspaces, projects, and targets for each platform (Mac, IOS, TVOS). The second makes one workspace, and one project for each platform, but the platform will have three run targets (but one build and one index target) - useful for single game workspaces. There are a couple nasty things, like the Project has the Editor configs, but the IOS target doesn't want them, but they show up anyway in dropdowns because of the Project config.
- If there are no modern projects, then the mode is ignored, and it's the same old mode. With a mix of modern and legacy, each platform workspace will point to the same legacy projects (not worth retooling Legacy since it's becoming deprecated)
- Added Launch Storyboard support (it will look for uncompiled, compiled, project, and engine fallback locations). Compiled is useful or old storyboards, and for Windows-based (assuming that will work with Modern)
- Other minor things like metadata discovery, etc
#preflight 639a321843330e63e50a21e9
[CL 23517631 by Josh Adams in ue5-main branch]
2022-12-14 15:44:34 -05:00
|
|
|
|
|
|
|
|
# If this is a source drop of the engine make sure that the UnrealBuildTool is up-to-date
|
|
|
|
|
if [ $BUILD_UBT == 1 ]; then
|
|
|
|
|
# remove environment variable passed from xcode which also has meaning to dotnet, breaking the build
|
|
|
|
|
unset TARGETNAME
|
|
|
|
|
|
|
|
|
|
if [ ! -f Engine/Build/InstalledBuild.txt ]; then
|
|
|
|
|
dotnet build Engine/Source/Programs/UnrealBuildTool/UnrealBuildTool.csproj -c Development -v quiet
|
|
|
|
|
|
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
|
echo "Failed to build the build tool (UnrealBuildTool)"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-09-01 14:07:48 -04:00
|
|
|
if [ ["$ACTION"] == [""] ]; then
|
|
|
|
|
ACTION="build"
|
|
|
|
|
TARGET=$1
|
|
|
|
|
PLATFORM=$2
|
|
|
|
|
CONFIGURATION=$3
|
|
|
|
|
TRAILINGARGS=${@:4}
|
|
|
|
|
else
|
|
|
|
|
# non build actions are all shifted by one
|
|
|
|
|
TARGET=$2
|
|
|
|
|
PLATFORM=$3
|
|
|
|
|
CONFIGURATION=$4
|
|
|
|
|
TRAILINGARGS=${@:5}
|
2019-10-29 15:07:15 -04:00
|
|
|
fi
|
2019-01-08 11:38:48 -05:00
|
|
|
|
2023-06-24 17:52:48 -04:00
|
|
|
if [[ $ARCHS ]]; then
|
|
|
|
|
# convert the space in xcode's multiple architecture (arm64 x86_64) argument into the standard + that UBT expects (arm64+x86_64)
|
|
|
|
|
UBT_ARCHFLAG="-architecture=${ARCHS/ /+}"
|
|
|
|
|
else
|
|
|
|
|
UBT_ARCHFLAG=""
|
|
|
|
|
fi
|
|
|
|
|
|
2020-09-01 14:07:48 -04:00
|
|
|
# Convert platform to UBT terms
|
|
|
|
|
case $PLATFORM in
|
2023-07-26 01:01:43 -04:00
|
|
|
"iphoneos"|"IOS")
|
2020-09-01 14:07:48 -04:00
|
|
|
PLATFORM="IOS"
|
|
|
|
|
;;
|
2023-07-26 01:01:43 -04:00
|
|
|
"iphonesimulator"|"iossimulator")
|
|
|
|
|
PLATFORM="IOS"
|
2023-07-26 17:45:21 -04:00
|
|
|
UBT_ARCHFLAG="-architecture=iossimulator"
|
2023-07-26 01:01:43 -04:00
|
|
|
;;
|
2020-09-01 14:07:48 -04:00
|
|
|
"appletvos")
|
|
|
|
|
PLATFORM="TVOS"
|
|
|
|
|
;;
|
2023-06-24 17:52:48 -04:00
|
|
|
"xros"|"xrsimulator")
|
|
|
|
|
PLATFORM="VisionOS"
|
|
|
|
|
UBT_ARCHFLAG="-architecture=iossimulator"
|
|
|
|
|
;;
|
2020-09-01 14:07:48 -04:00
|
|
|
"macosx")
|
|
|
|
|
PLATFORM="Mac"
|
|
|
|
|
;;
|
2019-01-08 11:38:48 -05:00
|
|
|
esac
|
|
|
|
|
|
2021-01-08 19:56:07 -04:00
|
|
|
echo "Processing $ACTION for Target=$TARGET Platform=$PLATFORM Configuration=$CONFIGURATION $UBT_ARCHFLAG $TRAILINGARGS "
|
2020-09-01 14:07:48 -04:00
|
|
|
|
|
|
|
|
# Add additional flags based on actions, arguments, and env properties
|
|
|
|
|
AdditionalFlags=""
|
|
|
|
|
|
|
|
|
|
if [ "$ACTION" == "build" ]; then
|
|
|
|
|
|
|
|
|
|
# flags based on platform
|
|
|
|
|
case $PLATFORM in
|
|
|
|
|
"IOS")
|
2020-09-24 00:43:27 -04:00
|
|
|
AdditionalFlags="${AdditionalFlags} -deploy"
|
2020-09-01 14:07:48 -04:00
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
"TVOS")
|
2020-09-24 00:43:27 -04:00
|
|
|
AdditionalFlags="${AdditionalFlags} -deploy"
|
2020-09-01 14:07:48 -04:00
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
case $CLANG_STATIC_ANALYZER_MODE in
|
|
|
|
|
"deep")
|
2020-09-24 00:43:27 -04:00
|
|
|
AdditionalFlags="${AdditionalFlags} -SkipActionHistory"
|
2020-09-01 14:07:48 -04:00
|
|
|
;;
|
|
|
|
|
"shallow")
|
2020-09-24 00:43:27 -04:00
|
|
|
AdditionalFlags="${AdditionalFlags} -SkipActionHistory"
|
2020-09-01 14:07:48 -04:00
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
case $ENABLE_THREAD_SANITIZER in
|
|
|
|
|
"YES"|"1")
|
|
|
|
|
# Disable TSAN atomic->non-atomic race reporting as we aren't C++11 memory-model conformant so UHT will fail
|
|
|
|
|
export TSAN_OPTIONS="suppress_equal_stacks=true suppress_equal_addresses=true report_atomic_races=false"
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
# Build SCW if this is an editor target
|
|
|
|
|
if [[ "$TARGET" == *"Editor" ]]; then
|
2022-10-06 19:44:31 -04:00
|
|
|
dotnet Engine/Binaries/DotNET/UnrealBuildTool/UnrealBuildTool.dll ShaderCompileWorker Mac Development $UBT_ARCHFLAG
|
2020-09-01 14:07:48 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
elif [ $ACTION == "clean" ]; then
|
|
|
|
|
AdditionalFlags="-clean"
|
- Made two modes for modern Xcode projects: OneWorkspacePerPlatform and OneRunTargetPerPlatform. The first makes completely separate .xcworkspaces, projects, and targets for each platform (Mac, IOS, TVOS). The second makes one workspace, and one project for each platform, but the platform will have three run targets (but one build and one index target) - useful for single game workspaces. There are a couple nasty things, like the Project has the Editor configs, but the IOS target doesn't want them, but they show up anyway in dropdowns because of the Project config.
- If there are no modern projects, then the mode is ignored, and it's the same old mode. With a mix of modern and legacy, each platform workspace will point to the same legacy projects (not worth retooling Legacy since it's becoming deprecated)
- Added Launch Storyboard support (it will look for uncompiled, compiled, project, and engine fallback locations). Compiled is useful or old storyboards, and for Windows-based (assuming that will work with Modern)
- Other minor things like metadata discovery, etc
#preflight 639a321843330e63e50a21e9
[CL 23517631 by Josh Adams in ue5-main branch]
2022-12-14 15:44:34 -05:00
|
|
|
|
|
|
|
|
elif [ $ACTION == "metadata" ]; then
|
|
|
|
|
AdditionalFlags="-mode=ExportXcodeMetadata"
|
2020-09-01 14:07:48 -04:00
|
|
|
fi
|
|
|
|
|
|
2021-03-19 16:26:44 -04:00
|
|
|
echo Running dotnet Engine/Binaries/DotNET/UnrealBuildTool/UnrealBuildTool.dll $TARGET $PLATFORM $CONFIGURATION "$TRAILINGARGS" $UBT_ARCHFLAG $AdditionalFlags
|
2022-08-23 15:40:10 -04:00
|
|
|
# set an envvar to let UBT know that it's being run from xcode (envvar allows children to get the setting if needed)
|
|
|
|
|
UE_BUILD_FROM_XCODE=1 dotnet Engine/Binaries/DotNET/UnrealBuildTool/UnrealBuildTool.dll $TARGET $PLATFORM $CONFIGURATION "$TRAILINGARGS" $UBT_ARCHFLAG $AdditionalFlags
|
2020-09-01 14:07:48 -04:00
|
|
|
|
2019-01-08 11:38:48 -05:00
|
|
|
ExitCode=$?
|
|
|
|
|
if [ $ExitCode -eq 254 ] || [ $ExitCode -eq 255 ] || [ $ExitCode -eq 2 ]; then
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
2019-10-29 15:07:15 -04:00
|
|
|
exit $ExitCode
|