Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: macos build with licensing server #580

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ lib/
.vsconfig
yarn-error.log
.orig
.env
build/*
dist/unity-config/*.txt
11 changes: 11 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
19 changes: 17 additions & 2 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/platforms/mac/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
68 changes: 55 additions & 13 deletions dist/platforms/mac/steps/activate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions dist/platforms/mac/steps/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,6 @@ echo ""
-quit \
-batchmode \
-nographics \
-username "$UNITY_EMAIL" \
-password "$UNITY_PASSWORD" \
-customBuildName "$BUILD_NAME" \
-projectPath "$UNITY_PROJECT_PATH" \
-buildTarget "$BUILD_TARGET" \
Expand Down
30 changes: 21 additions & 9 deletions dist/platforms/mac/steps/return_license.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions src/model/build-parameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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}`,
Expand Down
4 changes: 4 additions & 0 deletions src/model/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
Expand Down
6 changes: 4 additions & 2 deletions src/model/platform-setup/setup-mac.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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');
Expand All @@ -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[] = [
'--',
Expand All @@ -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
Expand Down
11 changes: 11 additions & 0 deletions src/model/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Loading