mirror of
https://github.com/google/blockly.git
synced 2026-01-08 01:20:12 +01:00
Advanced compilation gulp script to replace the shell script. (#3996)
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -10,6 +10,7 @@ build-debug.log
|
|||||||
/nbproject/private/
|
/nbproject/private/
|
||||||
|
|
||||||
tests/compile/main_compressed.js
|
tests/compile/main_compressed.js
|
||||||
|
tests/compile/main_compressed.js.map
|
||||||
tests/compile/*compiler*.jar
|
tests/compile/*compiler*.jar
|
||||||
tests/screenshot/outputs/*
|
tests/screenshot/outputs/*
|
||||||
local_build/*compiler*.jar
|
local_build/*compiler*.jar
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ module.exports = {
|
|||||||
buildUncompressed: buildTasks.uncompressed,
|
buildUncompressed: buildTasks.uncompressed,
|
||||||
buildCompressed: buildTasks.compressed,
|
buildCompressed: buildTasks.compressed,
|
||||||
buildGenerators: buildTasks.generators,
|
buildGenerators: buildTasks.generators,
|
||||||
|
buildAdvancedCompilationTest: buildTasks.advancedCompilationTest,
|
||||||
gitSyncDevelop: gitTasks.syncDevelop,
|
gitSyncDevelop: gitTasks.syncDevelop,
|
||||||
gitSyncMaster: gitTasks.syncMaster,
|
gitSyncMaster: gitTasks.syncMaster,
|
||||||
gitCreateRC: gitTasks.createRC,
|
gitCreateRC: gitTasks.createRC,
|
||||||
|
|||||||
@@ -38,6 +38,7 @@
|
|||||||
"test:run": "tests/run_all_tests.sh",
|
"test:run": "tests/run_all_tests.sh",
|
||||||
"test:setupselenium": "selenium-standalone install --config=./tests/scripts/selenium-config.js",
|
"test:setupselenium": "selenium-standalone install --config=./tests/scripts/selenium-config.js",
|
||||||
"test:startselenium": "selenium-standalone start --config=./tests/scripts/selenium-config.js",
|
"test:startselenium": "selenium-standalone start --config=./tests/scripts/selenium-config.js",
|
||||||
|
"test:compile:advanced": "gulp buildAdvancedCompilationTest",
|
||||||
"typings": "gulp typings",
|
"typings": "gulp typings",
|
||||||
"updateGithubPages": "gulp gitUpdateGithubPages"
|
"updateGithubPages": "gulp gitUpdateGithubPages"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -109,21 +109,20 @@ var JSCOMP_ERROR = [
|
|||||||
* as errors.
|
* as errors.
|
||||||
*/
|
*/
|
||||||
function compile(compilerOptions, opt_verbose, opt_warnings_as_error) {
|
function compile(compilerOptions, opt_verbose, opt_warnings_as_error) {
|
||||||
compilerOptions = compilerOptions || {};
|
const options = {};
|
||||||
compilerOptions.compilation_level = 'SIMPLE_OPTIMIZATIONS';
|
options.compilation_level = 'SIMPLE_OPTIMIZATIONS';
|
||||||
compilerOptions.warning_level = opt_verbose ? 'VERBOSE' : 'DEFAULT';
|
options.warning_level = opt_verbose ? 'VERBOSE' : 'DEFAULT';
|
||||||
compilerOptions.language_in =
|
options.language_in = 'ECMASCRIPT5_STRICT';
|
||||||
compilerOptions.language_in || 'ECMASCRIPT5_STRICT';
|
options.language_out = 'ECMASCRIPT5_STRICT';
|
||||||
compilerOptions.language_out = 'ECMASCRIPT5_STRICT';
|
options.rewrite_polyfills = false;
|
||||||
compilerOptions.rewrite_polyfills = false;
|
options.hide_warnings_for = 'node_modules';
|
||||||
compilerOptions.hide_warnings_for = 'node_modules';
|
|
||||||
if (opt_warnings_as_error) {
|
if (opt_warnings_as_error) {
|
||||||
compilerOptions.jscomp_error = JSCOMP_ERROR;
|
options.jscomp_error = JSCOMP_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
const platform = ['native', 'java', 'javascript'];
|
const platform = ['native', 'java', 'javascript'];
|
||||||
|
|
||||||
return closureCompiler(compilerOptions, { platform });
|
return closureCompiler({...options, ...compilerOptions}, { platform });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -431,6 +430,53 @@ function buildLangfiles(done) {
|
|||||||
done();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This task builds Blockly core, blocks and generators together and uses
|
||||||
|
* closure compiler's ADVANCED_COMPILATION mode.
|
||||||
|
*/
|
||||||
|
function buildAdvancedCompilationTest() {
|
||||||
|
const srcs = [
|
||||||
|
'tests/compile/main.js',
|
||||||
|
'tests/blocks/test_blocks.js',
|
||||||
|
'core/**/**/*.js',
|
||||||
|
'blocks/*.js',
|
||||||
|
'generators/**/*.js'];
|
||||||
|
return gulp.src(maybeAddClosureLibrary(srcs), {base: './'})
|
||||||
|
.pipe(stripApacheLicense())
|
||||||
|
.pipe(gulp.sourcemaps.init())
|
||||||
|
// Directories in Blockly are used to group similar files together
|
||||||
|
// but are not used to limit access with @package, instead the
|
||||||
|
// method means something is internal to Blockly and not a public
|
||||||
|
// API.
|
||||||
|
// Flatten all files so they're in the same directory, but ensure that
|
||||||
|
// files with the same name don't conflict.
|
||||||
|
.pipe(gulp.rename(function (p) {
|
||||||
|
if (p.dirname.indexOf('core') === 0) {
|
||||||
|
var dirname = p.dirname.replace(
|
||||||
|
new RegExp(path.sep.replace(/\\/, '\\\\'), "g"), "-");
|
||||||
|
p.dirname = "";
|
||||||
|
p.basename = dirname + "-" + p.basename;
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
.pipe(compile({
|
||||||
|
dependency_mode: 'PRUNE',
|
||||||
|
compilation_level: 'ADVANCED_OPTIMIZATIONS',
|
||||||
|
entry_point: './tests/compile/main.js',
|
||||||
|
js_output_file: 'main_compressed.js',
|
||||||
|
externs: ['./externs/svg-externs.js', './externs/goog-externs.js'],
|
||||||
|
language_in:
|
||||||
|
argv.closureLibrary ? 'ECMASCRIPT_2015' : 'ECMASCRIPT5_STRICT'
|
||||||
|
}, argv.verbose, argv.strict))
|
||||||
|
.pipe(gulp.sourcemaps.mapSources(function (sourcePath, file) {
|
||||||
|
return sourcePath.replace(/-/g, '/');
|
||||||
|
}))
|
||||||
|
.pipe(gulp.sourcemaps.write('.', {
|
||||||
|
includeContent: false,
|
||||||
|
sourceRoot: '../../'
|
||||||
|
}))
|
||||||
|
.pipe(gulp.dest('./tests/compile/'));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This tasks builds Blockly's core files:
|
* This tasks builds Blockly's core files:
|
||||||
* blockly_compressed.js
|
* blockly_compressed.js
|
||||||
@@ -469,4 +515,5 @@ module.exports = {
|
|||||||
uncompressed: buildUncompressed,
|
uncompressed: buildUncompressed,
|
||||||
compressed: buildCompressed,
|
compressed: buildCompressed,
|
||||||
generators: buildGenerators,
|
generators: buildGenerators,
|
||||||
|
advancedCompilationTest: buildAdvancedCompilationTest,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user