From 56214defaf3055d0427da7a098f8bbd3d7df43f2 Mon Sep 17 00:00:00 2001 From: tobspr Date: Tue, 25 May 2021 13:12:38 +0200 Subject: [PATCH] Support for building on non-steam platforms --- gulp/standalone.js | 52 +++++++++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/gulp/standalone.js b/gulp/standalone.js index 914fb95a..c6dc17f5 100644 --- a/gulp/standalone.js +++ b/gulp/standalone.js @@ -9,26 +9,31 @@ const buildutils = require("./buildutils"); const execSync = require("child_process").execSync; function gulptasksStandalone($, gulp) { - const electronBaseDir = path.join(__dirname, "..", "electron"); const targets = [ { tempDestDir: path.join(__dirname, "..", "tmp_standalone_files"), suffix: "", taskPrefix: "", + electronBaseDir: path.join(__dirname, "..", "electron"), + steam: true, }, { tempDestDir: path.join(__dirname, "..", "tmp_standalone_files_china"), suffix: "china", taskPrefix: "china.", + electronBaseDir: path.join(__dirname, "..", "electron"), + steam: true, }, { tempDestDir: path.join(__dirname, "..", "tmp_standalone_files_wegame"), suffix: "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"); gulp.task(taskPrefix + "standalone.prepare.cleanup", () => { @@ -39,13 +44,15 @@ function gulptasksStandalone($, gulp) { const requiredFiles = [ path.join(electronBaseDir, "node_modules", "**", "*.*"), path.join(electronBaseDir, "node_modules", "**", ".*"), - path.join(electronBaseDir, "steam_appid.txt"), path.join(electronBaseDir, "favicon*"), // fails on platforms which support symlinks // https://github.com/gulpjs/gulp/issues/1427 // 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)); }); @@ -69,6 +76,11 @@ function gulptasksStandalone($, gulp) { }); gulp.task(taskPrefix + "standalone.prepareVDF", cb => { + if (!steam) { + cb(); + return; + } + const hash = buildutils.getRevision(); const steampipeDir = path.join(__dirname, "steampipe", "scripts"); @@ -122,7 +134,7 @@ function gulptasksStandalone($, gulp) { const privateArtifactsPath = "node_modules/shapez.io-private-artifacts"; let asar; - if (fs.existsSync(path.join(tempDestBuildDir, privateArtifactsPath))) { + if (steam && fs.existsSync(path.join(tempDestBuildDir, privateArtifactsPath))) { asar = { unpackDir: privateArtifactsPath }; } else { asar = true; @@ -152,24 +164,26 @@ function gulptasksStandalone($, gulp) { return; } - fs.writeFileSync( - path.join(appPath, "LICENSE"), - fs.readFileSync(path.join(__dirname, "..", "LICENSE")) - ); + if (steam) { + fs.writeFileSync( + path.join(appPath, "LICENSE"), + fs.readFileSync(path.join(__dirname, "..", "LICENSE")) + ); - fse.copySync( - path.join(tempDestBuildDir, "steam_appid.txt"), - path.join(appPath, "steam_appid.txt") - ); + fse.copySync( + path.join(tempDestBuildDir, "steam_appid.txt"), + path.join(appPath, "steam_appid.txt") + ); - fs.writeFileSync(path.join(appPath, ".itch.toml"), tomlFile); + 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); + 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); + } } });