Skip to content

Commit

Permalink
Merge remote branch 'lozh/windows-fixes'
Browse files Browse the repository at this point in the history
  • Loading branch information
technomancy committed Jul 29, 2010
2 parents 0b0a30e + e5904be commit c461fa7
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 18 deletions.
30 changes: 16 additions & 14 deletions bin/lein
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@

VERSION="1.2.1-SNAPSHOT"

# Make sure classpath is in unix format for manipulating, then put
# it back to windows format when we use it
if [ "$OSTYPE" = "cygwin" ]; then
CLASSPATH=`cygpath -up $CLASSPATH`
fi

CLASSPATH="$(ls -1 lib/dev/*jar 2> /dev/null | tr \\n \:)":src/:$CLASSPATH
LEIN_JAR="$HOME/.m2/repository/leiningen/leiningen/$VERSION/leiningen-$VERSION-standalone.jar"
CLOJURE_JAR="$HOME/.m2/repository/org/clojure/clojure/1.2.0-beta1/clojure-1.2.0-beta1.jar"
NULL_DEVICE=/dev/null

# normalize $0 on certain BSDs
if [ "$(dirname $0)" = "." ]; then
SCRIPT="$(which $(basename $0))"
if [ "$(dirname "$0")" = "." ]; then
SCRIPT="$(which $(basename "$0"))"
else
SCRIPT="$0"
fi
Expand All @@ -29,7 +35,7 @@ ORIGINAL_PWD=$PWD
while [ ! -r "$PWD/project.clj" ] && [ "$PWD" != "/" ] && [ ! $NOT_FOUND ]
do
cd ..
if [ "$(dirname $PWD)" == "/" ]; then
if [ "$(dirname "$PWD")" == "/" ]; then
NOT_FOUND=0
cd $ORIGINAL_PWD
fi
Expand Down Expand Up @@ -57,15 +63,6 @@ else
fi
fi

# Convert classpath to Windows format when running on Cygwin
if [ "$OSTYPE" = "cygwin" ]; then
CLASSPATH=`cygpath -wp $CLASSPATH`
CLOJURE_JAR=`cygpath -wp $CLOJURE_JAR`
fi

if [ $DEBUG ]; then
echo $CLASSPATH
fi

HTTP_CLIENT="wget -O"
if type -p curl >/dev/null 2>&1; then
Expand Down Expand Up @@ -118,11 +115,16 @@ elif [ "$1" = "upgrade" ]; then
esac
fi
else
if type -p cygpath >/dev/null 2>&1; then
if [ "$OSTYPE" = "cygwin" ]; then
# When running on Cygwin, use Windows-style paths for java
CLOJURE_JAR=`cygpath -w "$CLOJURE_JAR"`
CLASSPATH=`cygpath -wp "$CLASSPATH"`
NULL_DEVICE=NUL
NULL_DEVICE=NUL
fi

if [ $DEBUG ]; then
echo $CLASSPATH
echo $CLOJURE_JAR
fi

if [ "$1" = "repl" ] && [ -z $INSIDE_EMACS ] && [ $TERM != "dumb" ]; then
Expand Down
39 changes: 37 additions & 2 deletions bin/lein.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ rem and copied on %CLOJURE_JAR% path
rem this step is not necessary, because Leiningen standalone jar
rem contains Clojure as well

set CLOJURE_VERSION=1.1.0
set LEIN_VERSION=1.1.0
set CLOJURE_VERSION=1.2.0-beta1
set LEIN_VERSION=1.2.0

rem uncomment this and set paths explicitly
rem set LEIN_JAR=C:\Documents and Settings\wojcirob\.m2\repository\leiningen\leiningen\%LEIN_VERSION%\leiningen-%LEIN_VERSION%-standalone.jar
Expand Down Expand Up @@ -51,6 +51,11 @@ rem ##################################################
rem ##################################################
rem add jars found under "lib" directory to CLASSPATH
rem

call :FIND_DIR_CONTAINING_UPWARDS project.clj

if "%DIR_CONTAINING%" neq "" cd "%DIR_CONTAINING%"

setLocal EnableDelayedExpansion
set CP="
for /R ./lib %%a in (*.jar) do (
Expand Down Expand Up @@ -99,4 +104,34 @@ echo 2. clojure.jar from http://build.clojure.org/releases/
echo.
goto EOF

rem Find directory containing filename supplied in first argument
rem looking in current directory, and looking up the parent
rem chain until we find it, or run out
rem returns result in %DIR_CONTAINING%
rem empty string if we don't find it
:FIND_DIR_CONTAINING_UPWARDS
set DIR_CONTAINING=%CD%
set LAST_DIR=

:LOOK_AGAIN
if "%DIR_CONTAINING%" == "%LAST_DIR%" (
rem didn't find it
set DIR_CONTAINING=
goto :EOF
)

if EXIST "%DIR_CONTAINING%\%1" (
rem found it - use result in DIR_CONTAINING
goto :EOF
)

set LAST_DIR=%DIR_CONTAINING%
call :GET_PARENT_PATH "%DIR_CONTAINING%\.."
set DIR_CONTAINING=%PARENT_PATH%
goto :LOOK_AGAIN

:GET_PARENT_PATH
set PARENT_PATH=%~f1
goto :EOF

:EOF
12 changes: 10 additions & 2 deletions src/leiningen/compile.clj
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,16 @@
form `(do (def ~'*classpath* ~cp)
(set! ~'*warn-on-reflection*
~(:warn-on-reflection project))
~form)]
(.setValue (.createArg java) (prn-str form)))
~form)
readable-form (if (= (get-os) :windows)
;; work around java's command line handling on windows
;; http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6468220
;; This isn't perfect, but works for what's currently being passed
;; see http://www.perlmonks.org/?node_id=300286
;; for some of the landmines involved in doing it properly
(pr-str (pr-str form))
(prn-str form))]
(.setValue (.createArg java) readable-form))
;; to allow plugins and other tasks to customize
(when handler (handler java))
(.executeJava java)))
Expand Down

0 comments on commit c461fa7

Please sign in to comment.