Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b348e18
Don't use path.join to create globs for gulp.src
cpcallen Jun 21, 2021
082fd1f
Move build and package directory config into new config.js
cpcallen Jun 18, 2021
4111073
Write build output to built/ instead of repository root
cpcallen Jun 18, 2021
a03cd29
Separate script to rebuild msg/json/en.json, qqq.json etc.
cpcallen Jun 18, 2021
25f073d
Build msg/js/*.js langfiles in BUILD_DIR
cpcallen Jun 22, 2021
e2c4a9b
Script to copy built files from BUILD_DIR to repository
cpcallen Jun 22, 2021
961319b
Script to clean build directory
cpcallen Jun 22, 2021
e8eb30f
Script to clean release directory
cpcallen Jun 23, 2021
c521fa9
Fix release process
cpcallen Jun 23, 2021
daab45f
Fix eslint tests
cpcallen Jun 24, 2021
96da5ed
Fix metadata tests
cpcallen Jun 24, 2021
1aa35ef
Merge branch 'develop' into build-elsewhere
cpcallen Jun 29, 2021
37ecce8
Have npm run typings use built directory; fix typescript tests
cpcallen Jun 29, 2021
5410ba6
Do trivial gulp tasks in parallel where possible
cpcallen Jun 30, 2021
c265eb8
Update metadata sizes for Q2 2021 release
cpcallen Jul 2, 2021
e6929de
Also check in sourcemaps
cpcallen Jul 7, 2021
ec14cc3
Package build output; fix node tests.
cpcallen Jul 7, 2021
311b2c1
Rename BUILD_DIR to "build" (was "built")
cpcallen Jul 8, 2021
1e4fa80
Fix comment TODO formatting.
cpcallen Jul 8, 2021
9e72378
Finish renaming BUILD_DIR; make tests more error-prone
cpcallen Jul 9, 2021
ffd0252
Merge branch 'develop' into build-elsewhere
cpcallen Jul 9, 2021
c45929d
Rename internal recompile function to rebuildAll
cpcallen Jul 9, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ local_build/*compiler*.jar
local_build/local_*_compressed.js
chromedriver
typings/tmp/*
build/
dist/
7 changes: 7 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var cleanupTasks = require('./scripts/gulpfiles/cleanup_tasks');
module.exports = {
deployDemos: appengineTasks.deployDemos,
default: buildTasks.build,
generateLangfiles: buildTasks.generateLangfiles,
build: buildTasks.build,
buildCore: buildTasks.core,
buildBlocks: buildTasks.blocks,
Expand All @@ -31,11 +32,17 @@ module.exports = {
buildCompressed: buildTasks.compressed,
buildGenerators: buildTasks.generators,
buildAdvancedCompilationTest: buildTasks.advancedCompilationTest,
checkin: gulp.parallel(buildTasks.checkinBuilt, typings.checkinTypings),
checkinBuilt: buildTasks.checkinBuilt,
clean: gulp.parallel(buildTasks.cleanBuildDir, packageTasks.cleanReleaseDir),
cleanBuildDir: buildTasks.cleanBuildDir,
cleanReleaseDir: packageTasks.cleanReleaseDir,
gitSyncDevelop: gitTasks.syncDevelop,
gitSyncMaster: gitTasks.syncMaster,
gitCreateRC: gitTasks.createRC,
gitUpdateGithubPages: gitTasks.updateGithubPages,
typings: gulp.series(typings.typings, typings.msgTypings),
checkinTypings: typings.checkinTypings,
package: packageTasks.package,
checkLicenses: licenseTasks.checkLicenses,
recompile: releaseTasks.recompile,
Expand Down
12 changes: 7 additions & 5 deletions msg/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
* @fileoverview English strings.
* @author fraser@google.com (Neil Fraser)
*
* After modifying this file, either run "npm run build:langfiles" from the
* parent directory, or run (from this directory):
* ../scripts/i18n/js_to_json.py
* to regenerate json/{en,qqq,synonyms}.json.
* After modifying this file, run:
*
* npm run generate:langfiles
*
* to regenerate json/{en,qqq,constants,synonyms}.json.
*
* To convert all of the json files to .js files, run:
* ../scripts/i18n/create_messages.py json/*.json
*
* npm run build:langfiles
*/
'use strict';

Expand Down
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,19 @@
"build:langfiles": "gulp buildLangfiles",
"build:uncompressed": "gulp buildUncompressed",
"bump": "npm --no-git-tag-version version 4.$(date +'%Y%m%d').0",
"clean": "gulp clean",
"clean:build": "gulp cleanBuildDir",
"clean:release": "gulp cleanReleaseDir",
"checkin": "gulp checkin",
"checkin:built": "gulp checkinBuilt",
"checkin:typings": "gulp checkinTypings",
"deployDemos": "gulp deployDemos",
"format": "git-clang-format",
"format:sortrequires": "gulp sortRequires",
"generate:langfiles": "gulp generateLangfiles",
"license": "gulp checkLicenses",
"lint": "eslint .",
"package": "gulp package",
"prepare": "npm run package",
"prepareDemos": "gulp prepareDemos",
"publish": "gulp publish",
"publish:beta": "gulp publishBeta",
Expand Down
4 changes: 2 additions & 2 deletions scripts/gulpfiles/appengine_tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ function copyStaticSrc(done) {
*/
function copyAppengineSrc() {
const appengineSrc = [
path.join(demoStaticTmpDir, 'appengine/**/*'),
path.join(demoStaticTmpDir, 'appengine/.gcloudignore'),
`${demoStaticTmpDir}/appengine/**/*`,
`${demoStaticTmpDir}/appengine/.gcloudignore`,
];
return gulp.src(appengineSrc).pipe(gulp.dest(demoTmpDir));
}
Expand Down
87 changes: 72 additions & 15 deletions scripts/gulpfiles/build_tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ var through2 = require('through2');
var closureCompiler = require('google-closure-compiler').gulp();
var closureDeps = require('google-closure-deps');
var argv = require('yargs').argv;
var { getPackageJson } = require('./helper_tasks');
var rimraf = require('rimraf');

var {BUILD_DIR} = require('./config');
var {getPackageJson} = require('./helper_tasks');

////////////////////////////////////////////////////////////
// Build //
Expand Down Expand Up @@ -217,7 +219,7 @@ function buildCompressed() {
}))
.pipe(
gulp.sourcemaps.write('.', {includeContent: false, sourceRoot: './'}))
.pipe(gulp.dest('./'));
.pipe(gulp.dest(BUILD_DIR));
};

