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

Fix macOS unity base path so that unity existence check works as intended #551

Merged
merged 1 commit into from
Jul 27, 2023
Merged
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
35 changes: 20 additions & 15 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.

38 changes: 22 additions & 16 deletions src/model/platform-setup/setup-mac.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { restoreCache, saveCache } from '@actions/cache';
import fs from 'node:fs';

class SetupMac {
static unityHubBasePath = `/Applications/"Unity Hub.app"`;
static unityHubExecPath = `${SetupMac.unityHubBasePath}/Contents/MacOS/"Unity Hub"`;
static unityHubBasePath = `/Applications/Unity Hub.app`;
static unityHubExecPath = `${SetupMac.unityHubBasePath}/Contents/MacOS/Unity Hub`;

public static async setup(buildParameters: BuildParameters, actionFolder: string) {
const unityEditorPath = `/Applications/Unity/Hub/Editor/${buildParameters.editorVersion}/Unity.app/Contents/MacOS/Unity`;
Expand Down Expand Up @@ -72,23 +72,23 @@ class SetupMac {
return '';
}

private static getModuleParametersForTargetPlatform(targetPlatform: string): string {
let moduleArgument = '';
private static getModuleParametersForTargetPlatform(targetPlatform: string): string[] {
const moduleArgument = [];
switch (targetPlatform) {
case 'iOS':
moduleArgument += `--module ios `;
moduleArgument.push('--module', 'ios');
break;
case 'tvOS':
moduleArgument += '--module tvos ';
moduleArgument.push('--module', 'tvos');
break;
case 'StandaloneOSX':
moduleArgument += `--module mac-il2cpp `;
moduleArgument.push('--module', 'mac-il2cpp');
break;
case 'Android':
moduleArgument += `--module android `;
moduleArgument.push('--module', 'android');
break;
case 'WebGL':
moduleArgument += '--module webgl ';
moduleArgument.push('--module', 'webgl');
break;
default:
throw new Error(`Unsupported module for target platform: ${targetPlatform}.`);
Expand All @@ -110,17 +110,23 @@ class SetupMac {
}

const unityChangeset = await getUnityChangeset(buildParameters.editorVersion);
const moduleArgument = SetupMac.getModuleParametersForTargetPlatform(buildParameters.targetPlatform);
const moduleArguments = SetupMac.getModuleParametersForTargetPlatform(buildParameters.targetPlatform);

const command = `${this.unityHubExecPath} -- --headless install \
--version ${buildParameters.editorVersion} \
--changeset ${unityChangeset.changeset} \
${moduleArgument} \
--childModules `;
const execArguments: string[] = [
'--',
'--headless',
'install',
...['--version', buildParameters.editorVersion],
...['--changeset', unityChangeset.changeset],
webbertakken marked this conversation as resolved.
Show resolved Hide resolved
...moduleArguments,
'--childModules',
];

const escapedExecPath = this.unityHubExecPath.replace(/ /g, '\\ ');

// Ignoring return code because the log seems to overflow the internal buffer which triggers
// a false error
const errorCode = await exec(command, undefined, { silent, ignoreReturnCode: true });
const errorCode = await exec(escapedExecPath, execArguments, { silent, ignoreReturnCode: true });
webbertakken marked this conversation as resolved.
Show resolved Hide resolved
if (errorCode) {
throw new Error(`There was an error installing the Unity Editor. See logs above for details.`);
}
Expand Down