You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ia...@apache.org on 2014/05/29 17:45:11 UTC

[12/13] android commit: Manually fix Android sdk location to support library projects without local.properties

Manually fix Android sdk location to support library projects without local.properties


Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/22b19593
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/22b19593
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/22b19593

Branch: refs/heads/4.0.x
Commit: 22b19593337eebbf80d399692218b569ae78d922
Parents: 9700830
Author: Ian Clelland <ic...@chromium.org>
Authored: Thu May 22 14:04:00 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Thu May 22 14:04:00 2014 -0400

----------------------------------------------------------------------
 bin/node_modules/which/LICENSE      |  23 +++++++
 bin/node_modules/which/README.md    |   5 ++
 bin/node_modules/which/bin/which    |  14 +++++
 bin/node_modules/which/package.json |  31 +++++++++
 bin/node_modules/which/which.js     | 104 +++++++++++++++++++++++++++++++
 bin/templates/cordova/lib/build.js  |   7 +++
 package.json                        |   3 +-
 7 files changed, 186 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/22b19593/bin/node_modules/which/LICENSE
----------------------------------------------------------------------
diff --git a/bin/node_modules/which/LICENSE b/bin/node_modules/which/LICENSE
new file mode 100644
index 0000000..05a4010
--- /dev/null
+++ b/bin/node_modules/which/LICENSE
@@ -0,0 +1,23 @@
+Copyright 2009, 2010, 2011 Isaac Z. Schlueter.
+All rights reserved.
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/22b19593/bin/node_modules/which/README.md
----------------------------------------------------------------------
diff --git a/bin/node_modules/which/README.md b/bin/node_modules/which/README.md
new file mode 100644
index 0000000..ff1eb53
--- /dev/null
+++ b/bin/node_modules/which/README.md
@@ -0,0 +1,5 @@
+The "which" util from npm's guts.
+
+Finds the first instance of a specified executable in the PATH
+environment variable.  Does not cache the results, so `hash -r` is not
+needed when the PATH changes.

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/22b19593/bin/node_modules/which/bin/which
----------------------------------------------------------------------
diff --git a/bin/node_modules/which/bin/which b/bin/node_modules/which/bin/which
new file mode 100755
index 0000000..8432ce2
--- /dev/null
+++ b/bin/node_modules/which/bin/which
@@ -0,0 +1,14 @@
+#!/usr/bin/env node
+var which = require("../")
+if (process.argv.length < 3) {
+  console.error("Usage: which <thing>")
+  process.exit(1)
+}
+
+which(process.argv[2], function (er, thing) {
+  if (er) {
+    console.error(er.message)
+    process.exit(er.errno || 127)
+  }
+  console.log(thing)
+})

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/22b19593/bin/node_modules/which/package.json
----------------------------------------------------------------------
diff --git a/bin/node_modules/which/package.json b/bin/node_modules/which/package.json
new file mode 100644
index 0000000..c71cabb
--- /dev/null
+++ b/bin/node_modules/which/package.json
@@ -0,0 +1,31 @@
+{
+  "author": {
+    "name": "Isaac Z. Schlueter",
+    "email": "i@izs.me",
+    "url": "http://blog.izs.me"
+  },
+  "name": "which",
+  "description": "Like which(1) unix command. Find the first instance of an executable in the PATH.",
+  "version": "1.0.5",
+  "repository": {
+    "type": "git",
+    "url": "git://github.com/isaacs/node-which.git"
+  },
+  "main": "which.js",
+  "bin": {
+    "which": "./bin/which"
+  },
+  "engines": {
+    "node": "*"
+  },
+  "dependencies": {},
+  "devDependencies": {},
+  "readme": "The \"which\" util from npm's guts.\n\nFinds the first instance of a specified executable in the PATH\nenvironment variable.  Does not cache the results, so `hash -r` is not\nneeded when the PATH changes.\n",
+  "readmeFilename": "README.md",
+  "bugs": {
+    "url": "https://github.com/isaacs/node-which/issues"
+  },
+  "homepage": "https://github.com/isaacs/node-which",
+  "_id": "which@1.0.5",
+  "_from": "which@^1.0.5"
+}

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/22b19593/bin/node_modules/which/which.js
----------------------------------------------------------------------
diff --git a/bin/node_modules/which/which.js b/bin/node_modules/which/which.js
new file mode 100644
index 0000000..db7e8f7
--- /dev/null
+++ b/bin/node_modules/which/which.js
@@ -0,0 +1,104 @@
+module.exports = which
+which.sync = whichSync
+
+var path = require("path")
+  , fs
+  , COLON = process.platform === "win32" ? ";" : ":"
+  , isExe
+
+try {
+  fs = require("graceful-fs")
+} catch (ex) {
+  fs = require("fs")
+}
+
+if (process.platform == "win32") {
+  // On windows, there is no good way to check that a file is executable
+  isExe = function isExe () { return true }
+} else {
+  isExe = function isExe (mod, uid, gid) {
+    //console.error(mod, uid, gid);
+    //console.error("isExe?", (mod & 0111).toString(8))
+    var ret = (mod & 0001)
+        || (mod & 0010) && process.getgid && gid === process.getgid()
+        || (mod & 0100) && process.getuid && uid === process.getuid()
+    //console.error("isExe?", ret)
+    return ret
+  }
+}
+
+
+
+function which (cmd, cb) {
+  if (isAbsolute(cmd)) return cb(null, cmd)
+  var pathEnv = (process.env.PATH || "").split(COLON)
+    , pathExt = [""]
+  if (process.platform === "win32") {
+    pathEnv.push(process.cwd())
+    pathExt = (process.env.PATHEXT || ".EXE").split(COLON)
+    if (cmd.indexOf(".") !== -1) pathExt.unshift("")
+  }
+  //console.error("pathEnv", pathEnv)
+  ;(function F (i, l) {
+    if (i === l) return cb(new Error("not found: "+cmd))
+    var p = path.resolve(pathEnv[i], cmd)
+    ;(function E (ii, ll) {
+      if (ii === ll) return F(i + 1, l)
+      var ext = pathExt[ii]
+      //console.error(p + ext)
+      fs.stat(p + ext, function (er, stat) {
+        if (!er &&
+            stat &&
+            stat.isFile() &&
+            isExe(stat.mode, stat.uid, stat.gid)) {
+          //console.error("yes, exe!", p + ext)
+          return cb(null, p + ext)
+        }
+        return E(ii + 1, ll)
+      })
+    })(0, pathExt.length)
+  })(0, pathEnv.length)
+}
+
+function whichSync (cmd) {
+  if (isAbsolute(cmd)) return cmd
+  var pathEnv = (process.env.PATH || "").split(COLON)
+    , pathExt = [""]
+  if (process.platform === "win32") {
+    pathEnv.push(process.cwd())
+    pathExt = (process.env.PATHEXT || ".EXE").split(COLON)
+    if (cmd.indexOf(".") !== -1) pathExt.unshift("")
+  }
+  for (var i = 0, l = pathEnv.length; i < l; i ++) {
+    var p = path.join(pathEnv[i], cmd)
+    for (var j = 0, ll = pathExt.length; j < ll; j ++) {
+      var cur = p + pathExt[j]
+      var stat
+      try { stat = fs.statSync(cur) } catch (ex) {}
+      if (stat &&
+          stat.isFile() &&
+          isExe(stat.mode, stat.uid, stat.gid)) return cur
+    }
+  }
+  throw new Error("not found: "+cmd)
+}
+
+var isAbsolute = process.platform === "win32" ? absWin : absUnix
+
+function absWin (p) {
+  if (absUnix(p)) return true
+  // pull off the device/UNC bit from a windows path.
+  // from node's lib/path.js
+  var splitDeviceRe =
+        /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?([\\\/])?/
+    , result = splitDeviceRe.exec(p)
+    , device = result[1] || ''
+    , isUnc = device && device.charAt(1) !== ':'
+    , isAbsolute = !!result[2] || isUnc // UNC paths are always absolute
+
+  return isAbsolute
+}
+
+function absUnix (p) {
+  return p.charAt(0) === "/" || p === ""
+}

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/22b19593/bin/templates/cordova/lib/build.js
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/lib/build.js b/bin/templates/cordova/lib/build.js
index 6336ecf..9e5172c 100644
--- a/bin/templates/cordova/lib/build.js
+++ b/bin/templates/cordova/lib/build.js
@@ -24,6 +24,7 @@ var shell   = require('shelljs'),
     Q       = require('q'),
     path    = require('path'),
     fs      = require('fs'),
+    which   = require('which'),
     ROOT    = path.join(__dirname, '..', '..');
 
 
@@ -32,6 +33,12 @@ function hasCustomRules() {
 }
 module.exports.getAntArgs = function(cmd) {
     var args = [cmd, '-f', path.join(ROOT, 'build.xml')];
+    try {
+      // Specify sdk dir in case local properties are missing
+      args.push('-Dsdk.dir='+path.join(which.sync('android'), '../..'));
+    } catch(e) {
+      // Can't find android; don't push arg: assume all is okay
+    }
     // custom_rules.xml is required for incremental builds.
     if (hasCustomRules()) {
         args.push('-Dout.dir=ant-build', '-Dgen.absolute.dir=ant-gen');

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/22b19593/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 0d203c9..f38c187 100644
--- a/package.json
+++ b/package.json
@@ -16,6 +16,7 @@
   "license": "Apache version 2.0",
   "dependencies": {
     "q": "^0.9.0",
-    "shelljs": "^0.2.6"
+    "shelljs": "^0.2.6",
+    "which": "^1.0.5"
   }
 }