1
+ $ErrorActionPreference = " Stop"
2
+ $root = Resolve-Path " $PSScriptRoot \.."
3
+ $shell = New-Object - com shell.application
4
+
5
+ # Read white listed dependency version info from the /bin/sh script and store in variables
6
+ Get-Content $root \script\bootstrap |
7
+ Where-Object { $_ -match ' ^\s*(\w+)\s*=\s*\"([^\"]*)\"\s*$' } |
8
+ Where-Object { $matches [1 ] -in " CLOJURE_RELEASE" , " CLOSURE_RELEASE" ,
9
+ " DJSON_RELEASE" , " GCLOSURE_LIB_RELEASE" , " RHINO_RELEASE" , " TREADER_RELEASE" } |
10
+ Foreach-Object { New-Variable $matches [1 ] $matches [2 ] - Scope private }
11
+
12
+ function Get-WebResource ($url , $dstPath ) {
13
+ Write-Verbose " Downloading '$url ' -> '$dstPath '"
14
+ Invoke-RestMethod $url - OutFile $dstPath
15
+ }
16
+
17
+ function Expand-ZipFile ($srcPath , $dstDir , $items ) {
18
+ Write-Verbose " Unzipping '$srcPath '"
19
+
20
+ function Get-ShellFolder ($dir ) {
21
+ $folder = $shell.NameSpace ($dir )
22
+ if ($folder -eq $null ) {
23
+ throw " Failed to bind to folder '$dir '"
24
+ }
25
+ $folder
26
+ }
27
+
28
+ function Copy-ShellItem ([Parameter (ValueFromPipeline = $true )] $src ) {
29
+ process {
30
+ Write-Verbose " Expanding '$ ( $src.Path ) ' -> '$dstDir '"
31
+ $dstFolder.CopyHere ($src , 4 + 16 + 1024 )
32
+ }
33
+ }
34
+
35
+ function Parse-ShellItem ([Parameter (ValueFromPipeline = $true )] $name ) {
36
+ process {
37
+ $x = $srcFolder.ParseName ($name )
38
+ if ($x -eq $null ) {
39
+ throw " Failed fo find item '$name ' in zip file '$srcPath '"
40
+ }
41
+ $x
42
+ }
43
+ }
44
+
45
+ $srcFolder = Get-ShellFolder ($srcPath )
46
+ $dstFolder = Get-ShellFolder ($dstDir )
47
+
48
+ if ($items -ne $null ) {
49
+ $items | Parse- ShellItem | Copy-ShellItem
50
+ }
51
+ else {
52
+ $srcFolder.Items () | Copy-ShellItem
53
+ }
54
+ }
55
+
56
+ function Move-File ($srcPath , $dstPath ) {
57
+ Delete- File $dstPath
58
+ Write-Verbose " Moving '$srcPath ' -> '$dstPath '"
59
+ Move-Item $srcPath $dstPath
60
+ }
61
+
62
+ function Copy-File ($srcPath , $dstPath ) {
63
+ Delete- File $dstPath
64
+ Write-Verbose " Copying '$srcPath ' -> '$dstPath '"
65
+ Copy-Item $srcPath $dstPath
66
+ }
67
+
68
+ function Delete-File ([Parameter (ValueFromPipeline = $true )] $path )
69
+ {
70
+ process {
71
+ if (Test-Path $path ) {
72
+ Write-Verbose " Deleting '$path '"
73
+ Remove-Item $path - Recurse
74
+ }
75
+ }
76
+ }
77
+
78
+ function Make-Dir ($dir ) {
79
+ if (! (Test-Path $dir - Type Container)) {
80
+ Write-Verbose " Making directory '$dir '"
81
+ New-Item $dir - ItemType Directory | Out-Null
82
+ }
83
+ }
84
+
85
+ Make- Dir $root \lib
86
+ Make- Dir $root \closure\library
87
+ Make- Dir $root \closure\compiler
88
+
89
+ Write-Host " Fetching Clojure..."
90
+ Get-WebResource `
91
+ https:// repo1.maven.org/ maven2/ org/ clojure/ clojure/ $CLOJURE_RELEASE / clojure- $CLOJURE_RELEASE.zip `
92
+ $root \clojure- $CLOJURE_RELEASE.zip
93
+ Delete- File $root \lib\clojure- $CLOJURE_RELEASE.jar
94
+ Expand-ZipFile $root \clojure- $CLOJURE_RELEASE.zip $root \lib clojure- $CLOJURE_RELEASE \clojure- $CLOJURE_RELEASE.jar
95
+ Move-File $root \lib\clojure- $CLOJURE_RELEASE.jar $root \lib\clojure.jar
96
+ Delete- File $root \clojure- $CLOJURE_RELEASE.zip
97
+
98
+ Write-Host " Fetching data.json..."
99
+ Get-WebResource `
100
+ https:// repo1.maven.org/ maven2/ org/ clojure/ data .json/ $DJSON_RELEASE / data .json- $DJSON_RELEASE.jar `
101
+ $root \lib\data .json- $DJSON_RELEASE.jar
102
+
103
+ # TODO: Implement Closure SVN support
104
+ Write-Host " Fetching Google Closure library..."
105
+ Get-WebResource `
106
+ https:// repo1.maven.org/ maven2/ org/ clojure/ google- closure- library/ $GCLOSURE_LIB_RELEASE / google- closure- library- $GCLOSURE_LIB_RELEASE.jar `
107
+ $root \lib\google- closure- library- $GCLOSURE_LIB_RELEASE.jar
108
+ Get-WebResource `
109
+ https:// repo1.maven.org/ maven2/ org/ clojure/ google- closure- library- third- party/ $GCLOSURE_LIB_RELEASE / google- closure- library- third- party- $GCLOSURE_LIB_RELEASE.jar `
110
+ $root \lib\google- closure- library- third- party- $GCLOSURE_LIB_RELEASE.jar
111
+
112
+ Write-Host " Fetching Google Closure compiler..."
113
+ Get-WebResource `
114
+ https:// dl.google.com / closure- compiler/ compiler- $CLOSURE_RELEASE.zip `
115
+ $root \compiler- $CLOSURE_RELEASE.zip
116
+ Get-ChildItem $root \closure\compiler\* | Delete- File
117
+ Expand-ZipFile $root \compiler- $CLOSURE_RELEASE.zip $root \closure\compiler
118
+ Copy-File $root \closure\compiler\compiler.jar $root \lib\compiler.jar
119
+ Delete- File $root \compiler- $CLOSURE_RELEASE.zip
120
+
121
+ Write-Host " Fetching Rhino..."
122
+ Get-WebResource `
123
+ https:// github.com / mozilla/ rhino/ releases/ download/ Rhino${RHINO_RELEASE} _RELEASE/ rhino$RHINO_RELEASE.zip `
124
+ $root \rhino$RHINO_RELEASE.zip
125
+ Delete- File $root \lib\js.jar
126
+ Expand-ZipFile $root \rhino$RHINO_RELEASE.zip $root \lib rhino$RHINO_RELEASE \js.jar
127
+ Delete- File $root \rhino$RHINO_RELEASE.zip
128
+
129
+ Write-Host " Fetching tools.reader $TREADER_RELEASE ..."
130
+ Get-WebResource `
131
+ https:// repo1.maven.org/ maven2/ org/ clojure/ tools.reader/ $TREADER_RELEASE / tools.reader- $TREADER_RELEASE.jar `
132
+ $root \lib\tools.reader- $TREADER_RELEASE.jar
133
+
134
+ Write-Host " [Bootstrap Completed]"
0 commit comments