Browse files

Add bootstrap.bat and its utility for Windows CMD shell

  • Loading branch information...
1 parent 74a4cb9 commit 0e72a6eaea2045916ff2446f9a0afec2324da842 @phongphan committed Mar 20, 2014
Showing with 146 additions and 0 deletions.
  1. +101 −0 script/bootstrap.bat
  2. +24 −0 script/download.vbs
  3. +21 −0 script/unzip.vbs
View
101 script/bootstrap.bat
@@ -0,0 +1,101 @@
+@ECHO OFF
+SETLOCAL EnableDelayedExpansion
+
+SET CLOJURE_RELEASE=1.5.1
+SET DJSON_RELEASE=0.2.3
+SET GCLOSURE_LIB_RELEASE=0.0-20130212-95c19e7f0f5f
+SET RHINO_RELEASE=1_7R3
+SET TREADER_RELEASE=0.8.3
+
+:: TOOLS
+SET DOWNLOAD=cscript /Nologo "%CD%\script\download.vbs"
+SET UNZIP=cscript /Nologo "%CD%\script\unzip.vbs"
+
+mkdir lib
+
+echo Fetching Clojure...
+%DOWNLOAD% http://repo1.maven.org/maven2/org/clojure/clojure/%CLOJURE_RELEASE%/clojure-%CLOJURE_RELEASE%.zip clojure-%CLOJURE_RELEASE%.zip
+%UNZIP% clojure-%CLOJURE_RELEASE%.zip .
+echo Copying clojure-%CLOJURE_RELEASE%\clojure-%CLOJURE_RELEASE%.jar to lib\clojure.jar...
+copy /Y clojure-%CLOJURE_RELEASE%\clojure-%CLOJURE_RELEASE%.jar lib\clojure.jar
+
+echo Cleaning up Clojure directory...
+rmdir /S /Q clojure-%CLOJURE_RELEASE%
+echo Cleaning up Clojure archive...
+del /F clojure-%CLOJURE_RELEASE%.zip
+
+echo Fetching data.json...
+%DOWNLOAD% http://repo1.maven.org/maven2/org/clojure/data.json/%DJSON_RELEASE%/data.json-%DJSON_RELEASE%.jar data.json-%DJSON_RELEASE%.jar
+echo Copying data.json-%DJSON_RELEASE%.jar to lib\data.json-%DJSON_RELEASE%.jar...
+copy /Y data.json-%DJSON_RELEASE%.jar lib/data.json-%DJSON_RELEASE%.jar
+echo Cleaning up data.json...
+del /F data.json-%DJSON_RELEASE%.jar
+
+echo Fetching Google Closure library...
+mkdir closure\library
+cd closure\library
+If "%1" == "--closure-library-head" (
+ echo Building against HEAD of Google Closure library...
+
+ svn >NUL 2>NUL
+ if not !ERRORLEVEL! == 9009 goto FETCH
+ echo No SVN found in PATH
+ EXIT /B 1
+:FETCH
+ svn info --non-interactive >NUL 2>NUL
+ If !ERRORLEVEL! == 0 (
+ echo Updating Google Closure library from HEAD...
+ svn update -q --non-interactive
+ ) Else (
+ echo Checking out HEAD of Google Closure library...
+ rmdir /S /Q *
+ svn checkout -q --non-interactive http://closure-library.googlecode.com/svn/trunk/ ./
+ )
+) Else (
+ %DOWNLOAD% http://repo1.maven.org/maven2/org/clojure/google-closure-library/%GCLOSURE_LIB_RELEASE%/google-closure-library-%GCLOSURE_LIB_RELEASE%.jar google-closure-library-%GCLOSURE_LIB_RELEASE%.jar
+ copy /Y google-closure-library-%GCLOSURE_LIB_RELEASE%.jar ..\..\lib\google-closure-library-%GCLOSURE_LIB_RELEASE%.jar
+ del /F google-closure-library-%GCLOSURE_LIB_RELEASE%.jar
+
+ echo Fetching Google Closure third party library...
+ %DOWNLOAD% http://repo1.maven.org/maven2/org/clojure/google-closure-library-third-party/%GCLOSURE_LIB_RELEASE%/google-closure-library-third-party-%GCLOSURE_LIB_RELEASE%.jar google-closure-library-third-party-%GCLOSURE_LIB_RELEASE%.jar
+ copy /Y google-closure-library-third-party-%GCLOSURE_LIB_RELEASE%.jar ..\..\lib\google-closure-library-third-party-$%CLOSURE_LIB_RELEASE%.jar
+ del /F google-closure-library-third-party-%GCLOSURE_LIB_RELEASE%.jar
+)
+cd ..
+
+echo Fetching Google Closure compiler...
+mkdir compiler
+cd compiler
+%DOWNLOAD% http://dl.google.com/closure-compiler/compiler-latest.zip compiler-latest.zip
+%UNZIP% compiler-latest.zip .
+echo Cleaning up Google Closure compiler archive...
+del /F compiler-latest.zip
+cd ..\..
+
+If "%1" == "--closure-library-head" (
+ echo Building lib\goog.jar...
+ echo jar cf ./lib/goog.jar -C closure/library/closure/ goog
+ jar cf ./lib/goog.jar -C closure/library/closure/ goog
+)
+
+echo Fetching Rhino...
+%DOWNLOAD% http://ftp.mozilla.org/pub/mozilla.org/js/rhino%RHINO_RELEASE%.zip rhino%RHINO_RELEASE%.zip
+%UNZIP% rhino%RHINO_RELEASE%.zip .
+echo Copying rhino%RHINO_RELEASE%\js.jar to lib\js.jar...
+copy /Y rhino%RHINO_RELEASE%\js.jar lib\js.jar
+echo Cleaning up Rhino directory...
+rmdir /S /Q rhino%RHINO_RELEASE%
+echo Cleaning up Rhino archive...
+del /F rhino%RHINO_RELEASE%.zip
+
+echo Copying closure\compiler\compiler.jar to lib\compiler.jar
+copy /Y closure\compiler\compiler.jar lib
+
+echo Fetching tools.reader %TREADER_RELEASE% ...
+%DOWNLOAD% http://repo1.maven.org/maven2/org/clojure/tools.reader/%TREADER_RELEASE%/tools.reader-%TREADER_RELEASE%.jar tools.reader-%TREADER_RELEASE%.jar
+
+echo Moving tools.reader.jar to lib\tools.reader.jar
+
+move /Y tools.reader-%TREADER_RELEASE%.jar lib\tools.reader-%TREADER_RELEASE%.jar
+
+echo [Bootstrap Completed]
View
24 script/download.vbs
@@ -0,0 +1,24 @@
+Sub Download(url, target)
+ WScript.Echo "Downloading... " & url
+
+ Set http = CreateObject("Microsoft.XMLHTTP")
+ Set stream = CreateObject("Adodb.Stream")
+ http.Open "GET", url, False
+ http.Send
+
+ WScript.Echo "Writing to... " & target
+ With stream
+ .Type = 1 ' Binary
+ .Open
+ .Write http.ResponseBody
+ .Savetofile target, 2 ' Always overwrite
+ End With
+End Sub
+
+if WScript.Arguments.Count < 2 then
+ WScript.Echo "Usage:"
+ WScript.Echo "cscript download.vbs URL DestinationPath"
+ WScript.Quit -1
+end if
+
+Download WScript.Arguments(0), WScript.Arguments(1)
View
21 script/unzip.vbs
@@ -0,0 +1,21 @@
+Sub Unzip(source, destination)
+ Set fso = CreateObject("Scripting.FileSystemObject")
+ If Not fso.FolderExists(destination) Then
+ fso.CreateFolder(destination)
+ End If
+
+ zipFile = fso.GetAbsolutePathName(source)
+ zipDest = fso.GetAbsolutePathName(destination)
+
+ set objShell = CreateObject("Shell.Application")
+ set filesInZip = objShell.NameSpace(zipFile).items
+ objShell.NameSpace(zipDest).CopyHere(filesInZip)
+End Sub
+
+if WScript.Arguments.Count < 2 then
+ WScript.Echo "Usage:"
+ WScript.Echo "cscript unzip.vbs ZipFile DestinationFolder"
+ WScript.Quit -1
+end if
+
+Unzip WScript.Arguments(0), WScript.Arguments(1)

0 comments on commit 0e72a6e

Please sign in to comment.