From 8e3860c7de00b99e25d565f02ea23cc8d47d709b Mon Sep 17 00:00:00 2001 From: eribeiro Date: Thu, 28 Sep 2023 11:32:20 +0100 Subject: [PATCH] feat: macos build with licensing server --- .gitignore | 3 + .vscode/launch.json | 11 ++++ dist/index.js | Bin 22170784 -> 22171325 bytes dist/index.js.map | Bin 14627568 -> 14628199 bytes dist/platforms/mac/entrypoint.sh | 2 +- dist/platforms/mac/steps/activate.sh | 66 +++++++++++++++++---- dist/platforms/mac/steps/build.sh | 2 - dist/platforms/mac/steps/return_license.sh | 30 +++++++--- src/model/build-parameters.ts | 2 + src/model/input.ts | 4 ++ src/model/platform-setup/setup-mac.ts | 6 +- src/model/platform.ts | 11 ++++ 12 files changed, 111 insertions(+), 26 deletions(-) diff --git a/.gitignore b/.gitignore index bc20e914..38624a6f 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,6 @@ lib/ .vsconfig yarn-error.log .orig +.env +build/* +dist/unity-config/*.txt \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json index 9c7be0a5..7e004362 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -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", diff --git a/dist/index.js b/dist/index.js index 9c38ab9a4a1f029e5c7d868a1ef046fee08cbb15..7e2642ff4e61c21f426504d6f6c595e83760131e 100644 GIT binary patch delta 1769 zcmZY9c~n$o9Eb5Ua6uVSSsXw_8Ce{K%Ls@gqKG4|xM8bhWFrnrfz~jTrj=zyWoC(W zv$D(LpXV;`xxe@Rb=R(LwQpb3YH!|e zS{oN{j*RvOD(6-Q{guJ`fWNWXOgibo(l)c9&9os5;h{Fus9O{p^abYlga3Ka@@+9P ztz+wrlgC-nO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StS!+DivOa@U(2Xh%Hnp^?_wY-NBHX`Aa5p zTV+ZS&}^3=0@~#H)mlqg_pE5lQc3oXv{+l=3@aCVi6W&31YDnaae}sSb>#T zh1FPtwTMRo)?qz1AQ2m}37fG6Td@sE*p6iEz)tMKZlqujQjvzeNJj=Tu@70uMh^Dl z01o014nv1r9KliOaSX?C0s<$IhkTqu0SZxs(SddNkl69^o;b;3=NrIU4Z-FVTcoc#USf b!CSn;d$gbxZD_{_bl@XC8BK#e$I1Tzh6;8! diff --git a/dist/platforms/mac/entrypoint.sh b/dist/platforms/mac/entrypoint.sh index 37cf7a4b..d95066a5 100755 --- a/dist/platforms/mac/entrypoint.sh +++ b/dist/platforms/mac/entrypoint.sh @@ -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" diff --git a/dist/platforms/mac/steps/activate.sh b/dist/platforms/mac/steps/activate.sh index c9511eb5..720514f4 100755 --- a/dist/platforms/mac/steps/activate.sh +++ b/dist/platforms/mac/steps/activate.sh @@ -6,19 +6,61 @@ pushd "$ACTIVATE_LICENSE_PATH" echo "Requesting activation" -# Activate license -/Applications/Unity/Hub/Editor/$UNITY_VERSION/Unity.app/Contents/MacOS/Unity \ - -logFile - \ - -batchmode \ - -nographics \ - -quit \ - -serial "$UNITY_SERIAL" \ - -username "$UNITY_EMAIL" \ - -password "$UNITY_PASSWORD" \ - -projectPath "$ACTIVATE_LICENSE_PATH" -# Store the exit code from the verify command -UNITY_EXIT_CODE=$? +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 - \ + -batchmode \ + -nographics \ + -quit \ + -serial "$UNITY_SERIAL" \ + -username "$UNITY_EMAIL" \ + -password "$UNITY_PASSWORD" \ + -projectPath "$ACTIVATE_LICENSE_PATH" + + # 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 diff --git a/dist/platforms/mac/steps/build.sh b/dist/platforms/mac/steps/build.sh index 8fd98f69..50727059 100755 --- a/dist/platforms/mac/steps/build.sh +++ b/dist/platforms/mac/steps/build.sh @@ -132,8 +132,6 @@ echo "" -quit \ -batchmode \ -nographics \ - -username "$UNITY_EMAIL" \ - -password "$UNITY_PASSWORD" \ -customBuildName "$BUILD_NAME" \ -projectPath "$UNITY_PROJECT_PATH" \ -buildTarget "$BUILD_TARGET" \ diff --git a/dist/platforms/mac/steps/return_license.sh b/dist/platforms/mac/steps/return_license.sh index 1749f9e7..aaa520e9 100755 --- a/dist/platforms/mac/steps/return_license.sh +++ b/dist/platforms/mac/steps/return_license.sh @@ -4,15 +4,27 @@ echo "Changing to \"$ACTIVATE_LICENSE_PATH\" directory." pushd "$ACTIVATE_LICENSE_PATH" -/Applications/Unity/Hub/Editor/$UNITY_VERSION/Unity.app/Contents/MacOS/Unity \ - -logFile - \ - -batchmode \ - -nographics \ - -quit \ - -username "$UNITY_EMAIL" \ - -password "$UNITY_PASSWORD" \ - -returnlicense \ - -projectPath "$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 \ + -nographics \ + -quit \ + -username "$UNITY_EMAIL" \ + -password "$UNITY_PASSWORD" \ + -returnlicense \ + -projectPath "$ACTIVATE_LICENSE_PATH" + +fi # Return to previous working directory popd diff --git a/src/model/build-parameters.ts b/src/model/build-parameters.ts index bd5f9103..10840a80 100644 --- a/src/model/build-parameters.ts +++ b/src/model/build-parameters.ts @@ -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}`, diff --git a/src/model/input.ts b/src/model/input.ts index f50b0633..5d793275 100644 --- a/src/model/input.ts +++ b/src/model/input.ts @@ -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'; } diff --git a/src/model/platform-setup/setup-mac.ts b/src/model/platform-setup/setup-mac.ts index d529d21f..33c8355a 100644 --- a/src/model/platform-setup/setup-mac.ts +++ b/src/model/platform-setup/setup-mac.ts @@ -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 diff --git a/src/model/platform.ts b/src/model/platform.ts index 768e51b4..b39b0957 100644 --- a/src/model/platform.ts +++ b/src/model/platform.ts @@ -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',