Gaia/Build/RefactoringToNodejs: Difference between revisions

 
(33 intermediate revisions by 2 users not shown)
Line 21: Line 21:


* '''Developer:'''
* '''Developer:'''
** Ricky (MoCoTPE) (irc #gaia: rickychien)
** Ricky Chien (MoCoTPE)
** George (MoCoTPE) (irc #gaia: gduan)
** Scott Wu (MoCoTPE)


* '''Total expected schedule:''' 18 - 22 weeks (5 months)
* '''Total expected schedule:''' 18 - 22 weeks (5 months)
Line 36: Line 36:
<bugzilla>
<bugzilla>
{
{
   "id": "1131469, 1131471",
   "id": "1131469, 1207073",
   "include_fields": "id, summary, assigned_to, status, resolution"
   "include_fields": "id, summary, priority, assigned_to, status, resolution"
}
}
</bugzilla>
</bugzilla>
Line 51: Line 51:
<bugzilla>
<bugzilla>
{
{
   "id": "955988, 1130934, 955989, 1131468, 1131496, 1131497, 1131499, 1131500, 1131501, 1131502, 1131503, 1131504, 1131505, 1131506, 1131510, 1131511, 1131512, 1131513, 1131514, 1131515, 1131516, 1131517, 1131518, 955994, 1131519, 1131521, 1131522, 1131524, 955996, 1131525, 955997, 955998, 1131526, 955999, 1131527, 1138773",
   "id": "955988, 1130934, 955989, 1131468, 1131496, 1131497, 1131499, 1131500, 1131501, 1131502, 1131503, 1131504, 1131505, 1131506, 1131510, 1131511, 1131512, 1131513, 1131514, 1131515, 1131516, 1131517, 1131518, 955994, 1131519, 1131521, 1131522, 1131524, 955996, 955997, 955998, 1131526, 955999, 1131527, 1138773, 1131471, 1240678, 1240740, 1242326, 1242327, 1243351",
   "include_fields": "id, summary, assigned_to, status, resolution"
   "include_fields": "id, summary, priority, assigned_to, status, resolution"
}
}
</bugzilla>
</bugzilla>


<!--
== Milestone 2 ==
== Milestone 2 ==


Line 66: Line 67:
** Bug ? - Refactor utils-node.js API and remove utils-xpc.js and utils.js
** Bug ? - Refactor utils-node.js API and remove utils-xpc.js and utils.js
** Bug ? - Refactor all build/*.js to conform to node-style
** Bug ? - Refactor all build/*.js to conform to node-style
 
-->
== Milestone 3 (Draft) ==
 
The M3 goal is to simplify make Makefile into merely a compatibility layer for the existing commands, and move all the logic into external JavaScript-based build tools. By doing so it would improve the maintainability and readability of the build system. We tentatively choose [http://gulpjs.com/ Gulp.js] as target currently as it offers [https://github.com/gulpjs/gulp#incremental-builds incremental builds] and stream workflow.
 
* '''Deliverable:''' Purge complex logic from Makefile and rely on an external JavaScript-based build tools for most of the complexities.
* '''Expected schedule:''' 8 weeks
* '''Breakdowns:'''
** Extract Makefile logic into JS modules
** Rewrite Makefile targets into JS
*** Task dependency - [https://www.npmjs.com/package/gulp gulp]
*** Parallel build - [https://www.npmjs.com/package/gulp-spawn gulp-spawn]
*** Incremental build
**** Watch file changes - [https://github.com/sindresorhus/gulp-changed gulp-changed]
**** File dependency resolving (speed up incremental build) [https://www.npmjs.com/package/gulp-resolver gulp-resolver]
*** Edit file content
*** Support ES6 [https://www.npmjs.com/package/gulp-babel gulp-babel]
*** Minify
**** JS [https://www.npmjs.com/package/gulp-uglify gulp-uglify]
**** CSS [https://www.npmjs.com/package/gulp-minify-css gulp-minify-css]
**** HTML [https://www.npmjs.com/package/gulp-minify-html gulp-minify-html]
**** SVG [https://www.npmjs.com/package/gulp-svgmin gulp-svgmin]
**** Image [https://github.com/sindresorhus/gulp-imagemin gulp-imagemin]
*** Concatenate [https://www.npmjs.com/package/gulp-concat gulp-concat]
*** Package to zip [https://www.npmjs.com/package/gulp-zip gulp-zip]
*** Process everything in memory (remove build_stage) [https://github.com/gulpjs/gulp/blob/master/docs/recipes/make-stream-from-buffer.md make-stream-from-buffer]
** Building parameters management
*** [https://github.com/gulpjs/gulp/blob/master/docs/recipes/using-external-config-file.md using-external-config-file]
*** [https://www.npmjs.com/package/parse-env parse-env]
*** [https://www.npmjs.com/package/config-manager config-manager]
** Redesign build.js - A config file rather than lots of build processes
* '''Reference:'''
** https://github.com/fxos/build


= Q & A =
= Q & A =
Line 144: Line 113:


In short, targeting io.js is not the scope of the current plan.
In short, targeting io.js is not the scope of the current plan.
== File dependency resolution to improve incremental build ==
It would work by using existed gulp plugins (ex: gulp-resolve-dependencies) or adding new feature into plugins.
== Task dependency and parallel build ==
Gulp is not as much convenience as Makefile and doesn't support parallel building natively. Therefore, although plugins could help us build up a same parallel architecture of our current build system, it’s hard to split every task into dependency tree to take full advantage of multi-core CPU (like "make -j8").
== If we decide to build up our build system by GNU Make tool chain, considering to split up every task into small tasks would be very hard to implement. Furthermore, splitting into many small tasks mean that you have to deal with more I/O operations because you need to write more temporary file for communicating within each task, such thing will slow down  performance ==
It would work by condition plugins for instance gulp-if, gulp-filter, gulp-ignore…, but introducing these plugins mean that lots of condition logic will pollute inside gulpfile.js. (Can we solve this problem in GNU make tool chain?)
Repack zip could be achieved by adding a new feature in gulp-zip (Issue is filed [https://github.com/sindresorhus/gulp-zip/issues/45 gulp-zip/issues/45]) and customize [https://www.npmjs.com/package/gulp-changed#haschanged hasChanged] comparator callback.
Confirmed users
429

edits