-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.ls
41 lines (39 loc) · 1.17 KB
/
gulpfile.ls
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
/**
* @package aez.wasm
* @author Nazar Mokrynskyi <nazar@mokrynskyi.com>
* @license 0BSD
*/
exec = require('child_process').exec
glob = require('glob')
gulp = require('gulp')
rename = require('gulp-rename')
uglify = require('gulp-uglify')
gulp
.task('build', ['wasm', 'minify'])
.task('wasm', (callback) !->
functions = JSON.stringify([
'_malloc'
'_free'
'_aez_encrypt'
'_aez_decrypt'
])
# Options that are only specified to optimize resulting file size and basically remove unused features
optimize = "-Oz --llvm-lto 1 --closure 1 -s NO_EXIT_RUNTIME=1 -s NO_FILESYSTEM=1 -s EXPORTED_RUNTIME_METHODS=[] -s DEFAULT_LIBRARY_FUNCS_TO_INCLUDE=[]"
clang_opts = "-I src"
command = "EMMAKEN_CFLAGS='#clang_opts' emcc src/aez.c --post-js src/bytes_allocation.js -o src/aez.js -s MODULARIZE=1 -s 'EXPORT_NAME=\"__aez_wasm\"' -s EXPORTED_FUNCTIONS='#functions' -s WASM=1 #optimize"
exec(command, (error, stdout, stderr) !->
if stdout
console.log(stdout)
if stderr
console.error(stderr)
callback(error)
)
)
.task('minify', ->
gulp.src("src/index.js")
.pipe(uglify())
.pipe(rename(
suffix: '.min'
))
.pipe(gulp.dest('src'))
)