Elffuss BraidHub

kikocis/java-driver public

52c6910bffed · 5.0 KiBRawPermalink
1Add-Type -AssemblyName System.IO.Compression.FileSystem
2
3$dep_dir="C:\Users\appveyor\deps"
4If (!(Test-Path $dep_dir)) {
5 Write-Host "Creating $($dep_dir)"
6 New-Item -Path $dep_dir -ItemType Directory -Force
7}
8
9$apr_platform = "Win32"
10$openssl_platform = "Win32"
11$vc_platform = "x86"
12$env:PYTHON="C:\Python27"
13$env:OPENSSL_PATH="C:\OpenSSL-Win32"
14If ($env:PLATFORM -eq "X64") {
15 $apr_platform = "x64"
16 $vc_platform = "x64"
17 $env:PYTHON="C:\Python27-x64"
18 $env:OPENSSL_PATH="C:\OpenSSL-Win64"
19}
20
21$env:JAVA_HOME="C:\Program Files\Java\jdk$($env:java_version)"
22$env:JAVA_8_HOME="C:\Program Files\Java\jdk1.8.0"
23$env:PATH="$($env:PYTHON);$($env:PYTHON)\Scripts;$($env:JAVA_HOME)\bin;$($env:OPENSSL_PATH)\bin;$($env:PATH)"
24$env:CCM_PATH="$($dep_dir)\ccm"
25
26$apr_dist_path = "$($dep_dir)\apr"
27# Build APR if it hasn't been previously built.
28If (!(Test-Path $apr_dist_path)) {
29 Write-Host "Cloning APR"
30 $apr_path = "C:\Users\appveyor\apr"
31 Start-Process git -ArgumentList "clone --branch=1.5.2 --depth=1 https://github.com/apache/apr.git $($apr_path)" -Wait -nnw
32 Write-Host "Setting Visual Studio Environment to VS 2015"
33 Push-Location "$($env:VS140COMNTOOLS)\..\..\VC"
34 cmd /c "vcvarsall.bat $vc_platform & set" |
35 foreach {
36 if ($_ -match "=") {
37 $v = $_.split("="); Set-Item -force -path "ENV:\$($v[0])" -value "$($v[1])"
38 }
39 }
40 Pop-Location
41 Write-Host "Building APR (an error may be printed, but it will still build)"
42 Push-Location $($apr_path)
43 cmd /c nmake -f Makefile.win ARCH="$apr_platform Release" PREFIX=$($apr_dist_path) buildall install
44 Pop-Location
45 Write-Host "Done Building APR"
46}
47$env:PATH="$($apr_dist_path)\bin;$($env:PATH)"
48
49# Install Ant and Maven
50$ant_base = "$($dep_dir)\ant"
51$ant_path = "$($ant_base)\apache-ant-1.9.7"
52If (!(Test-Path $ant_path)) {
53 Write-Host "Installing Ant"
54 $ant_url = "https://www.dropbox.com/s/lgx95x1jr6s787l/apache-ant-1.9.7-bin.zip?dl=1"
55 $ant_zip = "C:\Users\appveyor\apache-ant-1.9.7-bin.zip"
56 (new-object System.Net.WebClient).DownloadFile($ant_url, $ant_zip)
57 [System.IO.Compression.ZipFile]::ExtractToDirectory($ant_zip, $ant_base)
58}
59$env:PATH="$($ant_path)\bin;$($env:PATH)"
60
61$maven_base = "$($dep_dir)\maven"
62$maven_path = "$($maven_base)\apache-maven-3.2.5"
63If (!(Test-Path $maven_path)) {
64 Write-Host "Installing Maven"
65 $maven_url = "https://www.dropbox.com/s/fh9kffmexprsmha/apache-maven-3.2.5-bin.zip?dl=1"
66 $maven_zip = "C:\Users\appveyor\apache-maven-3.2.5-bin.zip"
67 (new-object System.Net.WebClient).DownloadFile($maven_url, $maven_zip)
68 [System.IO.Compression.ZipFile]::ExtractToDirectory($maven_zip, $maven_base)
69}
70$env:PATH="$($maven_path)\bin;$($env:PATH)"
71
72$jdks = @("1.6.0", "1.7.0", "1.8.0")
73foreach ($jdk in $jdks) {
74 $java_dir = "C:\Program Files\Java\jdk$jdk"
75 $jce_target = "$java_dir\jre\lib\security"
76 $jce_indicator = "$jce_target\README.txt"
77 # Install Java Cryptographic Extensions, needed for SSL.
78 # If this file doesn't exist we know JCE hasn't been installed.
79 If (!(Test-Path $jce_indicator)) {
80 Write-Host "Installing JCE for $jdk"
81 $zip = "$dep_dir\jce_policy-$jdk.zip"
82 $url = "https://www.dropbox.com/s/po4308hlwulpvep/UnlimitedJCEPolicyJDK7.zip?dl=1"
83 $extract_folder = "UnlimitedJCEPolicy"
84 If ($jdk -eq "1.8.0") {
85 $url = "https://www.dropbox.com/s/al1e6e92cjdv7m7/jce_policy-8.zip?dl=1"
86 $extract_folder = "UnlimitedJCEPolicyJDK8"
87 }
88 ElseIf ($jdk -eq "1.6.0") {
89 $url = "https://www.dropbox.com/s/dhrtucxcif4n11k/jce_policy-6.zip?dl=1"
90 $extract_folder = "jce"
91 }
92 # Download zip to staging area if it doesn't exist, we do this because
93 # we extract it to the directory based on the platform and we want to cache
94 # this file so it can apply to all platforms.
95 if(!(Test-Path $zip)) {
96 (new-object System.Net.WebClient).DownloadFile($url, $zip)
97 }
98
99 [System.IO.Compression.ZipFile]::ExtractToDirectory($zip, $jce_target)
100
101 $jcePolicyDir = "$jce_target\$extract_folder"
102 Move-Item $jcePolicyDir\* $jce_target\ -force
103 Remove-Item $jcePolicyDir
104 }
105}
106
107# Install Python Dependencies for CCM.
108Write-Host "Installing Python Dependencies for CCM"
109Start-Process python -ArgumentList "-m pip install psutil pyYaml six" -Wait -nnw
110
111# Clone ccm from git and use master.
112If (!(Test-Path $env:CCM_PATH)) {
113 Write-Host "Cloning CCM"
114 Start-Process git -ArgumentList "clone https://github.com/pcmanus/ccm.git $($env:CCM_PATH)" -Wait -nnw
115}
116
117# Copy ccm -> ccm.py so windows knows to run it.
118If (!(Test-Path $env:CCM_PATH\ccm.py)) {
119 Copy-Item "$env:CCM_PATH\ccm" "$env:CCM_PATH\ccm.py"
120}
121$env:PYTHONPATH="$($env:CCM_PATH);$($env:PYTHONPATH)"
122$env:PATH="$($env:CCM_PATH);$($env:PATH)"
123
124# Predownload cassandra version for CCM if it isn't already downloaded.
125If (!(Test-Path C:\Users\appveyor\.ccm\repository\$env:cassandra_version)) {
126 Write-Host "Preinstalling C* $($env:cassandra_version)"
127 Start-Process python -ArgumentList "$($env:CCM_PATH)\ccm.py create -v $($env:cassandra_version) -n 1 predownload" -Wait -nnw
128 Start-Process python -ArgumentList "$($env:CCM_PATH)\ccm.py remove predownload" -Wait -nnw
129}