Skip to content
Draft
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
2 changes: 1 addition & 1 deletion src/commands/compile/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import { buildCommand } from "@stricli/core";
import { TARGETS, TargetSchema } from "~/igor";
import { TARGETS, TargetSchema } from "~/target";
import { parseProjectPath } from "~/project";
import { parseToolchainVersion } from "~/toolchain";

Expand Down
6 changes: 4 additions & 2 deletions src/commands/init/scaffold.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ export async function scaffoldProject(
const projectToolPath = await downloadProjectTool(ctx, cache, noopLog, {
verbose: false,
});
const gmpmPath = await downloadGmpm(ctx, cache, noopLog, { verbose: false });
const { gmpmDllPath } = await downloadGmpm(ctx, cache, noopLog, {
verbose: false,
});
const packageToolPath = await downloadPackageTool(ctx, cache, noopLog, {
verbose: false,
});
Expand All @@ -61,7 +63,7 @@ export async function scaffoldProject(
projectToolPath,
projectPath: extractedYyp,
packageToolPath,
gmpmPath,
gmpmDllPath,
verbose: true,
});

Expand Down
2 changes: 1 addition & 1 deletion src/commands/package/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import { buildCommand } from "@stricli/core";
import { TARGETS, TargetSchema } from "~/igor";
import { TARGETS, TargetSchema } from "~/target";
import { parseProjectPath } from "~/project";
import { parseToolchainVersion } from "~/toolchain";

Expand Down
15 changes: 14 additions & 1 deletion src/commands/package/impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import type { Context } from "~/context";
import { getProjectName, type ProjectPath } from "~/project";
import { packageExtension, type Target } from "~/igor";
import type { Target } from "~/target";
import {
commonCompileSetup,
type CommonCliBuildFlags,
Expand Down Expand Up @@ -82,3 +82,16 @@ function getPackageAction(target: Target): string {
// FIXME: exhaustiveness checking and fix for platforms like xbox: PackageSubmissionXboxOne", PackageSubmissionXboxSeriesXS
}
}

function packageExtension(target: Target): string | undefined {
switch (target) {
case "windows":
case "linux":
case "mac":
case "operagx":
return ".zip";
default:
// FIXME: implement for all platforms
return;
}
}
4 changes: 2 additions & 2 deletions src/commands/resourcetool/impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export async function run(
});

