From 8f231431fcab33e5be63e52bb4d515f9736df168 Mon Sep 17 00:00:00 2001 From: Fabian Date: Thu, 31 Dec 2020 19:14:30 -0600 Subject: [PATCH] Simplify --- Makefile | 2 -- gen/util.js | 41 +---------------------------------------- 2 files changed, 1 insertion(+), 42 deletions(-) diff --git a/Makefile b/Makefile index dd6c9f75..a8b3f9dc 100644 --- a/Makefile +++ b/Makefile @@ -195,8 +195,6 @@ clean: -rm build/v86.wasm -rm build/v86-debug.wasm -rm $(INSTRUCTION_TABLES) - -rm $(addsuffix .bak,$(INSTRUCTION_TABLES)) - -rm $(addsuffix .diff,$(INSTRUCTION_TABLES)) -rm build/*.map -rm build/*.wast $(MAKE) -C $(NASM_TEST_DIR) clean diff --git a/gen/util.js b/gen/util.js index 71a706df..9325428c 100644 --- a/gen/util.js +++ b/gen/util.js @@ -18,11 +18,7 @@ function hex(n, pad) function mkdirpSync(dir) { - path.normalize(dir).split(path.sep).reduce((accum_path, dir) => { - const new_dir = accum_path + dir + path.sep; - if(!fs.existsSync(new_dir)) fs.mkdirSync(new_dir); - return new_dir; - }, ""); + fs.mkdirSync(dir, { recursive: true }); } function get_switch_value(arg_switch) @@ -42,44 +38,10 @@ function get_switch_exist(arg_switch) return process.argv.includes(arg_switch); } -function create_backup_file(src, dest) -{ - try - { - fs.copyFileSync(src, dest); - } - catch(e) - { - if(e.code !== "ENOENT") throw e; - fs.writeFileSync(dest, ""); - } -} - -function create_diff_file(in1, in2, out) -{ - const diff = child_process.spawnSync("git", ["diff", "--no-index", in1, in2]).stdout; - fs.writeFileSync(out, diff); -} - -function finalize_table(out_dir, name, contents) -{ - const file_path = path.join(out_dir, `${name}.c`); - const backup_file_path = path.join(out_dir, `${name}.c.bak`); - const diff_file_path = path.join(out_dir, `${name}.c.diff`); - - create_backup_file(file_path, backup_file_path); - fs.writeFileSync(file_path, contents); - create_diff_file(backup_file_path, file_path, diff_file_path); - - console.log(CYAN_FMT, `[+] Wrote table ${name}. Remember to check ${diff_file_path}`); -} - function finalize_table_rust(out_dir, name, contents) { const file_path = path.join(out_dir, name); - fs.writeFileSync(file_path, contents); - console.log(CYAN_FMT, `[+] Wrote table ${name}.`); } @@ -88,6 +50,5 @@ module.exports = { mkdirpSync, get_switch_value, get_switch_exist, - finalize_table, finalize_table_rust, };