Opened 10 years ago

Closed 10 years ago

#9323 closed enhancement (fixed)

make build.js less dependent on home directory

Reported by: maulin Owned by: James Burke
Priority: high Milestone: 1.4
Component: BuildTools Version: 1.3.0
Keywords: Cc:
Blocked By: Blocking:

Description

I create a "parallel" directory for my builds. I write my own build.js for some of my own tasks, then call load(../../util/buildsripts/build.js). And it ALMOST works. There are just a few places in the build.js file that could use some "prefixing" with buildscriptsPath + 'file.js'. then just don't clobber buildscripsPath on entry, with a line at the top of the file to the effect of:

buildscriptsPath = buildscriptsPath
'./'

then I can set buildscriptsPath before my load of it, and everything else just works automagically.

thanks. patch attached

Attachments (2)

build.js.patch (1.9 KB) - added by maulin 10 years ago.
i18nUtil.js.patch (642 bytes) - added by maulin 10 years ago.

Download all attachments as: .zip

Change History (8)

Changed 10 years ago by maulin

Attachment: build.js.patch added

Changed 10 years ago by maulin

Attachment: i18nUtil.js.patch added

comment:1 Changed 10 years ago by maulin

one other change -- i18n needs to use buildscriptsPath for its load() statments as well

comment:2 Changed 10 years ago by James Burke

Thanks for taking the time to look at the source and make a patch.

The build.js.patch file passes buildscriptsPath to buildUtil.loadDependencyList() but there is no patch that shows a change to buildUtil.loadDependencyList?

A more general question:

What I have normally done, and I think is standard practice is to have your own build script "change directory" to the dojo directory, do the build, then "change directory" back to where you want to continue your build in your other area.

In that way, there is not a need to configure a buildscripts path. Is there a reason why that "change directory" approach does not work for you?

comment:3 Changed 10 years ago by maulin

Its interesting, but buildUtil.loadDependencyList() already supported passing in the path! It just wasn't passed in!

I could simply do a CD approach, but this gives me the ability to actually use the buildUtil and other dojo build scripts, as well as cleans up my paths (so they are relative to my build directory, not relative to dojo/util/buidlscripts):

-build --profiles/ --config/ --build.bat --build.jssee contents below -dojo/ ---dojo/ ---dijit/ ---dojox/ ---util/ -mynamespace/ -mybootstrapper.js

my build.js:

summary: This is a javascript build file that will compress and build all the js (delegating to dojo's build system). it also handles configuration issues uses all the same build arguments as dojo's build, but you can also pass in the environment=dev.dynamic

buildscriptsPath = "../../dojo/util/buildscripts/"; load(buildscriptsPath + "build.js");

load the orhospitalists and the config and do the regex/compression if (kwArgs.action == "release") {

var orh = readFile("../../mybootstrapper.js");

load the config we want

var cf = readFile("../config/" + (kwArgs.environment
"dev.static") + ".js");

insert the config orh = orh.replace(/djConfig = \{[\w\W\s]*?\};/gi, cf)

logger.trace("Optimizing (" + kwArgs.layerOptimize + ") file: mybootstrapper.js");

compress var compressedContents = buildUtil.optimizeJs("mybootstrapper.js", orh, readFile('copyright.txt'), kwArgs.layerOptimize);

save fileUtil.saveUtf8File(kwArgs.releaseDir + "/mybootstrapper.js", compressedContents);

}

So, I can use your machinery to swap out my config information, as well as optimize a script that sits outside my namespace. (but thats just an example... I can imagine many other uses...)

comment:4 Changed 10 years ago by maulin

ugh, forgot my wiki formatting...

folder hierarchy:

-build 
---profiles/ 
---config/ 
---build.bat 
---build.js**see contents below 
-dojo/ 
---dojo/ 
---dijit/ 
---dojox/ 
---util/ 
-mynamespace/ 
-mybootstrapper.js 


//	summary:
//		This is a javascript build file that will compress and build all the js (delegating to dojo's build system).
//		it also handles configuration issues
//		uses all the same build arguments as dojo's build, but you can also pass in the 
//		environment=dev.dynamic

buildscriptsPath = "../../dojo/util/buildscripts/";
load(buildscriptsPath + "build.js");


//load the mybootstrapper and the config and do the regex/compression
if (kwArgs.action == "release") {
	var orh = readFile("../../mybootstrapper.js");
	
	//load the config we want
	var cf = readFile("../config/" + (kwArgs.environment || "dev.static") + ".js");
	
	//insert the config
	orh = orh.replace(/djConfig = \{[\w\W\s]*?\};/gi, cf)
	
	logger.trace("Optimizing (" + kwArgs.layerOptimize + ") file: mybootstrapper.js");
	
	//compress
	var compressedContents = buildUtil.optimizeJs("mybootstrapper.js", orh, readFile('copyright.txt'), kwArgs.layerOptimize);
	
	//save
	fileUtil.saveUtf8File(kwArgs.releaseDir + "/mybootstrapper.js", compressedContents);
}

comment:5 Changed 10 years ago by James Burke

OK, I can see if you wanted to use some of the build's methods for your own work, outside a dojo build, it would be useful to set the buildscriptsPath. I'll get this in for 1.4.

comment:6 Changed 10 years ago by James Burke

Resolution: fixed
Status: newclosed

(In [20349]) Fixes #9323, allow buildscripts dir to be set. Patch from maulin, CLA on file. \!strict

Note: See TracTickets for help on using tickets.