Skip to content

Commit

Permalink
Merge branch 'develop' into feature/dir-tracking-directive
Browse files Browse the repository at this point in the history
  • Loading branch information
chen-factual committed Sep 21, 2015
2 parents 4fd7a28 + 17f1f1a commit 13817e4
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 15 deletions.
6 changes: 3 additions & 3 deletions bin/drake
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ fi

function build_jar {
echo "Using DRAKE_HOME: $DRAKE_HOME"
DRAKE_JAR=$DRAKE_HOME/target/drake.jar
DRAKE_JAR=${DRAKE_JAR:-$DRAKE_HOME/target/drake.jar}
if [[ ! -f $DRAKE_JAR ]]; then
echo ""
echo "========= UBERJAR COMPILING ========="
Expand All @@ -84,8 +84,8 @@ if [ ! -z ${DRAKE_HOME:+x} ] && [ -d $DRAKE_HOME ] && [ -f "$DRAKE_HOME/project.
build_jar
else
DRAKE_HOME=~/.drakerc
mkdir -p $DRAKE_HOME/jar
DRAKE_JAR=$DRAKE_HOME/jar/drake-$DRAKE_VERSION-standalone.jar
DRAKE_JAR=${DRAKE_JAR:-$DRAKE_HOME/jar/drake-$DRAKE_VERSION-standalone.jar}
mkdir -p $(dirname $DRAKE_JAR)
if [ ! -f $DRAKE_JAR ]; then
echo "Downloading drake jar for version $DRAKE_VERSION..."
echo ""
Expand Down
4 changes: 2 additions & 2 deletions src/drake/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,10 @@
[inputs]
(let [inputs-info (map parser/make-file-stats inputs)]
{:existing (->> (filter :exists inputs-info)
(map :file))
(map :path))
;; Non-existing, non-optional inputs
:missing (->> (remove (some-fn :optional :exists) inputs-info)
(map :file))}))
(map :path))}))

(defn- should-build?
"Given the parse tree and a step index, determines whether it should
Expand Down
2 changes: 1 addition & 1 deletion src/drake/parser.clj
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@
{:optional (optional-input? filename)
:exists (dfs/fs di/data-in? filepath)
:path filepath
:file filename}))
:raw-name filename}))

(defn modify-filename
[filename mod-fn]
Expand Down
5 changes: 2 additions & 3 deletions src/drake/protocol_interpreters.clj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(ns drake.protocol-interpreters
(:require [drake-interface.core :refer [Protocol]]
[drake.shell :as shell]
[drake.protocol :refer [register-protocols! run-interpreter]]))

(def WINDOWS? (.startsWith (System/getProperty "os.name") "Win"))
Expand All @@ -12,9 +13,7 @@
(run [_ step]
(run-interpreter step interpreter args)))))

(dorun (map register-interpreter! [(if WINDOWS?
["shell" "cmd" ["/C"]]
["shell" (get (System/getenv) "SHELL") nil])
(dorun (map register-interpreter! [(into ["shell"] (shell/shell-cmd-prelude))
["ruby" "ruby" nil]
["python" "python" nil]
["node" "node" nil]
Expand Down
19 changes: 13 additions & 6 deletions src/drake/shell.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns drake.shell
(:require [clojure.string :refer [join]]
[clojure.tools.logging :refer [debug]]
[clojure.tools.logging :as log :refer [debug]]
[clojure.java.io :refer [as-file]]
[slingshot.slingshot :refer [throw+]]
[fs.core :as fs]
Expand Down Expand Up @@ -50,6 +50,14 @@
(catch java.lang.InterruptedException _) ;; if we interrupt
(catch java.io.IOException _)))) ;; if the process dies

(defn shell-cmd-prelude [& unix-suffix]
(if (.startsWith (System/getProperty "os.name") "Win")
["cmd" "/C"]
(cons (or (get (System/getenv) "SHELL")
(do (log/warnf "$SHELL not set; defaulting to /bin/sh")
"/bin/sh"))
unix-suffix)))

(defn shell
"Runs the specified command and arguments using the system shell.
Expand Down Expand Up @@ -83,16 +91,15 @@
[& args]
(let [[cmd {:keys [out err die use-shell no-stdin env replace-env exec-dir] :as opts}]
(split-with string? args)
windows? (.startsWith (System/getProperty "os.name") "Win")
env (as-env-strings (if replace-env
env
(merge (into {} (System/getenv)) env)))
^"[Ljava.lang.String;" cmd-for-exec
(into-array (if-not use-shell
(into-array String
(if-not use-shell
cmd
[(if windows? "cmd" (get (System/getenv) "SHELL"))
(if windows? "/C" "-c")
(join " " cmd)]))
`[~@(shell-cmd-prelude "-c")
~(join " " cmd)]))
proc (.exec (Runtime/getRuntime)
cmd-for-exec
^"[Ljava.lang.String;" env
Expand Down

0 comments on commit 13817e4

Please sign in to comment.