if (projectPath !== undefined) {
const gmpmPath = await downloadGmpm(ctx, cache, noopLog, {
const { gmpmDllPath } = await downloadGmpm(ctx, cache, noopLog, {
verbose: false,
});
const packageToolPath = await downloadPackageTool(ctx, cache, noopLog, {
Expand All @@ -71,7 +71,7 @@ export async function run(
projectToolPath,
projectPath,
packageToolPath,
gmpmPath,
gmpmDllPath: gmpmDllPath,
verbose: false,
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/run/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import { buildCommand } from "@stricli/core";
import { TARGETS, TargetSchema } from "~/igor";
import { TARGETS, TargetSchema } from "~/target";
import { parseProjectPath } from "~/project";
import { parseToolchainVersion } from "~/toolchain";

Expand Down
132 changes: 97 additions & 35 deletions src/common-compile-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@

import { exists, type Context } from "./context";
import {
targetForPlatform,
downloadIgor,
installRuntimeIfNeeded,
type Target,
type CommonIgorBuildArgs,
fetchLicense,
} from "./igor";
Expand All @@ -35,6 +33,8 @@ import { Cache } from "./cache";
import { noopLog, type Log } from "./log";
import type { ToolchainVersion } from "./toolchain";
import { restorePrefabs } from "./restore-prefabs";
import { installGmrtIfNeeded, spawnGmrt } from "./gmrt";
import { targetForPlatform, type Target } from "./target";

/**
* Command flags exposed in package/run/compile
Expand Down Expand Up @@ -152,13 +152,6 @@ export async function commonCompileSetup(
// flag for GMRT later too. Default to VM if not set.
const runtime = flags.runtime === "native" ? "YYC" : "VM";

// FIXME: Add support for GMRT
if (flags.toolchain?.type === "GMRT") {
throw new KnownError(
"Support for the GMRT toolchain is coming soon to GameMaker CLI.",
);
}

// FIXME: Add full support for all platforms
if (!["mac", "windows", "linux", "operagx"].includes(target)) {
throw new KnownError(
Expand All @@ -181,27 +174,20 @@ export async function commonCompileSetup(
: { type: "infer", projectDir: ctx.path.dirname(projectPath) },
);

const igorLog = ctx.makeTaskLogger("Downloading Igor");
let igorPath: string;
try {
igorPath = await downloadIgor(ctx, igorLog, cache);
} catch (e) {
igorLog.error("Failed to download Igor");
throw new KnownError(e);
}
igorLog.success("Igor downloaded");

const gmToolLog = ctx.makeTaskLogger("Downloading tools");
let projectToolPath: string;
let gmpmPath: string;
let gmpmDllPath;
let gmpmExecutablePath;
let packageToolPath: string;
try {
projectToolPath = await downloadProjectTool(ctx, cache, gmToolLog, {
verbose: flags.verbose ?? false,
});
gmpmPath = await downloadGmpm(ctx, cache, gmToolLog, {
const gmpm = await downloadGmpm(ctx, cache, gmToolLog, {
verbose: flags.verbose ?? false,
});
gmpmDllPath = gmpm.gmpmDllPath;
gmpmExecutablePath = gmpm.gmpmExecutablePath;
packageToolPath = await downloadPackageTool(ctx, cache, gmToolLog, {
verbose: flags.verbose ?? false,
});
Expand All @@ -211,27 +197,14 @@ export async function commonCompileSetup(
}
gmToolLog.success("Tools downloaded");

const licenseLog = ctx.makeTaskLogger("Fetching license");
const licenseFile = await getLicense(ctx, flags, cache, igorPath, licenseLog);
licenseLog.success("License fetched");

const runtimeLog = ctx.makeTaskLogger("Installing runtime");
const runtimeLocation = await installRuntimeIfNeeded(ctx, runtimeLog, {
licenseFile,
igorPath,
cache,
version: flags.toolchain?.version,
target,
});

const prefabsLog = ctx.makeTaskLogger("Restoring prefabs");
let prefabsDir: string;
try {
prefabsDir = await restorePrefabs(ctx, cache, prefabsLog, {
projectToolPath,
projectPath,
packageToolPath,
gmpmPath,
gmpmDllPath,
verbose: flags.verbose ?? false,
});
} catch (e) {
Expand All @@ -240,6 +213,95 @@ export async function commonCompileSetup(
}
prefabsLog.success("Prefabs restored");

if (flags.toolchain?.type === "GMRT") {
const gmrtDownloadLog = ctx.makeTaskLogger("Downloading GMRT");

const gmrtRuntime = await installGmrtIfNeeded(ctx, cache, gmrtDownloadLog, {
verbose: flags.verbose ?? false,
version: flags.toolchain.version,
gmpmPath: gmpmExecutablePath,
});
gmrtDownloadLog.success("GMRT downloaded");
const gmrtRunLog = ctx.makeTaskLogger("Running GMRT", { noCollapse: true });

const buildCacheDir = await cache.getSubDirPath(
ctx,
`build-cache-gmrt-${target}-${runtime}`,
);

const buildDir = await cache.getSubDirPath(
ctx,
`build-gmrt-${target}-${runtime}`,
);

await spawnGmrt(ctx, gmrtRunLog, {
gmrtPath: gmrtRuntime.gmrtPath,
args: [
projectPath,
"-o",
buildDir,
"-bg",
gmrtRuntime.buildGraphPath,
"-bj",
// TODO: Depends on target and command and options (e.g. native/vm)
"Build-native-macos-arm64;Run-macos-arm64",
...(flags.verbose ? ["-v"] : []),
// TOOD: expose
"--build-type",
"Release",
"--script-build-type",
"Debug",
"--cache-dir",
buildCacheDir,
"--prefab-dir",
prefabsDir,
"--projecttool",
projectToolPath,
"--user-config",
"Default",
"--launch-type",
"run",

// FIXME: remove these later (or create corresponding files in our own cache)
"--target-options",
"/Users/eli/Library/Application Support/GameMakerStudio2-Beta/Cache/GMS2CACHE/BLANK_GAME_39DEBCCB/targetoptions.json",
"--target-preferences",
"/Users/eli/Library/Application Support/GameMakerStudio2-Beta/Cache/GMS2CACHE/BLANK_GAME_39DEBCCB/preferences.json",
"--gmrt-preferences",
"/Users/eli/Library/Application Support/GameMakerStudio2-Beta/Cache/GMS2CACHE/BLANK_GAME_39DEBCCB/GMRTPreferences.json",
// FIXME: add license file
],
});

// FIXME: Add full GMRT build invocation
throw new KnownError(
"Support for the GMRT toolchain is coming soon to GameMaker CLI.",
);
}

const igorLog = ctx.makeTaskLogger("Downloading Igor");
let igorPath: string;
try {
igorPath = await downloadIgor(ctx, igorLog, cache);
} catch (e) {
igorLog.error("Failed to download Igor");
throw new KnownError(e);
}
igorLog.success("Igor downloaded");

const licenseLog = ctx.makeTaskLogger("Fetching license");
const licenseFile = await getLicense(ctx, flags, cache, igorPath, licenseLog);
licenseLog.success("License fetched");

const runtimeLog = ctx.makeTaskLogger("Installing runtime");
const runtimeLocation = await installRuntimeIfNeeded(ctx, runtimeLog, {
licenseFile,
igorPath,
cache,
version: flags.toolchain?.version,
target,
});

const buildCacheDir = await cache.getSubDirPath(
ctx,
`build-gms2-${target}-${runtime}`,
Expand Down
19 changes: 8 additions & 11 deletions src/gm-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ export async function downloadGmpm(
cache: Cache,
log: Log,
{ verbose }: { verbose: boolean },
) {
return download(
): Promise<{ gmpmDllPath: string; gmpmExecutablePath: string }> {
const dir = await download(
ctx,
"gmpm",
cache,
Expand All @@ -97,21 +97,18 @@ export async function downloadGmpm(
"bundle",
"Contents",
"MacOS",
"gmpm.dll",
);
}
if (ctx.process.platform === "win32") {
return ctx.path.join(destDir, "node_modules", packageName, "gmpm.dll");
return ctx.path.join(destDir, "node_modules", packageName);
}
return ctx.path.join(
destDir,
"lib",
"node_modules",
packageName,
"gmpm.dll",
);
return ctx.path.join(destDir, "lib", "node_modules", packageName);
},
);
return {
gmpmDllPath: ctx.path.join(dir, "gmpm.dll"),
gmpmExecutablePath: ctx.path.join(dir, "gmpm"),
};
}

export async function downloadPackageTool(
Expand Down
18 changes: 18 additions & 0 deletions src/gmrt/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Copyright 2026, Opera Norway AS
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

export * from "./install-runtime";
export * from "./spawn";
Loading
Loading