feat: macos build with licensing server

This commit is contained in:
eribeiro 2023-09-28 11:32:20 +01:00
parent a13443a746
commit 8e3860c7de
12 changed files with 111 additions and 26 deletions

3
.gitignore vendored
View File

@ -5,3 +5,6 @@ lib/
.vsconfig
yarn-error.log
.orig
.env
build/*
dist/unity-config/*.txt

11
.vscode/launch.json vendored
View File

@ -1,5 +1,16 @@
{
"configurations": [
{
"type": "node-terminal",
"request": "launch",
"name": "Launch Program",
"command": "ts-node -- ${workspaceFolder}/src/index.ts",
"cwd": "${workspaceFolder}",
"envFile": "${workspaceRoot}/.env",
"env": {
"UNITY_NOPROXY": "localhost,127.0.0.1"
}
},
{
"type": "node",
"request": "launch",

BIN
dist/index.js generated vendored

Binary file not shown.

BIN
dist/index.js.map generated vendored

Binary file not shown.

View File

@ -4,7 +4,7 @@
# Create directories for license activation
#
sudo mkdir /Library/Application\ Support/Unity
sudo mkdir -p /Library/Application\ Support/Unity/config
sudo chmod -R 777 /Library/Application\ Support/Unity
ACTIVATE_LICENSE_PATH="$ACTION_FOLDER/BlankProject"

View File

@ -6,6 +6,10 @@ pushd "$ACTIVATE_LICENSE_PATH"
echo "Requesting activation"
if [[ -n "$UNITY_SERIAL" && -n "$UNITY_EMAIL" && -n "$UNITY_PASSWORD" ]]; then
# Activate license
/Applications/Unity/Hub/Editor/$UNITY_VERSION/Unity.app/Contents/MacOS/Unity \
-logFile - \
@ -20,6 +24,44 @@ echo "Requesting activation"
# Store the exit code from the verify command
UNITY_EXIT_CODE=$?
elif [[ -n "$UNITY_LICENSING_SERVER" ]]; then
#
# Custom Unity License Server
#
echo "Adding licensing server config"
echo "Echoing the floating license address $UNITY_LICENSING_SERVER"
echo "Copying the services-config.json to Library"
cp ../unity-config/services-config.json /Library/Application\ Support/Unity/config/
/Applications/Unity/Hub/Editor/$UNITY_VERSION/Unity.app/Contents/Frameworks/UnityLicensingClient.app/Contents/Resources/Unity.Licensing.Client --acquire-floating > license.txt #is this accessible in a env variable?
##PARSEDFILE=$(grep -oP '\".*?\"' < license.txt | tr -d '"')
FLOATING_LICENSE=$(cat license.txt | awk '/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/' | awk '{print $6}' | sed 's/.$//')
export FLOATING_LICENSE
##FLOATING_LICENSE=$(sed -n 2p <<< "$PARSEDFILE")
#FLOATING_LICENSE_TIMEOUT=$(sed -n 4p <<< "$PARSEDFILE")
echo "Acquired floating license: \"$FLOATING_LICENSE\""
# Store the exit code from the verify command
UNITY_EXIT_CODE=$?
else
#
# NO LICENSE ACTIVATION STRATEGY MATCHED
#
# This will exit since no activation strategies could be matched.
#
echo "License activation strategy could not be determined."
echo ""
echo "Visit https://game.ci/docs/github/getting-started for more"
echo "details on how to set up one of the possible activation strategies."
# Immediately exit as no UNITY_EXIT_CODE can be derrived.
exit 1;
fi
#
# Display information about the result
#

View File

@ -132,8 +132,6 @@ echo ""
-quit \
-batchmode \
-nographics \
-username "$UNITY_EMAIL" \
-password "$UNITY_PASSWORD" \
-customBuildName "$BUILD_NAME" \
-projectPath "$UNITY_PROJECT_PATH" \
-buildTarget "$BUILD_TARGET" \

View File

@ -4,6 +4,16 @@
echo "Changing to \"$ACTIVATE_LICENSE_PATH\" directory."
pushd "$ACTIVATE_LICENSE_PATH"
if [[ -n "$UNITY_LICENSING_SERVER" ]]; then
#
# Return any floating license used.
#
echo "Returning floating license: \"$FLOATING_LICENSE\""
/Applications/Unity/Hub/Editor/$UNITY_VERSION/Unity.app/Contents/Frameworks/UnityLicensingClient.app/Contents/Resources/Unity.Licensing.Client --return-floating "$FLOATING_LICENSE"
else
/Applications/Unity/Hub/Editor/$UNITY_VERSION/Unity.app/Contents/MacOS/Unity \
-logFile - \
-batchmode \
@ -14,5 +24,7 @@ pushd "$ACTIVATE_LICENSE_PATH"
-returnlicense \
-projectPath "$ACTIVATE_LICENSE_PATH"
fi
# Return to previous working directory
popd

View File

@ -23,6 +23,7 @@ class BuildParameters {
public unityLicensingServer!: string;
public runnerTempPath!: string;
public targetPlatform!: string;
public targetArchitecture!: string;
public projectPath!: string;
public buildName!: string;
public buildPath!: string;
@ -134,6 +135,7 @@ class BuildParameters {
unityLicensingServer: Input.unityLicensingServer,
runnerTempPath: Input.runnerTempPath,
targetPlatform: Input.targetPlatform,
targetArchitecture: Input.targetArchitecture,
projectPath: Input.projectPath,
buildName: Input.buildName,
buildPath: `${Input.buildsPath}/${Input.targetPlatform}`,

View File

@ -80,6 +80,10 @@ class Input {
return Input.getInput('targetPlatform') || Platform.default;
}
static get targetArchitecture(): string {
return Input.getInput('targetArchitecture') || Platform.defaultarch;
}
static get unityVersion(): string {
return Input.getInput('unityVersion') || 'auto';
}

View File

@ -76,7 +76,7 @@ class SetupMac {
const moduleArgument = [];
switch (targetPlatform) {
case 'iOS':
moduleArgument.push('--module', 'ios');
moduleArgument.push('--module', 'ios', '--module', 'android');
break;
case 'tvOS':
moduleArgument.push('--module', 'tvos');
@ -85,7 +85,7 @@ class SetupMac {
moduleArgument.push('--module', 'mac-il2cpp');
break;
case 'Android':
moduleArgument.push('--module', 'android');
moduleArgument.push('--module', 'android', '--module', 'ios');
break;
case 'WebGL':
moduleArgument.push('--module', 'webgl');
@ -111,6 +111,7 @@ class SetupMac {
const unityChangeset = await getUnityChangeset(buildParameters.editorVersion);
const moduleArguments = SetupMac.getModuleParametersForTargetPlatform(buildParameters.targetPlatform);
const unityArch = buildParameters.targetArchitecture;
const execArguments: string[] = [
'--',
@ -120,6 +121,7 @@ class SetupMac {
...['--changeset', unityChangeset.changeset],
...moduleArguments,
'--childModules',
...['--architecture', unityArch],
];
// Ignoring return code because the log seems to overflow the internal buffer which triggers

View File

@ -3,6 +3,17 @@ class Platform {
return Platform.types.StandaloneWindows64;
}
static get defaultarch() {
return Platform.archs.X86_64;
}
static get archs() {
return {
X86_64: 'x86_64',
Arm64: 'arm64',
};
}
static get types() {
return {
StandaloneOSX: 'StandaloneOSX',