Skip to content

Commit

Permalink
Potential fix for issue with being unable to build if running using t…
Browse files Browse the repository at this point in the history
…he Itch.io app
  • Loading branch information
chrismaltby committed Jun 25, 2019
1 parent 17dacf0 commit 70f949a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/lib/compiler/ensureBuildTools.js
@@ -1,14 +1,14 @@
import { remote } from "electron";
import fs from "fs-extra";
import { buildToolsRoot } from "../../consts";
import copy from "../helpers/fsCopy";
import getTmp from "../helpers/getTmp";

const ensureBuildTools = async () => {
const buildToolsPath = `${buildToolsRoot}/${process.platform}-${
process.arch
}`;

const tmpPath = remote.app.getPath("temp");
const tmpPath = getTmp();
const tmpBuildToolsPath = `${tmpPath}/_gbs`;

// Symlink build tools so that path doesn't contain any spaces
Expand Down
5 changes: 4 additions & 1 deletion src/lib/compiler/makeBuild.js
Expand Up @@ -4,6 +4,7 @@ import fs from "fs-extra";
import { buildToolsRoot } from "../../consts";
import copy from "../helpers/fsCopy";
import buildMakeBat from "./buildMakeBat";
import getTmp from "../helpers/getTmp";

const HEADER_TITLE = 0x134;
const HEADER_CHECKSUM = 0x14d;
Expand Down Expand Up @@ -60,7 +61,7 @@ const makeBuild = ({
process.arch
}`;

const tmpPath = remote.app.getPath("temp");
const tmpPath = getTmp();
const tmpBuildToolsPath = `${tmpPath}/_gbs`;

// Symlink build tools so that path doesn't contain any spaces
Expand All @@ -77,6 +78,8 @@ const makeBuild = ({
env.PATH = [`${tmpBuildToolsPath}/gbdk/bin`, env.PATH].join(":");
env.GBDKDIR = `${tmpBuildToolsPath}/gbdk/`;
env.CART_TYPE = parseInt(data.settings.cartType || "1B", 16);
env.TMP = getTmp();
env.TEMP = getTmp();

const makeBat = await buildMakeBat(buildRoot, { CART_TYPE: env.CART_TYPE });
await fs.writeFile(`${buildRoot}/make.bat`, makeBat);
Expand Down
12 changes: 12 additions & 0 deletions src/lib/helpers/getTmp.js
@@ -0,0 +1,12 @@
import { remote } from "electron";

export default () => {
const tmpPath = remote.app.getPath("temp");
if (tmpPath.indexOf(" ") === -1) {
return tmpPath;
}
if (process.platform === "win32") {
return "C:\tmp";
}
return "/tmp";
};
7 changes: 3 additions & 4 deletions src/middleware/buildGame.js
Expand Up @@ -13,6 +13,7 @@ import {
} from "../actions/actionTypes";
import copy from "../lib/helpers/fsCopy";
import { denormalizeProject } from "../reducers/entitiesReducer";
import getTmp from "../lib/helpers/getTmp";

const buildUUID = uuid();

Expand All @@ -26,15 +27,13 @@ export default store => next => async action => {
const state = store.getState();
const projectRoot = state.document && state.document.root;
const project = denormalizeProject(state.entities.present);
const outputRoot = Path.normalize(
`${remote.app.getPath("temp")}/${buildUUID}`
);
const outputRoot = Path.normalize(`${getTmp()}/${buildUUID}`);

await buildProject(project, {
projectRoot,
buildType,
outputRoot,
tmpPath: remote.app.getPath("temp"),
tmpPath: getTmp(),
progress: message => {
if (
message !== "'" &&
Expand Down

0 comments on commit 70f949a

Please sign in to comment.