mirror of
https://github.com/google/blockly.git
synced 2026-01-08 01:20:12 +01:00
Add langfiles build task in gulp (#3331)
* Add build-langfiles to gulp, and add uncompressed + langfiles to build when building all
This commit is contained in:
44
gulpfile.js
44
gulpfile.js
@@ -238,7 +238,7 @@ gulp.task('build-dart', function() {
|
||||
* blockly_uncompressed.js
|
||||
*/
|
||||
gulp.task('build-uncompressed', function() {
|
||||
const header = `// Do not edit this file; automatically generated by build.py.
|
||||
const header = `// Do not edit this file; automatically generated by gulp.
|
||||
'use strict';
|
||||
|
||||
this.IS_NODE_JS = !!(typeof module !== 'undefined' && module.exports);
|
||||
@@ -272,9 +272,6 @@ if (this.IS_NODE_JS) {
|
||||
this.BLOCKLY_BOOT(this);
|
||||
module.exports = Blockly;
|
||||
} else {
|
||||
// Delete any existing Closure (e.g. Soy's nogoog_shim).
|
||||
document.write('<script>var goog = undefined;</script>');
|
||||
// Load fresh Closure Library.
|
||||
document.write('<script src="' + this.BLOCKLY_DIR +
|
||||
'/closure/goog/base.js"></script>');
|
||||
document.write('<script>this.BLOCKLY_BOOT(this);</script>');
|
||||
@@ -286,13 +283,15 @@ if (this.IS_NODE_JS) {
|
||||
--root_with_prefix="./core ../core" > ${file}`;
|
||||
execSync(cmd, { stdio: 'inherit' });
|
||||
|
||||
const requires = `\n// Load Blockly.\ngoog.require('Blockly.requires');\n`;
|
||||
const requires = `goog.addDependency("base.js", [], []);\n\n// Load Blockly.\ngoog.require('Blockly.requires')\n`;
|
||||
|
||||
return gulp.src(file)
|
||||
// Remove comments so we're compatible with the build.py script
|
||||
.pipe(gulp.replace(/\/\/.*\n/gm, ''))
|
||||
// Replace quotes to be compatible with build.py
|
||||
.pipe(gulp.replace(/\'(.*\.js)\'/gm, '"$1"'))
|
||||
// Remove last parameter to be compatible with build.py
|
||||
.pipe(gulp.replace(/, \{\}\);/gm, ');'))
|
||||
// Find the Blockly directory name and replace it with a JS variable.
|
||||
// This allows blockly_uncompressed.js to be compiled on one computer and be
|
||||
// used on another, even if the directory name differs.
|
||||
@@ -301,6 +300,35 @@ if (this.IS_NODE_JS) {
|
||||
.pipe(gulp.dest('./'));
|
||||
});
|
||||
|
||||
/**
|
||||
* This task builds Blockly's lang files.
|
||||
* msg/*.js
|
||||
*/
|
||||
gulp.task('build-langfiles', function(done) {
|
||||
// Run js_to_json.py
|
||||
const jsToJsonCmd = `python ./i18n/js_to_json.py \
|
||||
--input_file ${path.join('msg', 'messages.js')} \
|
||||
--output_dir ${path.join('msg', 'json')} \
|
||||
--quiet`;
|
||||
execSync(jsToJsonCmd, { stdio: 'inherit' });
|
||||
|
||||
// Run create_messages.py
|
||||
let json_files = fs.readdirSync(path.join('msg', 'json'));
|
||||
json_files = json_files.filter(file => file.endsWith('json') &&
|
||||
!(new RegExp(/(keys|synonyms|qqq|constants)\.json$/).test(file)));
|
||||
json_files = json_files.map(file => path.join('msg', 'json', file));
|
||||
const createMessagesCmd = `python ./i18n/create_messages.py \
|
||||
--source_lang_file ${path.join('msg', 'json', 'en.json')} \
|
||||
--source_synonym_file ${path.join('msg', 'json', 'synonyms.json')} \
|
||||
--source_constants_file ${path.join('msg', 'json', 'constants.json')} \
|
||||
--key_file ${path.join('msg', 'json', 'keys.json')} \
|
||||
--output_dir ${path.join('msg', 'js')} \
|
||||
--quiet ${json_files.join(' ')}`;
|
||||
execSync(createMessagesCmd, { stdio: 'inherit' });
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
/**
|
||||
* This task builds all of Blockly:
|
||||
* blockly_compressed.js
|
||||
@@ -310,6 +338,8 @@ if (this.IS_NODE_JS) {
|
||||
* php_compressed.js
|
||||
* lua_compressed.js
|
||||
* dart_compressed.js
|
||||
* blockly_uncompressed.js
|
||||
* msg/json/*.js
|
||||
*/
|
||||
gulp.task('build', gulp.parallel(
|
||||
'build-core',
|
||||
@@ -318,7 +348,9 @@ gulp.task('build', gulp.parallel(
|
||||
'build-python',
|
||||
'build-php',
|
||||
'build-lua',
|
||||
'build-dart'
|
||||
'build-dart',
|
||||
'build-uncompressed',
|
||||
'build-langfiles'
|
||||
));
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -18,7 +18,11 @@
|
||||
},
|
||||
"scripts": {
|
||||
"build": "gulp build",
|
||||
"build:blocks": "gulp build-blocks",
|
||||
"build:core": "gulp build-core",
|
||||
"build:debug": "gulp build-core --verbose > build-debug.log 2>&1 && tail -3 -r build-debug.log",
|
||||
"build:langfiles": "gulp build-langfiles",
|
||||
"build:uncompressed": "gulp build-uncompressed",
|
||||
"bump": "npm version 3.$(date +'%Y%m%d').0",
|
||||
"lint": "eslint .",
|
||||
"package": "gulp package",
|
||||
|
||||
Reference in New Issue
Block a user