UNPKG

bs-platform

Version:

bucklescript compiler, ocaml standard libary by bucklescript and its required runtime support

74 lines (67 loc) 2.11 kB
//@ts-check var cp = require("child_process"); var path = require("path"); var { sys_extension, is_windows } = require("./config.js"); var root = path.join(__dirname, ".."); var root_config = { cwd: root, stdio: [0, 1, 2], encoding: 'utf8' }; process.env.BS_RELEASE_BUILD = "true"; var ocamlVersion = require("./buildocaml.js").getVersionPrefix(); var fs = require("fs"); var hostPlatform = "darwin"; function rebuild() { cp.execSync(`node ${path.join(__dirname, "ninja.js")} clean`, { cwd: __dirname, stdio: [0, 1, 2] }); cp.execSync(`node ${path.join(__dirname, "ninja.js")} config`, { cwd: __dirname, stdio: [0, 1, 2] }); cp.execSync(`node ${path.join(__dirname, "ninja.js")} build`, { cwd: __dirname, stdio: [0, 1, 2] }); } function buildCompiler() { // for 4.02.3 it relies on OCAMLLIB to find stdlib path // for 4.06.1 OCAMLLIB is another PATH // delete process.env.OCAMLLIB var prebuilt = "prebuilt.ninja"; var content = require("./ninjaFactory.js").libNinja({ ocamlopt: is_windows ? `ocamlopt.opt.exe` : `../native/${ocamlVersion}/bin/ocamlopt.opt`, ext: sys_extension, INCL: ocamlVersion, isWin: is_windows }); fs.writeFileSync(path.join(root, "lib", prebuilt), content, "ascii"); process.env.PATH= `${path.join(__dirname,'..','vendor','ninja','snapshot')}${path.delimiter}${process.env.PATH}` let ninjaPath = `ninja${sys_extension}` cp.execSync( `${ninjaPath} -C lib -f ${prebuilt} -t clean && ${ninjaPath} -C lib -f ${prebuilt}`, root_config ); } if (!is_windows) { rebuild(); require("./ninja.js").updateRelease(); } var os = require("os"); function createOCamlTar() { if (os.platform() === hostPlatform) { cp.execSync(`git -C ocaml status -uno`, { cwd: root, stdio: [0, 1, 2] }); cp.execSync( `git -C ocaml archive --format=tar.gz HEAD -o ../vendor/ocaml.tar.gz`, { cwd: root, stdio: [0, 1, 2] } ); // fs.copyFileSync( // path.join(root, "ocaml", "VERSION"), // path.join(root, "OCAML_VERSION") // ); } } createOCamlTar(); buildCompiler(); //