/**
Expand All @@ -242,7 +244,7 @@ function buildBlocks() {
includeContent: false,
sourceRoot: './'
}))
.pipe(gulp.dest('./'));
.pipe(gulp.dest(BUILD_DIR));
};

/**
Expand All @@ -268,7 +270,7 @@ function buildGenerator(language, namespace) {
includeContent: false,
sourceRoot: './'
}))
.pipe(gulp.dest('./'));
.pipe(gulp.dest(BUILD_DIR));
};

/**
Expand Down Expand Up @@ -409,30 +411,58 @@ goog.require('Blockly.requires');
};

/**
* This task builds Blockly's lang files.
* msg/*.js
* This task regenrates msg/json/en.js and msg/json/qqq.js from
* msg/messages.js.
*/
function buildLangfiles(done) {
function generateLangfiles(done) {
// Run js_to_json.py
const jsToJsonCmd = `python ./scripts/i18n/js_to_json.py \
--input_file ${path.join('msg', 'messages.js')} \
--output_dir ${path.join('msg', 'json')} \
--quiet`;
const jsToJsonCmd = `python scripts/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
console.log(`
Regenerated several flies in msg/json/. Now run

git diff msg/json/*.json

and check that operation has not overwritten any modifications made to
hints, etc. by the TranslateWiki volunteers. If it has, backport
their changes to msg/messages.js and re-run 'npm run generate:langfiles'.

Once you are satisfied that any new hints have been backported you may
go ahead and commit the changes, but note that the generate script
will have removed the translator credits - be careful not to commit
this removal!
`);

done();
};

/**
* This task builds Blockly's lang files.
* msg/*.js
*/
function buildLangfiles(done) {
// Create output directory.
// TODO(#5000): does mkidr -p work on Windows?
const outputDir = path.join(BUILD_DIR, 'msg', 'js');
execSync(`mkdir -p ${outputDir}`, {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)));
!(new RegExp(/(keys|synonyms|qqq|constants)\.json$/).test(file)));
json_files = json_files.map(file => path.join('msg', 'json', file));
const createMessagesCmd = `python ./scripts/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')} \
--output_dir ${outputDir} \
--quiet ${json_files.join(' ')}`;
execSync(createMessagesCmd, { stdio: 'inherit' });
execSync(createMessagesCmd, {stdio: 'inherit'});

done();
};
Expand Down Expand Up @@ -510,13 +540,40 @@ const build = gulp.parallel(
buildLangfiles
);

/**
* This task copies built files from BUILD_DIR back to the repository
* so they can be committed to git.
*/
function checkinBuilt() {
return gulp.src([
`${BUILD_DIR}/**.js`,
`${BUILD_DIR}/**.js.map`,
`${BUILD_DIR}/**/**.js`,
`${BUILD_DIR}/**/**.js.map`,
]).pipe(gulp.dest('.'));
};

/**
* This task cleans the build directory (by deleting it).
*/
function cleanBuildDir(done) {
// Sanity check.
if (BUILD_DIR === '.' || BUILD_DIR === '/') {
throw new Error(`Refusing to rm -rf ${BUILD_DIR}`);
}
rimraf(BUILD_DIR, done);
}

module.exports = {
build: build,
core: buildCore,
blocks: buildBlocks,
generateLangfiles: generateLangfiles,
langfiles: buildLangfiles,
uncompressed: buildUncompressed,
compressed: buildCompressed,
generators: buildGenerators,
checkinBuilt: checkinBuilt,
cleanBuildDir: cleanBuildDir,
advancedCompilationTest: buildAdvancedCompilationTest,
}
28 changes: 28 additions & 0 deletions scripts/gulpfiles/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* @license
* Copyright 2021 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/

/**
* @fileoverview Common configuration for Gulp scripts.
*/

var path = require('path');

// Paths are all relative to the repository root. Do not include
// trailing slash.
//
// TODO(#5007): If you modify these values, you must also modify the
// corresponding values in the following files:
//
// - tests/scripts/compile_typings.sh
// - tests/scripts/check_metadata.sh
module.exports = {
// Directory to write compiled output to.
BUILD_DIR: 'build',

// Directory in which to assemble (and from which to publish) the
// blockly npm package.
RELEASE_DIR: 'dist',
};
2 changes: 2 additions & 0 deletions scripts/gulpfiles/git_tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ const updateGithubPages = gulp.series(
execSync('git reset --hard upstream/develop', { stdio: 'inherit' });
done();
},
buildTasks.cleanBuildDir,
buildTasks.build,
buildTasks.checkinBuilt,
function(done) {
execSync('git commit -am "Rebuild"', { stdio: 'inherit' });
execSync('git push ' + upstream_url + ' gh-pages --force', { stdio: 'inherit' });
Expand Down
Loading