1、New Build System in Dojo 1.7,,April 26th, 2012,Agenda,Introduction to bdBuild and Dojo new builder,Build Profile in Dojo 1.6,Build Control Script in Dojo 1.7,How does the new build system work?,Customize the build process.,Agenda,Introduction to bdBuild and Dojo new builder,Build Profile in Dojo 1.6
2、,Build Control Script in Dojo 1.7,How does the new build system work?,Customize the build process.,Introduction to bdBuild and Dojo new builder,Dojo 1.7 builder is based on the bdBuilder which done by Rawld GillbdBuild is a general-purpose program for transforming resourcesBuild process -Discover re
3、sources -Apply transformsHighly configurable - Build Control Script (BCS, the new Build Profile!),Invoking the Build System,Use nodeJS /dev/dtk/util/buildscripts node.js /dojo/dojo.js load=build -helpUse Rhino java -Xms256m -Xmx256m -cp /shrinksafe/js.jar;/closureCompiler/compiler.jar;/shrinksafe/sh
4、rinksafe.jar org.mozilla.javascript.tools.shell.Main /dojo/dojo.js baseUrl=/dojo load=buildUse batch program or shell script /dev/dtk/util/buildscripts ./build.sh -help (nodeJS is preferred, otherwise Rino will be userd) /dev/dtk/util/buildscripts ./build.bat -help,Useful Command Link Swtich,-profil
5、e profile-name build.bat -profile yourprofile.profile.js build.bat -profile yourprofile build.bat -profile yourprofile1 -profile yourprofile2,Useful Command Link Swtich,-dojoConfig filename /util/build/examples/dojoConfig.js var dojoConfig = packages:name:“dojo“,location:“/dojo“,name:“dijit“,locatio
6、n:“/dijit“ ; build.bat -dojoConfig /build/exapmles/dojoConfig.js,Useful Command Link Swtich,-package path /dojo/package.json “directories“: “lib“: “.“,“version“ : “1.7.2“,“dojoBuild“: “dojo.profile.js“ build.bat -package /dojo build.bat -package /dojo, /dijit,Useful Command Link Swtich,-releaseDir *
7、directory* -check -help -version-release build.bat -profile yourprofile -releaseNote: The action clean is no longer supported.,Agenda,Introduction to bdBuild and Dojo new builder,Build Profile in Dojo 1.6,Build Control Script in Dojo 1.7,How does the new build system work?,Customize the build proces
8、s.,Build Profile in Dojo 1.6,/buildscripts/profile/myprofile.profile.jsdependencies = layers: name: “test.js“,dependencies: “test.ModuleA“,“test.ModuleB“,“test.ModuleC“,prefixes: “test“, “/test“ ,layerDependencies,dependencies = layers: name: “part1.js“,resourceName: “test.part1“,dependencies: “test
9、.ModuleA“,“test.ModuleB“,name: “part2.js“,resourceName: “test.part2“,dependencies: “test.ModuleC“,“test.ModuleD“,layerDependencies: “test/part1.js“,prefixes: “test“, “/test“ ,keepRequires,dependencies = layers: name: “part1.js“,resourceName: “test.part1“,dependencies: “test.ModuleA“,“test.ModuleB“,n
10、ame: “part2.js“,resourceName: “test.part2“,dependencies: “test.ModuleC“,“test.ModuleD“,layerDependencies: “test/part1.js“,keepRequires: “dojo.i18n“ ,prefixes: “test“, “/test_old“ , “dijit“, “/dijit“ , “dojox“, “/dojox“ ,prefixes: “test“, “/test“ , “dijit“, “/dijit“ ,Conditional Exclusions,excludeSta
11、rt( tag , *condition* ) excludeEnd( tag )excludeStart( tag , “Tag“, kwArgs.layers.length 1) . code within the region here will be ignored excludeEnd( tag )includeStart( tag , *condition* ) includeEnd( tag )includeStart( tag , “Tag“, kwArgs.layers.length 1) . code within the region here will be inclu
12、ded includeEnd( tag ),Agenda,Introduction to bdBuild and Dojo new builder,Build Profile in Dojo 1.6,Build Control Script in Dojo 1.7,How does the new build system work?,Customize the build process.,Build Control Script in Dojo 1.7,/buildscripts/profile/myprofile.profile.jsvar profile = packages: nam
13、e: dojo,location: /dojo,name: test,location: /test,layers: test/part1: include: test/ModuleA,test/ModuleB,test/part2: include: test/ModuleC,test/ModuleD,exclude: test/part1 ;,packages,var profile = packages: name: dojo,location: /dojo,name: test,location: /test,layers: test/part1: include: test/Modu
14、leA,test/ModuleB,test/part2: include: test/ModuleC,test/ModuleD,exclude: test/part1 ;,Package information can be feed in -dojoConfig and -require parameters,Include & Exclude,var profile = packages: name: dojo,location: /dojo,name: test,location: /test,layers: test/part1: include: test/ModuleA,test/
15、ModuleB,test/part2: include: test/ModuleC,test/ModuleD,exclude: test/part1 ;,Use exclude instead of layerDependencies and keepRequires,Resourse Tags,-test The resource is part of the test code for the package.-copyOnly The resource should be copied to the destination location and otherwise left unal
16、tered.-amd The resource is an AMD module.-miniExclude The resource should not be copied to the destination if the profile property “mini“ is truthy.,Apply tags to resourse,var profile = .resourceTags: test: function(filename, mid)return testResourceRe.test(mid) | mid=“dojo/tests“ | mid=“dojo/robot“|
17、 mid=“dojo/robotx“;,copyOnly: function(filename, mid)return copyOnly(filename, mid);,amd: function(filename, mid)return !testResourceRe.test(mid) ,. ,Agenda,Introduction to bdBuild and Dojo new builder,Build Profile in Dojo 1.6,Build Control Script in Dojo 1.7,How does the new build system work?,Cus
18、tomize the build process.,Discover Resources,Using Packages, Trees, Dirs, and Files trees:“./dtk/dojo“, “./lib/dojo“,“./dtk/dijit“, “./lib/dijit“,“./myapp/lib“, “./lib/myapp“,source, destination ,ignore tree: All files in the file system hierarchy rooted at each given source path dirs: Only each sin
19、gle directory is processed files: Simply lists a set of specific files to discover.,Transform,Transforms are functions applied to resources. bdBuild is a general-purpose program for transforming resourcestransforms:/ transform-name: transform-class, gate-name trace: “build/transforms/trace“, “read“,
20、read: “build/transforms/read“, “read“,write: “build/transforms/write“, “write“,copy: “build/transforms/copy“, “write“. ,Gate,Each transform is associated with a gate; gates give the order transforms are applied.,gates:/ synchronized, gate-name, gate-message0, “read“, “reading resources“,0, “text“, “
21、processing raw resource content“,0, “tokenize“, “tokenizing resource“,0, “tokens“, “processing resource tokens“,0, “parse“, “parsing resource“,1, “ast“, “processing resource AST“,1, “optimize“, “executing global optimizations“,1, “write“, “writing resources“,1, “cleanup“, “cleaning up“,1, “report“,
22、“reporting“ ,TransformJobs,transformJobs maps a particular resource to an ordered set of transforms to apply to that resource.,transformJobs:/ If the resource is tagged as copyOnly, then apply the copy transformfunction(resource) return resource.tag.copyOnly;,“copy“ ,/ If the filename is end with .c
23、ss, then apply read, optimizeCss, write transformsfunction(resource, bc) return /.css$/.test(resource.src);,“read“, “optimizeCss“, “write“, , .,Work Flow & Common Transform,-copy: Copies a resource from a source location to a destination location.-depsScan: Determines a modules dependencies and inte
24、rns legacy dojo.cache string resources.-dojoPragmas: Applies dojo pragmas to a resource.-optimizeCss: Inlines CSS imports and/or removes comments from CSS files.-read: Reads a resource from the file system.-write: Writes a resource to the file system.-writeAmd: Writes an AMD module to the file syste
25、m.-writeCss: Writes a CSS style sheet to the file system-writeOptimized: Processes a resource with shrinksafe or the closure compiler and writes the result to the file system.,Agenda,Introduction to bdBuild and Dojo new builder,Build Profile in Dojo 1.6,Build Control Script in Dojo 1.7,How does the
26、new build system work?,Customize the build process.,Create your own transform,utilbuildtransformssayHello.jsdefine(“/buildControl“, “/fileUtils“, function(bc, fileUtils) .return function(resource, callback)/ resource: resource file info/ callback(resource, error): Catch and report the error returned
27、 from Aysnc / procconsole.log(“Say hello to modules in dojo/data: “ + resource.mid); );,Create your own gate,var profile = .gates: 0, “beforeread“, “-Say hello to modules with tag *myTag*-“,0, “read“, “reading resources“,0, “text“, “processing raw resource content“,0, “tokenize“, “tokenizing resourc
28、e“, . ,Register the transform,var profile = .transforms:sayhello: “build/transforms/sayHello“, “beforeread“,trace: “build/transforms/trace“, “read“,., . ,Customize the resourceTags and transform jobs,var profile = packages: name: dojo,location: /dojo,resourceTags: myTag: function(filename, mid)retur
29、n /data/.test(mid) ; .,transformJobs:function(resource, bc) return resource.tag.myTag;, “sayhello“,. ,Run the profile,Reference,Quick Reference for Optimization Build Program http:/dojotoolkit.org/reference-guide/1.7/build/qref.html#build-qrefThe Dojo Build System http:/dojotoolkit.org/reference-guide/1.7/build/buildSystem.html#build-buildsystemDojo Build System (Pre 1.7) http:/dojotoolkit.org/reference-guide/1.7/build/pre17/build.html#build-pre17-buildbdBuild Tutorial and Reference Manual http:/bdframework.org/bdBuild/docs/bdBuild-tutorial/bdBuild-tutorial.html,