[Libreoffice-commits] online.git: 4 commits - loleaflet/build loleaflet/Jakefile.js loleaflet/Makefile loleaflet/plugins
Pranav Kant
pranavk at collabora.co.uk
Fri Dec 9 14:40:31 UTC 2016
loleaflet/Jakefile.js | 80 +++++++++++++++++++++-------
loleaflet/Makefile | 5 -
loleaflet/build/build.js | 77 +++++++++++++++++++++-----
loleaflet/plugins/draw-0.2.4/build/build.js | 8 +-
4 files changed, 127 insertions(+), 43 deletions(-)
New commits:
commit e845bdfbe5af6c0dc644f434e139cef4f4b650dc
Author: Pranav Kant <pranavk at collabora.co.uk>
Date: Fri Dec 9 20:08:58 2016 +0530
loleaflet: build: Pass debug, minify variables as env. vars
Change-Id: I500b49f50901a72a93caa5cce1f50a2c2e3d0613
diff --git a/loleaflet/Makefile b/loleaflet/Makefile
index 218eaff..9bb26f1 100644
--- a/loleaflet/Makefile
+++ b/loleaflet/Makefile
@@ -16,7 +16,7 @@ build:
npm install
rm -rf dist/plugins/draw-$(DRAW_VERSION) && mkdir -p dist/plugins/draw-$(DRAW_VERSION)
cd plugins/draw-$(DRAW_VERSION) && jake build && cp -ar dist ../../dist/plugins/draw-$(DRAW_VERSION)
- jake build
+ jake build debug=$(DEBUG) minify=$(MINIFY)
.PHONY: build-l10n
build-l10n:
commit c4fe26e1db947c38974636b2d0b630559ede36dd
Author: Pranav Kant <pranavk at collabora.co.uk>
Date: Fri Dec 9 20:06:45 2016 +0530
loleaflet: build: better log messages
Change-Id: I10c1cacebc542c6a1234603a264f2dbd5381c015
diff --git a/loleaflet/Jakefile.js b/loleaflet/Jakefile.js
index a5c30dc..d7ba999 100644
--- a/loleaflet/Jakefile.js
+++ b/loleaflet/Jakefile.js
@@ -63,20 +63,20 @@ file('dist/admin/admin-src.js', build.getAdminFiles(), {async: true}, function()
});
desc('Create final bundled js file to be used by main lool editor');
-file('dist/bundle.js', build.getBundleFiles(), {async: true}, function(debug, minify) {
- debug = debug === 'true';
- minify = minify === 'true';
+file('dist/bundle.js', build.getBundleFiles(), {async: true}, function() {
+ var debug = process.env.debug === 'true';
+ var minify = process.env.minify === 'true';
- console.log('Creating bundle.js ...');
+ console.log('Creating bundle.js (debug=' + debug +', minify=' + minify + ') ...');
build.bundle(debug, minify, complete);
});
desc('Create final bundle js file to be used by admin console');
-file('dist/admin-bundle.js', build.getAdminBundleFiles(), {async: true}, function(debug, minify) {
- debug = debug === 'true';
- minify = minify === 'true';
+file('dist/admin-bundle.js', build.getAdminBundleFiles(), {async: true}, function() {
+ var debug = process.env.debug === 'true';
+ var minify = process.env.minify === 'true';
- console.log('Creating admin-bundle.js ...');
+ console.log('Creating admin-bundle.js (debug=' + debug +', minify=' + minify + ') ...');
build.bundleAdmin(debug, minify, complete);
});
commit ab9d744fe53a620f627d970386cc5b5b626d6e23
Author: Pranav Kant <pranavk at collabora.co.uk>
Date: Fri Dec 9 18:06:53 2016 +0530
loleaflet: Improved build process, don't build unnecessarily
No point in building things that are already built, create
different jake tasks, enclose whole of the build process in a
single jake task - 'build' which would call other various tasks
depending on whether they needs building.
Change-Id: I4b26834440ef638d697aa0793d2ced1e2c49784a
diff --git a/loleaflet/Jakefile.js b/loleaflet/Jakefile.js
index 8d60824..a5c30dc 100644
--- a/loleaflet/Jakefile.js
+++ b/loleaflet/Jakefile.js
@@ -19,7 +19,7 @@ function hint(msg, args) {
return function () {
console.log(msg);
jake.exec('node node_modules/eslint/bin/eslint.js ' + args,
- {printStdout: true}, function () {
+ {printStdout: true}, function () {
console.log('\tCheck passed.\n');
complete();
});
@@ -29,33 +29,73 @@ function hint(msg, args) {
desc('Check Leaflet source for errors with ESLint');
task('lint', {async: true}, hint('Checking for JS errors...', 'src dist --config .eslintrc'));
+desc('Check admin source for errors with ESLint');
+task('lintadmin', {async: true}, hint('Checking for admin JS errors...', 'src/admin --config .eslintrc'));
+
desc('Check Leaflet specs source for errors with ESLint');
task('lintspec', {async: true}, hint('Checking for specs JS errors...', 'spec/suites --config spec/.eslintrc'));
-desc('Combine and compress Leaflet source files');
-task('build', {async: true}, function (compsBase32, buildName) {
- var v;
-
- jake.exec('git log -1 --pretty=format:"%h"', {breakOnError: false}, function () {
- build.build(complete, v, compsBase32, buildName);
+desc('Create a combined leaflet file');
+file('dist/leaflet-src.js', build.getFiles(), {async: true}, function() {
+ var lint = jake.Task['lint'];
+ lint.addListener('complete', function(value) {
+ var v;
+ jake.exec('git log -1 --pretty=format:"%h"', {breakOnError: false}, function () {
+ console.log('Building leaflet-src.js ...');
+ build.build(complete, v);
+ }).on('stdout', function (data) {
+ v = version + ' (' + data.toString() + ')';
+ }).on('error', function () {
+ v = version;
+ });
+ });
+ lint.invoke();
+});
- }).on('stdout', function (data) {
- v = version + ' (' + data.toString() + ')';
- }).on('error', function () {
- v = version;
+desc('Create a combined admin file');
+file('dist/admin/admin-src.js', build.getAdminFiles(), {async: true}, function() {
+ var lint = jake.Task['lintadmin'];
+ lint.addListener('complete', function(value) {
+ console.log('Building admin-src.js ...');
+ build.buildadmin(complete);
});
+ lint.invoke();
+});
+
+desc('Create final bundled js file to be used by main lool editor');
+file('dist/bundle.js', build.getBundleFiles(), {async: true}, function(debug, minify) {
+ debug = debug === 'true';
+ minify = minify === 'true';
+
+ console.log('Creating bundle.js ...');
+ build.bundle(debug, minify, complete);
});
-desc('Browserify and bundle all js and css files');
-task('bundle', {async: true}, function (type, debug, minify) {
+desc('Create final bundle js file to be used by admin console');
+file('dist/admin-bundle.js', build.getAdminBundleFiles(), {async: true}, function(debug, minify) {
debug = debug === 'true';
minify = minify === 'true';
- if (type === 'admin') {
- build.bundleAdmin(debug, minify);
- } else {
- build.bundle(debug, minify);
- }
+ console.log('Creating admin-bundle.js ...');
+ build.bundleAdmin(debug, minify, complete);
+});
+
+desc('Create final bundled JS files');
+task('build', {async: true}, function () {
+ // TODO: Build both admin-bundle and bundle parallely
+ var bundlejs = jake.Task['dist/bundle.js'];
+ bundlejs.addListener('complete', function(value) {
+ console.log('Finished building loleaflet');
+ complete();
+ });
+
+ var adminbundlejs = jake.Task['dist/admin-bundle.js'];
+ adminbundlejs.addListener('complete', function(value) {
+ console.log('Finished building admin');
+ bundlejs.invoke();
+ });
+
+ adminbundlejs.invoke();
});
desc('Run PhantomJS tests');
diff --git a/loleaflet/Makefile b/loleaflet/Makefile
index 3265cb8..218eaff 100644
--- a/loleaflet/Makefile
+++ b/loleaflet/Makefile
@@ -14,12 +14,9 @@ MINIFY=false
.PHONY: build
build:
npm install
- jake lint
- jake build
rm -rf dist/plugins/draw-$(DRAW_VERSION) && mkdir -p dist/plugins/draw-$(DRAW_VERSION)
cd plugins/draw-$(DRAW_VERSION) && jake build && cp -ar dist ../../dist/plugins/draw-$(DRAW_VERSION)
- jake bundle[,$(DEBUG),$(MINIFY)]
- jake bundle[admin,$(DEBUG),$(MINIFY)]
+ jake build
.PHONY: build-l10n
build-l10n:
diff --git a/loleaflet/build/build.js b/loleaflet/build/build.js
index f43c2c8..4165efb 100644
--- a/loleaflet/build/build.js
+++ b/loleaflet/build/build.js
@@ -8,6 +8,45 @@ var fs = require('fs'),
deps = require('./deps.js').deps,
adminDeps = require('./adminDeps.js').adminDeps;
+// TODO: Don't hardcode leaflet-draw version here
+var JSBundleFiles = [
+ 'main.js',
+ 'dist/leaflet-src.js',
+ 'dist/errormessages.js',
+ 'dist/plugins/draw-0.2.4/dist/leaflet.draw.js'
+];
+
+var CSSBundleFiles = [
+ 'main.css',
+ 'dist/leaflet.css',
+ 'dist/selectionMarkers.css',
+ 'dist/loleaflet.css',
+ 'dist/toolbar.css',
+ 'dist/partsPreviewControl.css',
+ 'dist/scrollBar.css',
+ 'dist/searchControl.css',
+ 'dist/spreadsheet.css',
+ 'plugins/draw-0.2.4/dist/leaflet.draw.css',
+ 'dist/sm-simple.css'
+];
+
+var adminBundleFiles = [
+ 'main-admin.js',
+ 'dist/admin/admin-src.js',
+ 'dist/admin/bootstrap/ie10-viewport-bug-workaround.css',
+ 'admin.strings.js',
+ 'dist/admin/bootstrap/holder.min.js',
+ 'dist/admin/bootstrap/ie10-viewport-bug-workaround.js'
+];
+
+exports.getBundleFiles = function() {
+ return JSBundleFiles.concat(CSSBundleFiles);
+};
+
+exports.getAdminBundleFiles = function() {
+ return adminBundleFiles;
+};
+
function getFiles(compsBase32) {
var memo = {},
comps;
@@ -60,6 +99,7 @@ function getAdminFiles() {
}
exports.getFiles = getFiles;
+exports.getAdminFiles = getAdminFiles;
function getSizeDelta(newContent, oldContent, fixCRLF) {
if (!oldContent) {
@@ -97,7 +137,7 @@ function bytesToKB(bytes) {
return (bytes / 1024).toFixed(2) + ' KB';
}
-function bundle(files, destFilename, debug, minify) {
+function bundle(files, destFilename, debug, minify, callback) {
var bundler = browserify(files, {debug: debug});
bundler = bundler.transform(browserifyCss);
if (minify) {
@@ -115,15 +155,16 @@ function bundle(files, destFilename, debug, minify) {
bundleFs.on('finish', function() {
console.log('Finish writing to dist/' + destFilename);
+ callback();
});
};
-exports.bundle = function(debug, minify) {
- bundle(['main.js'], 'bundle.js', debug, minify);
+exports.bundle = function(debug, minify, callback) {
+ bundle(['main.js'], 'bundle.js', debug, minify, callback);
};
-exports.bundleAdmin = function(debug, minify) {
- bundle(['main-admin.js'], 'admin-bundle.js', debug, minify);
+exports.bundleAdmin = function(debug, minify, callback) {
+ bundle(['main-admin.js'], 'admin-bundle.js', debug, minify, callback);
};
exports.build = function (callback, version, compsBase32, buildName) {
@@ -150,17 +191,6 @@ exports.build = function (callback, version, compsBase32, buildName) {
console.log('\tSaved to ' + srcPath);
}
- // Also combine and copy the admin JS files
- // TODO: Also minify if admin complexity increases in future
- var adminNewSrc = combineFiles(getAdminFiles()),
- adminPath = 'dist/admin/admin-src.js',
- adminOldSrc = loadSilently(adminPath);
-
- if (adminNewSrc != adminOldSrc) {
- fs.writeFileSync(adminPath, adminNewSrc);
- console.log('\tAdmin files saved to ' + adminPath);
- }
-
var path = pathPart + '.js',
oldCompressed = loadSilently(path),
newCompressed = copy + UglifyJS.minify(newSrc, {
@@ -198,6 +228,21 @@ exports.build = function (callback, version, compsBase32, buildName) {
});
};
+exports.buildadmin = function(callback) {
+ // TODO: Also minify if admin complexity increases in future
+ var adminNewSrc = combineFiles(getAdminFiles()),
+ adminPath = 'dist/admin/admin-src.js',
+ adminOldSrc = loadSilently(adminPath),
+ adminSrcDelta = getSizeDelta(adminNewSrc, adminOldSrc, true);
+
+ if (adminSrcDelta !== ' (unchanged)') {
+ fs.writeFileSync(adminPath, adminNewSrc);
+ console.log('\tAdmin files saved to ' + adminPath);
+ }
+
+ callback();
+};
+
exports.test = function(complete, fail) {
var karma = require('karma'),
testConfig = {configFile : __dirname + '/../spec/karma.conf.js'};
commit b940b34ab14b2d88af12871609f9bbc0ae3c86c9
Author: Pranav Kant <pranavk at collabora.co.uk>
Date: Fri Dec 9 18:02:53 2016 +0530
loleaflet-draw: Return early if no changes
Compression is most expensive in terms of time; if we detect
early that there are no changes between oldSrc and newSrc, lets
return early and skip the compression.
Change-Id: Id3d7c1d4bf89a33819907ff735e01629581627a3
diff --git a/loleaflet/plugins/draw-0.2.4/build/build.js b/loleaflet/plugins/draw-0.2.4/build/build.js
index a95b145..967c6a9 100644
--- a/loleaflet/plugins/draw-0.2.4/build/build.js
+++ b/loleaflet/plugins/draw-0.2.4/build/build.js
@@ -99,11 +99,13 @@ exports.build = function (callback, compsBase32, buildName) {
console.log('\tUncompressed: ' + bytesToKB(newSrc.length) + srcDelta);
- if (newSrc !== oldSrc) {
- fs.writeFileSync(srcPath, newSrc);
- console.log('\tSaved to ' + srcPath);
+ if (srcDelta === ' (unchanged)') {
+ return;
}
+ fs.writeFileSync(srcPath, newSrc);
+ console.log('\tSaved to ' + srcPath);
+
var path = pathPart + '.js',
oldCompressed = loadSilently(path),
newCompressed = copy + UglifyJS.minify(newSrc, {
More information about the Libreoffice-commits
mailing list