-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathbuild.js
87 lines (72 loc) · 2.36 KB
/
build.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
(function () {
"use strict";
var files = [
// Real Entry Point
"./src/emscripten/VBA.cpp",
// Driver classes
"./src/emscripten/EmscriptenSoundDriver.cpp",
// Util
"./src/Util.cpp",
// Settings File
"./src/common/ConfigManager.cpp",
// APU files
"./src/apu/Blip_Buffer.cpp",
"./src/apu/Effects_Buffer.cpp",
"./src/apu/Gb_Apu.cpp",
"./src/apu/Gb_Apu_State.cpp",
"./src/apu/Gb_Oscs.cpp",
"./src/apu/Multi_Buffer.cpp",
// GBA Files
"./src/gba/bios.cpp",
"./src/gba/EEprom.cpp",
"./src/gba/Flash.cpp",
"./src/gba/GBA.cpp",
"./src/gba/GBA-arm.cpp",
"./src/gba/GBA-thumb.cpp",
"./src/gba/GBAGfx.cpp",
"./src/gba/GBALink.cpp",
"./src/gba/GBASockClient.cpp",
"./src/gba/Globals.cpp",
"./src/gba/Mode0.cpp",
"./src/gba/Mode1.cpp",
"./src/gba/Mode2.cpp",
"./src/gba/Mode3.cpp",
"./src/gba/Mode4.cpp",
"./src/gba/Mode5.cpp",
"./src/gba/RTC.cpp",
"./src/gba/Sound.cpp",
"./src/gba/Sram.cpp",
"./src/gba/ereader.cpp",
"./src/gba/agbprint.cpp",
];
var opt = require("yargs").argv.opt;
var MB = Math.pow(2, 20);
var options = [
"--memory-init-file 0",
"-Werror",
opt ? "--closure 1" : "",
opt ? "-O3" : "-g3",
"-DC_CORE",
"-DNO_PNG",
"-DNO_LINK",
"-DNO_DEBUGGER",
"-DFINAL_BUILD",
"-DFINAL_VERSION",
"-s MODULARIZE=1",
"-s EXPORT_NAME=\"'gbaninja'\"",
opt ? "" : "-s ASSERTIONS=2",
"-s NO_FILESYSTEM=1",
"-s NO_EXIT_RUNTIME=1",
"-s \"EXTRA_EXPORTED_RUNTIME_METHODS=['ccall']\"",
"-s TOTAL_MEMORY=" + (80 * MB),
].filter(function (v) {return v;}).join(" ");
function fix (file) {
let str = require("fs").readFileSync(file).toString()
.replace(/require\('fs'\)/g, "(function () { throw new Error('cant use fs in browser')}())");
require("fs").writeFileSync(file, str);
}
let command = `emcc ${options} ${files.join(" ")} -o ./build/emu.js`;
console.log(command);
require("child_process").execSync(command);
fix("./build/emu.js");
}());