Skip to content
Permalink
Browse files
CB-9156 added support for absolute platform paths
  • Loading branch information
stevengill committed Jun 20, 2015
1 parent 3e13d0a commit d88c18b6aab74d3b9f527adeec03093286657326
Showing 5 changed files with 28 additions and 28 deletions.
@@ -71,7 +71,7 @@ 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:
To comiple the js for all platforms but pass in a custom path for your cordova-android and cordova-ios platforms, run:

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

@@ -83,6 +83,8 @@ To compile the browserify version of the js for just one platform, run:

grunt compile-browserify:android --platformVersion=4.0.0

NOTE: browserify method does not support custom paths for platform repos.

For integration, see the 'Integration' section below.

## Known Issues
@@ -88,6 +88,7 @@
"cordova-wp8": "../cordova-wp8",
"cordova-windows": "../cordova-windows",
"cordova-osx": "../cordova-osx",
"cordova-browser": "../cordova-browser"
"cordova-browser": "../cordova-browser",
"cordova-webos": "../cordova-webos"
}
}
@@ -45,8 +45,9 @@ module.exports = function(grunt) {
}
});
if(!platformVersion){
if(pkgJson['cordova-platforms']['cordova-'+platformName] && fs.existsSync(path.join(pkgJson['cordova-platforms']['cordova-'+platformName]))) {
var platformPkgJson = require('../' + pkgJson['cordova-platforms']['cordova-'+platformName] +'/package.json');
var platformPath = pkgJson['cordova-platforms']['cordova-'+platformName];
if(platformPath && fs.existsSync(platformPath)) {
var platformPkgJson = require('../' + platformPath +'/package.json');
platformVersion = platformPkgJson.version;
} else {
console.log('platformVersion not supplied. Setting platformVersion to N/A');
@@ -19,40 +19,45 @@
var generate = require('./lib/packager');
var fs = require('fs');
var path = require('path');
var pkgJson = require(process.cwd() + '/package.json');
var pkgJson = require('../package.json');

module.exports = function(grunt) {
grunt.registerMultiTask('compile', 'Packages cordova.js', function() {
var done = this.async();
var platformName = this.target;
var useWindowsLineEndings = this.data.useWindowsLineEndings;
var platformVersion;

//grabs --platformVersion flag
var flags = grunt.option.flags();
var platformVersion;
var platformPath = undefined;
flags.forEach(function(flag) {
//see if --platformVersion was passed in
if (flag.indexOf('platformVersion') > -1) {
var equalIndex = flag.indexOf('=');
platformVersion = flag.slice(equalIndex + 1);
}


//see if flags for platforms were passed in
//followed by custom paths
if (flag.indexOf(platformName) > -1) {
var equalIndex = flag.indexOf('=');
platformPath = flag.slice(equalIndex + 1);
}
});
//Use platformPath from package.json, no custom platform path
if(platformPath === undefined) {
platformPath = pkgJson['cordova-platforms']['cordova-'+platformName];
}
//Get absolute path to platform
if(platformPath) {
platformPath = path.resolve(platformPath);
}
if(!platformVersion) {
var platformPkgJson;
//grab platformVersion from custom path
if(platformPath && fs.existsSync(platformPath)) {
platformPkgJson = require('../' + platformPath + '/package.json');
platformVersion = platformPkgJson.version;

//grab platformVersion from sibling platform directoreis
} else if(pkgJson['cordova-platforms']['cordova-'+platformName] && fs.existsSync(path.join(pkgJson['cordova-platforms']['cordova-'+platformName]))) {
platformPkgJson = require('../' + pkgJson['cordova-platforms']['cordova-'+platformName]+'/package.json');
if(platformPath && fs.existsSync(platformPath)) {
platformPkgJson = require(platformPath +'/package.json');
platformVersion = platformPkgJson.version;
} else {
platformVersion="N/A";
@@ -23,27 +23,17 @@ var copyProps = require('./copy-props');
var writeModule = require('./write-module');
var writeScript = require('./write-script');
var licensePath = path.join(__dirname, '..', 'templates', 'LICENSE-for-js-file.txt');
var pkgJson = require(process.cwd()+'/package.json');
var pkgJson = require('../../package.json');

module.exports = function bundle(platform, debug, commitId, platformVersion, platformPath) {
var modules = collectFiles(path.join('src', 'common'));
var scripts = collectFiles(path.join('src', 'scripts'));
var platformDep;
modules[''] = path.join('src', 'cordova.js');

//Use passed in platformPath if it exists
if(platformPath) {
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;
}

//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')));
//check to see if platform has cordova-js-src directory
if(fs.existsSync(platformPath) && fs.existsSync(path.join(platformPath, 'cordova-js-src'))) {
copyProps(modules, collectFiles(path.join(platformPath, 'cordova-js-src')));
} else {
if(platform !== 'test') {
//for platforms that don't have a release with cordova-js-src yet
@@ -54,6 +44,7 @@ module.exports = function bundle(platform, debug, commitId, platformVersion, pla
}

}
//test doesn't support custom paths
if (platform === 'test') {
var testFilesPath;
// Add android platform-specific modules that have tests to the test bundle.

0 comments on commit d88c18b

Please sign in to comment.