diff --git a/build.js b/build.js new file mode 100644 index 0000000..e43bea7 --- /dev/null +++ b/build.js @@ -0,0 +1,21 @@ +const childProcess = require("child_process"); +const os = require("os"); + +function puts(error, stdout, stderr) { + if (error) { + throw error; + } + console.log(stdout); + console.error(stderr); +} + +switch (os.type()) { + case "Linux": + childProcess.exec("npm run build-linux", puts); + break; + case "Windows_NT": + childProcess.exec("npm run build-windows", puts); + break; + default: + throw new Error("Unsupported OS found: " + os.type()); +} diff --git a/package.json b/package.json index 570acac..1f08e1f 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,9 @@ "url": "https://git.jedipedia.net/swtor/ssn.git" }, "scripts": { - "preinstall": "gcc -Wall -m64 -o ssn-installer lib/miniz/miniz.c src/*.c src/*/*.c && chmod +x ssn-installer" + "preinstall": "npm run build-linux", + "build-linux": "gcc -Wall -m64 -o ssn-installer lib/miniz/miniz.c src/*.c src/*/*.c && chmod +x ssn-installer", + "build-windows": "gcc -Wall -m64 -std=c99 -o ssn-installer.exe lib/miniz/miniz.c src/*.c src/utils/decryptUtilities.c src/utils/fileUtilities.c" }, "files": [ "lib/miniz/miniz.h",