Skip to content
Permalink
Browse files
CB-9156 added ability to pass in custom path via command line for pla…
…tforms
  • Loading branch information
stevengill committed Jun 20, 2015
1 parent 9ade05c commit b08a012c77cbc5f49d4d0a9e05f666b70dd48b49
Showing 4 changed files with 20 additions and 15 deletions.
@@ -61,14 +61,20 @@ All of the build tasks can be run via the `grunt` node module. Install it global

sudo npm install -g grunt-cli

`grunt compile` task assumes that users have cordova-platforms as siblings to this cordova.js directory. When generating cordova.js, `grunt compile` will grab platform specific files from these directories if they exist. The default locations are defined in `package.json`.

Then from the repository root run:

grunt --platformVersion=4.0.0
grunt

To compile the js for just one platform, run:

grunt compile:android --platformVersion=4.0.0

To comiple the js for all platforms but pass in a relative path custom root for your cordova-android and cordova-ios platforms, run:

grunt compile --android='../custompath/cordova-android' --ios='../custompath/cordova-ios'

To create the browserify version of the js, run:

grunt compile-browserify --platformVersion=4.0.0
@@ -31,11 +31,18 @@ module.exports = function(grunt) {
//grabs --platformVersion flag
var flags = grunt.option.flags();
var platformVersion;
var platformPath = undefined;
flags.forEach(function(flag) {
if (flag.indexOf('platformVersion') > -1) {
var equalIndex = flag.indexOf('=');
platformVersion = flag.slice(equalIndex + 1);
}

if (flag.indexOf(platformName) > -1) {
var equalIndex = flag.indexOf('=');
platformPath = flag.slice(equalIndex + 1);
console.log(platformPath);
}
});
if(!platformVersion) {
//grab platformVersion from sibling platform directoreis
@@ -46,6 +53,6 @@ module.exports = function(grunt) {
platformVersion="N/A";
}
}
generate(platformName, useWindowsLineEndings, platformVersion, done);
generate(platformName, useWindowsLineEndings, platformVersion, platformPath, done);
});
}
@@ -25,9 +25,6 @@ var writeScript = require('./write-script');
var licensePath = path.join(__dirname, '..', 'templates', 'LICENSE-for-js-file.txt');
var pkgJson = require(process.cwd()+'/package.json');

console.log(__dirname);
//console.log(pkgJson);

module.exports = function bundle(platform, debug, commitId, platformVersion, platformPath) {
var modules = collectFiles(path.join('src', 'common'));
var scripts = collectFiles(path.join('src', 'scripts'));
@@ -36,20 +33,17 @@ module.exports = function bundle(platform, debug, commitId, platformVersion, pla

//Use passed in platformPath if it exists
if(platformPath) {
//USE PLATFORM PATH passed in

platformDep = path.join(process.cwd(), platformPath);
//see if platform location exists in package.json
} else if(pkgJson['cordova-platforms']['cordova-'+platform]){
platformDep = path.join(process.cwd(), pkgJson['cordova-platforms']['cordova-'+platform]);
} else {
platformDep = undefined;
}
console.log(platform +' '+ platformDep)
console.log(process.cwd());

//check to see if platform dependency has cordova-js-src directory
if(fs.existsSync(platformDep) && fs.existsSync(path.join(platformDep, 'cordova-js-src'))) {
copyProps(modules, collectFiles(path.join(platformDep, 'cordova-js-src')));
console.log('using sibiling directories');
} else {
if(platform !== 'test') {
//for platforms that don't have a release with cordova-js-src yet
@@ -66,7 +60,6 @@ module.exports = function bundle(platform, debug, commitId, platformVersion, pla
if(fs.existsSync(path.join(process.cwd(), pkgJson['cordova-platforms']['cordova-android']))) {
testFilesPath = path.join(process.cwd(), pkgJson['cordova-platforms']['cordova-android'], 'cordova-js-src', 'android');
modules['android/exec'] = path.join(process.cwd(), pkgJson['cordova-platforms']['cordova-android'], 'cordova-js-src', 'exec.js');
console.log('android test sibling');
} else {
testFilesPath = path.join('src', 'legacy-exec', 'android');
modules['android/exec'] = path.join('src', 'legacy-exec', 'android', 'exec.js');
@@ -76,7 +69,6 @@ module.exports = function bundle(platform, debug, commitId, platformVersion, pla
//Add iOS platform-specific modules that have tests for the test bundle.
if(fs.existsSync(path.join(process.cwd(), pkgJson['cordova-platforms']['cordova-ios']))) {
modules['ios/exec'] = path.join(process.cwd(), pkgJson['cordova-platforms']['cordova-ios'], 'cordova-js-src', 'exec.js');
console.log('ios test sibiling');
} else {
modules['ios/exec'] = path.join('src', 'legacy-exec', 'ios', 'exec.js');
}
@@ -22,17 +22,17 @@ var bundle = require('./bundle');
var computeCommitId = require('./compute-commit-id');


module.exports = function generate(platform, useWindowsLineEndings, platformVersion, callback) {
module.exports = function generate(platform, useWindowsLineEndings, platformVersion, platformPath, callback) {
computeCommitId(function(commitId) {
var outFile;
var time = new Date().valueOf();

var libraryRelease = bundle(platform, false, commitId, platformVersion);
var libraryRelease = bundle(platform, false, commitId, platformVersion, platformPath);
// if we are using windows line endings, we will also add the BOM
if(useWindowsLineEndings) {
libraryRelease = "\ufeff" + libraryRelease.split(/\r?\n/).join("\r\n");
}
var libraryDebug = bundle(platform, true, commitId, platformVersion);
var libraryDebug = bundle(platform, true, commitId, platformVersion, platformPath);

time = new Date().valueOf() - time;
if (!fs.existsSync('pkg')) {

0 comments on commit b08a012

Please sign in to comment.