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