forked from scratchfoundation/scratch-flash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
82 lines (69 loc) · 2.02 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
var childProcess = require('child_process');
var path = require('path');
var flexSdk = require('flex-sdk');
var binPath = flexSdk.bin.mxmlc;
// Source locations for Scratch and the 3D rendering library
var proj_dir = path.normalize(__dirname)
var src_dir = path.join(proj_dir, 'src');
var src_dir_3d = path.join(proj_dir, '3d_render_src');
// Where to find libraries to link into Scratch
var libs_dir = path.join(proj_dir, 'libs');
// Where to put the built SWF
var deploy_dir = path.join(proj_dir, 'bin');
function errorCheckThen(nextCall) {
return function(err, stdout, stderr) {
if (err) {
console.log(err);
process.exit(1);
} else {
nextCall();
}
};
}
function compile(src, dest, callback, lib_paths, extra_args) {
var args = [
'-output', dest,
'-debug=true',
'-accessible'
];
if(lib_paths) {
lib_paths.forEach(function(lib_path){
args.push('-library-path+='+lib_path);
});
}
args.push(src);
if(extra_args) {
args = args.concat(extra_args);
}
childProcess.execFile(binPath, args, callback);
}
var src = path.join(src_dir, 'Scratch.as');
var libs = [
path.join(libs_dir, 'blooddy_crypto.swc'),
flexSdk.FLEX_HOME+'/frameworks/libs/framework.swc'
];
function compileWith3D(callback) {
compile(src, path.join(deploy_dir, 'Scratch.swf'), callback, libs, [
'-target-player=11.4',
'-swf-version=17',
'-define=SCRATCH::allow3d,true',
'-static-link-runtime-shared-libraries=true'
]);
}
function compileWithout3D(callback) {
compile(src, path.join(deploy_dir, 'ScratchFor10.2.swf'), callback, libs, [
'-target-player=10.2',
'-swf-version=11',
'-define=SCRATCH::allow3d,false',
'-static-link-runtime-shared-libraries=true'
]);
}
compileWith3D(
errorCheckThen(function() {
compileWithout3D(
errorCheckThen(function() {
process.exit(0);
})
)
})
);