-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
34 lines (34 loc) · 1.47 KB
/
gulpfile.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
// Generated by LiveScript 1.5.0
/**
* @package blake2.wasm
* @author Nazar Mokrynskyi <nazar@mokrynskyi.com>
* @license 0BSD
*/
(function(){
var exec, glob, gulp, rename, uglify;
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', function(callback){
var functions, optimize, clang_opts, command;
functions = JSON.stringify(['_malloc', '_free', '_blake2b_init_key', '_blake2b_init', '_blake2b_update', '_blake2b_final', '_blake2s_init_key', '_blake2s_init', '_blake2s_update', '_blake2s_final']);
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 vendor/ref/blake2b-ref.c vendor/ref/blake2s-ref.c --post-js src/bytes_allocation.js -o src/blake2.js -s MODULARIZE=1 -s 'EXPORT_NAME=\"__blake2_wasm\"' -s EXPORTED_FUNCTIONS='" + functions + "' -s WASM=1 " + optimize;
exec(command, function(error, stdout, stderr){
if (stdout) {
console.log(stdout);
}
if (stderr) {
console.error(stderr);
}
callback(error);
});
}).task('minify', function(){
return gulp.src("src/index.js").pipe(uglify()).pipe(rename({
suffix: '.min'
})).pipe(gulp.dest('src'));
});
}).call(this);