Merge ff72fecedd into 0c82a58873
commit
04ce8f6740
|
|
@ -43,6 +43,10 @@ inputs:
|
|||
required: false
|
||||
default: ''
|
||||
description: 'Launches unity without specifying `-nographics`.'
|
||||
enableParallelLinking:
|
||||
required: false
|
||||
default: 'true'
|
||||
description: 'Enable parallel linking for IL2CPP builds to speed up linking phase.'
|
||||
customParameters:
|
||||
required: false
|
||||
default: ''
|
||||
|
|
|
|||
|
|
@ -116,6 +116,12 @@ namespace UnityBuilderAction
|
|||
AndroidSettings.Apply(options);
|
||||
}
|
||||
|
||||
// Enable parallel linking for IL2CPP builds
|
||||
if (options.TryGetValue("enableParallelLinking", out var enableParallelLinking) &&
|
||||
enableParallelLinking != "false") {
|
||||
SetParallelLinking(buildTarget);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Perform build
|
||||
|
|
@ -129,5 +135,47 @@ namespace UnityBuilderAction
|
|||
BuildResult result = summary.result;
|
||||
StdOutReporter.ExitWithResult(result);
|
||||
}
|
||||
|
||||
private static void SetParallelLinking(BuildTarget buildTarget) {
|
||||
string additionalArgs = PlayerSettings.additionalIl2CppArgs;
|
||||
|
||||
// Determine number of parallel jobs (use CPU count, or default to 4)
|
||||
int numJobs = System.Environment.ProcessorCount;
|
||||
if (numJobs <= 0) numJobs = 2;
|
||||
|
||||
// Platform-specific parallel linking flags
|
||||
switch (buildTarget) {
|
||||
case BuildTarget.StandaloneWindows:
|
||||
case BuildTarget.StandaloneWindows64:
|
||||
string cgthreadsFlag = $"--linker-flags=/CGTHREADS:{numJobs}";
|
||||
if (!additionalArgs.Contains("/CGTHREADS:")) {
|
||||
additionalArgs = string.IsNullOrEmpty(additionalArgs)
|
||||
? cgthreadsFlag
|
||||
: $"{additionalArgs} {cgthreadsFlag}";
|
||||
}
|
||||
break;
|
||||
|
||||
case BuildTarget.StandaloneLinux64:
|
||||
case BuildTarget.Android:
|
||||
case BuildTarget.iOS:
|
||||
if (!additionalArgs.Contains("--threads")) {
|
||||
additionalArgs = string.IsNullOrEmpty(additionalArgs)
|
||||
? $"-Wl,--threads={numJobs}"
|
||||
: $"{additionalArgs} -Wl,--threads={numJobs}";
|
||||
}
|
||||
break;
|
||||
|
||||
case BuildTarget.StandaloneOSX:
|
||||
if (!additionalArgs.Contains("thread_count")) {
|
||||
additionalArgs = string.IsNullOrEmpty(additionalArgs)
|
||||
? $"-Wl,-thread_count,{numJobs}"
|
||||
: $"{additionalArgs} -Wl,-thread_count,{numJobs}";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
PlayerSettings.additionalIl2CppArgs = additionalArgs;
|
||||
Debug.Log($"IL2CPP parallel linking enabled with {numJobs} jobs. Additional args: {additionalArgs}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -305,6 +305,7 @@ class BuildParameters {
|
|||
buildVersion,
|
||||
manualExit: input_1.default.manualExit,
|
||||
enableGpu: input_1.default.enableGpu,
|
||||
enableParallelLinking: input_1.default.enableParallelLinking,
|
||||
androidVersionCode,
|
||||
androidKeystoreName: input_1.default.androidKeystoreName,
|
||||
androidKeystoreBase64: input_1.default.androidKeystoreBase64,
|
||||
|
|
@ -6452,6 +6453,7 @@ class ImageEnvironmentFactory {
|
|||
{ name: 'BUILD_METHOD', value: parameters.buildMethod },
|
||||
{ name: 'MANUAL_EXIT', value: parameters.manualExit },
|
||||
{ name: 'ENABLE_GPU', value: parameters.enableGpu },
|
||||
{ name: 'ENABLE_PARALLEL_LINKING', value: parameters.enableParallelLinking },
|
||||
{ name: 'VERSION', value: parameters.buildVersion },
|
||||
{ name: 'ANDROID_VERSION_CODE', value: parameters.androidVersionCode },
|
||||
{ name: 'ANDROID_KEYSTORE_NAME', value: parameters.androidKeystoreName },
|
||||
|
|
@ -7019,6 +7021,10 @@ class Input {
|
|||
const input = Input.getInput('enableGpu') ?? false;
|
||||
return input === 'true';
|
||||
}
|
||||
static get enableParallelLinking() {
|
||||
const input = Input.getInput('enableParallelLinking') ?? true;
|
||||
return input === 'true';
|
||||
}
|
||||
static get customParameters() {
|
||||
return Input.getInput('customParameters') ?? '';
|
||||
}
|
||||
|
|
@ -7495,6 +7501,7 @@ class SetupMac {
|
|||
process.env.CHOWN_FILES_TO = buildParameters.chownFilesTo;
|
||||
process.env.MANUAL_EXIT = buildParameters.manualExit.toString();
|
||||
process.env.ENABLE_GPU = buildParameters.enableGpu.toString();
|
||||
process.env.ENABLE_PARALLEL_LINKING = buildParameters.enableParallelLinking.toString();
|
||||
}
|
||||
}
|
||||
SetupMac.unityHubBasePath = `/Applications/"Unity Hub.app"`;
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -166,6 +166,7 @@ echo ""
|
|||
-androidTargetSdkVersion "$ANDROID_TARGET_SDK_VERSION" \
|
||||
-androidExportType "$ANDROID_EXPORT_TYPE" \
|
||||
-androidSymbolType "$ANDROID_SYMBOL_TYPE" \
|
||||
$( [ "${ENABLE_PARALLEL_LINKING}" == "true" ] && echo "-enableParallelLinking" ) \
|
||||
$CUSTOM_PARAMETERS
|
||||
|
||||
# Catch exit code
|
||||
|
|
|
|||
|
|
@ -140,6 +140,7 @@ unity-editor \
|
|||
-androidTargetSdkVersion "$ANDROID_TARGET_SDK_VERSION" \
|
||||
-androidExportType "$ANDROID_EXPORT_TYPE" \
|
||||
-androidSymbolType "$ANDROID_SYMBOL_TYPE" \
|
||||
$( [ "${ENABLE_PARALLEL_LINKING}" == "true" ] && echo "-enableParallelLinking" ) \
|
||||
$CUSTOM_PARAMETERS
|
||||
|
||||
# Catch exit code
|
||||
|
|
|
|||
|
|
@ -178,7 +178,11 @@ $unityArgs = @(
|
|||
"-androidExportType", "`"$Env:ANDROID_EXPORT_TYPE`"",
|
||||
"-androidSymbolType", "`"$Env:ANDROID_SYMBOL_TYPE`"",
|
||||
"-logfile", "-"
|
||||
) + $customParametersArray
|
||||
)
|
||||
if ($Env:ENABLE_PARALLEL_LINKING -eq "true") {
|
||||
$unityArgs += @("-enableParallelLinking")
|
||||
}
|
||||
$unityArgs = $unityArgs + $customParametersArray
|
||||
|
||||
if (-not $Env:BUILD_PROFILE) {
|
||||
$unityArgs += @("-buildTarget", "`"$Env:BUILD_TARGET`"")
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ class BuildParameters {
|
|||
public buildVersion!: string;
|
||||
public manualExit!: boolean;
|
||||
public enableGpu!: boolean;
|
||||
public enableParallelLinking!: boolean;
|
||||
public androidVersionCode!: string;
|
||||
public androidKeystoreName!: string;
|
||||
public androidKeystoreBase64!: string;
|
||||
|
|
@ -162,6 +163,7 @@ class BuildParameters {
|
|||
buildVersion,
|
||||
manualExit: Input.manualExit,
|
||||
enableGpu: Input.enableGpu,
|
||||
enableParallelLinking: Input.enableParallelLinking,
|
||||
androidVersionCode,
|
||||
androidKeystoreName: Input.androidKeystoreName,
|
||||
androidKeystoreBase64: Input.androidKeystoreBase64,
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ class ImageEnvironmentFactory {
|
|||
{ name: 'BUILD_METHOD', value: parameters.buildMethod },
|
||||
{ name: 'MANUAL_EXIT', value: parameters.manualExit },
|
||||
{ name: 'ENABLE_GPU', value: parameters.enableGpu },
|
||||
{ name: 'ENABLE_PARALLEL_LINKING', value: parameters.enableParallelLinking },
|
||||
{ name: 'VERSION', value: parameters.buildVersion },
|
||||
{ name: 'ANDROID_VERSION_CODE', value: parameters.androidVersionCode },
|
||||
{ name: 'ANDROID_KEYSTORE_NAME', value: parameters.androidKeystoreName },
|
||||
|
|
|
|||
|
|
@ -143,6 +143,12 @@ class Input {
|
|||
return input === 'true';
|
||||
}
|
||||
|
||||
static get enableParallelLinking(): boolean {
|
||||
const input = Input.getInput('enableParallelLinking') ?? true;
|
||||
|
||||
return input === 'true';
|
||||
}
|
||||
|
||||
static get customParameters(): string {
|
||||
return Input.getInput('customParameters') ?? '';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -194,6 +194,7 @@ class SetupMac {
|
|||
process.env.CHOWN_FILES_TO = buildParameters.chownFilesTo;
|
||||
process.env.MANUAL_EXIT = buildParameters.manualExit.toString();
|
||||
process.env.ENABLE_GPU = buildParameters.enableGpu.toString();
|
||||
process.env.ENABLE_PARALLEL_LINKING = buildParameters.enableParallelLinking.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue