diff --git a/scripts/cover.sh b/scripts/cover.sh deleted file mode 100755 index e5d750b25f..0000000000 --- a/scripts/cover.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -set -e -node ./node_modules/istanbul/lib/cli.js cover --report html ./node_modules/.bin/_mocha -- jscomp/test/*test.js "$@" diff --git a/scripts/release.js b/scripts/release.js deleted file mode 100755 index 1ddacab96e..0000000000 --- a/scripts/release.js +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env node -//@ts-check - -// used as a unit of releasing -var path = require("path"); -var fs = require("fs"); -var cp = require("child_process"); -var rootDir = path.join(__dirname, ".."); -var libJsDir = path.join(rootDir, "lib", "js"); -var jscompDir = path.join(rootDir, "jscomp"); - -function run() { - // Note removing js file would affect `release.ninja` - // for (let file of fs.readdirSync(libJsDir)) { - // if (file.endsWith('.js')) { - // fs.unlinkSync(path.join(libJsDir, file)) - // } - // } - - cp.execSync( - `git clean -dfx stubs ext common syntax depends core bsb main .`, - { cwd: jscompDir, encoding: "utf8", stdio: [0, 1, 2] }, - ); - cp.execSync(`ninja -t clean -g && ninja`, { - cwd: jscompDir, - encoding: "utf8", - stdio: [0, 1, 2], - }); - cp.execSync("ninja", { cwd: path.join(rootDir, "lib"), stdio: [0, 1, 2] }); - cp.execSync("ninja -f release.ninja -t clean && ninja -f release.ninja", { - cwd: path.join(rootDir, "jscomp"), - stdio: [0, 1, 2], - }); - require("./doc_gen").main(); -} -if (require.main === module) { - run(); -} -exports.run = run; diff --git a/scripts/shake.js b/scripts/shake.js deleted file mode 100644 index a3f1178a1d..0000000000 --- a/scripts/shake.js +++ /dev/null @@ -1,138 +0,0 @@ -//@ts-check -// usage : node ./script/shake.js bsb -var cp = require("child_process"); -var path = require("path"); -var fs = require("fs"); - -var bsc = path.join(__dirname, "..", process.platform, "bsc"); -var ocamlopt = path.join( - __dirname, - "..", - "native", - "4.06.1", - "bin", - "ocamlopt.opt", -); - -var base = process.argv[2]; -if (base === undefined) { - console.error(`please specifiy a base`); - process.exit(2); -} -var file = `${base}.ml`; -var cwd = path.join(__dirname, "..", "lib", "4.06.1"); - -// TODO replace it with yours -var esy = `/Users/hongbozhang/git/genType/_esy/default/build/install/default/bin`; - -/** - * - * @param {string} file - */ -function dsource(file) { - let tmp = path.join(cwd, "tmp.ml"); - var output = cp.spawnSync( - `${bsc} -bs-no-builtin-ppx -bs-syntax-only -dsource -c ${file} 2>${tmp}`, - { - cwd, - encoding: "utf8", - shell: true, - }, - ); - // check output.status - if (output.status === 0) { - // fs.writeFileSync(path.join(cwd, file), output.stderr); - fs.copyFileSync(tmp, path.join(cwd, file)); - fs.unlinkSync(tmp); - } else { - console.error(`dsource failure`); - console.error(fs.readFileSync(tmp) + ""); - process.exit(2); - } - - // fs.copyFileSync(path.join(cwd, tmp), path.join(cwd, file)); -} - -/** - * - * @param {string} file - * @param {string} msg - */ -function checkDiff(file, msg) { - var output = cp.spawnSync(`git diff --quiet ${file}`, { - shell: true, - encoding: "utf8", - cwd, - }); - if (output.status !== 0) { - var output = cp.spawnSync( - `git add ${file} && git commit -m "${msg} for ${file}"`, - { shell: true, encoding: "utf8", cwd }, - ); - if (output.status !== 0) { - console.error(`diff failure for ${file} -- ${msg}`); - process.exit(2); - } else { - console.log(output.stdout); - } - } else { - console.log(`nothing changes to ${file}`); - } -} -/** - * - * @param {string} file - */ -function shake(file) { - let tmp = path.join(cwd, "tmp.ml"); - var output = cp.spawnSync( - `${bsc} -bs-no-builtin-ppx -bs-syntax-only -dsource -ppx ${esy}/deadcodeppx.exe -c ${file} 2>${tmp}`, - { - cwd, - encoding: "utf8", - shell: true, - }, - ); - if (output.status !== 0) { - console.error(`shake failure`); - console.error(fs.readFileSync(tmp) + ""); - process.exit(2); - } else { - // fs.writeFileSync(path.join(cwd, file), output.stderr); - fs.copyFileSync(tmp, path.join(cwd, file)); - fs.unlinkSync(tmp); - } -} - -/** - * - * @param {string} file - */ -function attachDead(file) { - var output = cp.spawnSync(`${ocamlopt} -bin-annot -c ${file}`, { - cwd, - encoding: "utf8", - shell: true, - }); - - var genType = path.join(esy, "genType.exe"); - - output = cp.spawnSync(`Write=1 ${genType} -dce-cmt ${base}.cmt`, { - cwd, - encoding: "utf8", - shell: true, - }); - if (output.status !== 0) { - console.error(`dce failure`); - console.error(output.stderr); - process.exit(2); - } - // fs.writeFileSync(path.join(cwd,file),output.stderr) -} - -// normalize files -dsource(file); -checkDiff(file, `dsource changes`); -attachDead(file); -shake(file); -checkDiff(file, `shake`); diff --git a/scripts/tmp.js b/scripts/tmp.js deleted file mode 100644 index e8c58a38fb..0000000000 --- a/scripts/tmp.js +++ /dev/null @@ -1,98 +0,0 @@ -//@ts-check -var fs = require("fs"); -var path = require("path"); -/** - * - * @param {number} n - */ -function* range(n) { - for (var i = 0; i < n; ++i) { - yield i; - } -} - -/** - * - * @param {number} n - */ -var constructors = n => { - return [...range(n)].map(x => `| A${x} \n`).reduce((x, y) => x + y); -}; - -/** - * - * @param {number} n - */ -var polyConstructors = n => { - return [...range(n)].map(x => `| \`variant${x} \n`).reduce((x, y) => x + y); -}; - -/** - * - * @param {number} n - */ -var matches = n => { - return [...range(n)].map(x => `| A${x} -> ${x} \n `).reduce((x, y) => x + y); -}; - -/** - * - * @param {number} n - */ -var xs = n => { - return [...range(n)] - .map(x => `| A${x} -> "A${x}" \n `) - .reduce((x, y) => x + y); -}; - -/** - * - * @param {number} n - */ -var code = n => { - var content = `type t = \n ${constructors(n)}`; - var match = `let to_enum = function\n ${matches(n)}`; - var to_string = `let to_string = function\n ${xs(n)}`; - return content + match + to_string; -}; - -/** - * - * @param {number} n - */ -var polyCode = n => { - var content = `type t = [ \n ${polyConstructors( - n, - )}\n ] [@@deriving jsConverter] `; - var eq = ` - let eq (x : t option) (y: t option) = - match x with - | Some x -> - (match y with None -> false | Some y -> x = y) - | None -> y = None - `; - var assertions = [...range(n)] - .map(x => `\n;;assert (tToJs \`variant${x} = "variant${x}")`) - .reduce((x, y) => x + y); - var assertions2 = [...range(n)] - .map(x => `\n;;assert (eq (tFromJs "variant${x}") (Some \`variant${x}))`) - .reduce((x, y) => x + y); - var assertions3 = `\n;;assert (eq (tFromJs "xx") None) \n`; - return content + eq + assertions + assertions2 + assertions3; -}; -var run = () => { - fs.writeFileSync( - path.join(__dirname, "..", "tests", "tests", "big_enum.ml"), - code(300), - "utf8", - ); -}; - -var runPol = () => { - fs.writeFileSync( - path.join(__dirname, "..", "tests", "tests", "big_polyvar_test.ml"), - polyCode(300), - ); -}; - -runPol();