1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-06-04 08:34:02 +00:00

Support for building on non-steam platforms

This commit is contained in:
tobspr 2021-05-25 13:12:38 +02:00
parent 6e9fa89792
commit 56214defaf

View File

@ -9,26 +9,31 @@ const buildutils = require("./buildutils");
const execSync = require("child_process").execSync; const execSync = require("child_process").execSync;
function gulptasksStandalone($, gulp) { function gulptasksStandalone($, gulp) {
const electronBaseDir = path.join(__dirname, "..", "electron");
const targets = [ const targets = [
{ {
tempDestDir: path.join(__dirname, "..", "tmp_standalone_files"), tempDestDir: path.join(__dirname, "..", "tmp_standalone_files"),
suffix: "", suffix: "",
taskPrefix: "", taskPrefix: "",
electronBaseDir: path.join(__dirname, "..", "electron"),
steam: true,
}, },
{ {
tempDestDir: path.join(__dirname, "..", "tmp_standalone_files_china"), tempDestDir: path.join(__dirname, "..", "tmp_standalone_files_china"),
suffix: "china", suffix: "china",
taskPrefix: "china.", taskPrefix: "china.",
electronBaseDir: path.join(__dirname, "..", "electron"),
steam: true,
}, },
{ {
tempDestDir: path.join(__dirname, "..", "tmp_standalone_files_wegame"), tempDestDir: path.join(__dirname, "..", "tmp_standalone_files_wegame"),
suffix: "wegame", suffix: "wegame",
taskPrefix: "wegame.", taskPrefix: "wegame.",
electronBaseDir: path.join(__dirname, "..", "electron_wegame"),
steam: false,
}, },
]; ];
for (const { tempDestDir, suffix, taskPrefix } of targets) { for (const { tempDestDir, suffix, taskPrefix, electronBaseDir, steam } of targets) {
const tempDestBuildDir = path.join(tempDestDir, "built"); const tempDestBuildDir = path.join(tempDestDir, "built");
gulp.task(taskPrefix + "standalone.prepare.cleanup", () => { gulp.task(taskPrefix + "standalone.prepare.cleanup", () => {
@ -39,13 +44,15 @@ function gulptasksStandalone($, gulp) {
const requiredFiles = [ const requiredFiles = [
path.join(electronBaseDir, "node_modules", "**", "*.*"), path.join(electronBaseDir, "node_modules", "**", "*.*"),
path.join(electronBaseDir, "node_modules", "**", ".*"), path.join(electronBaseDir, "node_modules", "**", ".*"),
path.join(electronBaseDir, "steam_appid.txt"),
path.join(electronBaseDir, "favicon*"), path.join(electronBaseDir, "favicon*"),
// fails on platforms which support symlinks // fails on platforms which support symlinks
// https://github.com/gulpjs/gulp/issues/1427 // https://github.com/gulpjs/gulp/issues/1427
// path.join(electronBaseDir, "node_modules", "**", "*"), // path.join(electronBaseDir, "node_modules", "**", "*"),
]; ];
if (steam) {
requiredFiles.push(path.join(electronBaseDir, "steam_appid.txt"));
}
return gulp.src(requiredFiles, { base: electronBaseDir }).pipe(gulp.dest(tempDestBuildDir)); return gulp.src(requiredFiles, { base: electronBaseDir }).pipe(gulp.dest(tempDestBuildDir));
}); });
@ -69,6 +76,11 @@ function gulptasksStandalone($, gulp) {
}); });
gulp.task(taskPrefix + "standalone.prepareVDF", cb => { gulp.task(taskPrefix + "standalone.prepareVDF", cb => {
if (!steam) {
cb();
return;
}
const hash = buildutils.getRevision(); const hash = buildutils.getRevision();
const steampipeDir = path.join(__dirname, "steampipe", "scripts"); const steampipeDir = path.join(__dirname, "steampipe", "scripts");
@ -122,7 +134,7 @@ function gulptasksStandalone($, gulp) {
const privateArtifactsPath = "node_modules/shapez.io-private-artifacts"; const privateArtifactsPath = "node_modules/shapez.io-private-artifacts";
let asar; let asar;
if (fs.existsSync(path.join(tempDestBuildDir, privateArtifactsPath))) { if (steam && fs.existsSync(path.join(tempDestBuildDir, privateArtifactsPath))) {
asar = { unpackDir: privateArtifactsPath }; asar = { unpackDir: privateArtifactsPath };
} else { } else {
asar = true; asar = true;
@ -152,24 +164,26 @@ function gulptasksStandalone($, gulp) {
return; return;
} }
fs.writeFileSync( if (steam) {
path.join(appPath, "LICENSE"),
fs.readFileSync(path.join(__dirname, "..", "LICENSE"))
);
fse.copySync(
path.join(tempDestBuildDir, "steam_appid.txt"),
path.join(appPath, "steam_appid.txt")
);
fs.writeFileSync(path.join(appPath, ".itch.toml"), tomlFile);
if (platform === "linux") {
fs.writeFileSync( fs.writeFileSync(
path.join(appPath, "play.sh"), path.join(appPath, "LICENSE"),
'#!/usr/bin/env bash\n./shapezio --no-sandbox "$@"\n' fs.readFileSync(path.join(__dirname, "..", "LICENSE"))
); );
fs.chmodSync(path.join(appPath, "play.sh"), 0o775);
fse.copySync(
path.join(tempDestBuildDir, "steam_appid.txt"),
path.join(appPath, "steam_appid.txt")
);
fs.writeFileSync(path.join(appPath, ".itch.toml"), tomlFile);
if (platform === "linux") {
fs.writeFileSync(
path.join(appPath, "play.sh"),
'#!/usr/bin/env bash\n./shapezio --no-sandbox "$@"\n'
);
fs.chmodSync(path.join(appPath, "play.sh"), 0o775);
}
} }
}); });