-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwasmc.js
61 lines (51 loc) · 1.14 KB
/
wasmc.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
const DEBUG = false
// const DEBUG = true
const SIMD = false
// const SIMD = true
const FLAGS = ['-std=c++11', '-flto', '-s ALLOW_MEMORY_GROWTH=1', '-s MALLOC=emmalloc']
if (!DEBUG) {
FLAGS.push('-O3')
FLAGS.push('-fno-rtti')
FLAGS.push('-fno-exceptions')
} else {
FLAGS.push('-O0')
FLAGS.push('--profiling')
}
if (SIMD) {
FLAGS.push('-msimd128')
}
// Add include for submodules.
//
// IMPORTANT: For wasmc, the __dirname is mounted to /src for Docker.
const CFLAGS = ['-I/src/third_party/geometry.hpp/include']
const LFLAGS = ['-lm']
// Reference:
// https://github.com/rsms/js-wasmc
const common = {
jsentry: 'src/index.js',
sources: ['src/*.cpp', 'third_party/martinez/*.cpp'],
cflags: [...FLAGS, ...CFLAGS],
lflags: [...FLAGS, ...LFLAGS],
}
// Available as window.astro
module({
...common,
name: 'astro',
out: 'dist/astro.js',
})
// ES module.
module({
...common,
name: 'astro-es',
out: 'dist/astro.es.js',
outwasm: 'dist/astro.wasm',
format: 'es',
})
// Node.js
module({
...common,
name: 'astro-node',
out: 'dist/astro.node.js',
target: 'node',
embed: true,
})