File: prepare_win_build_environment.ps1

package info (click to toggle)
libdigidoc 3.10.4%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 6,436 kB
  • sloc: ansic: 29,037; makefile: 15
file content (96 lines) | stat: -rw-r--r-- 3,364 bytes parent folder | download
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
#powershell -ExecutionPolicy ByPass -File prepare_win_build_environment.ps1 [-openssl] [-libxml2] [-zlib]
param(
	[string]$target = "C:\build",
	[string]$msbuild = "C:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild.exe",
	[string]$7zip = "C:\Program Files\7-Zip\7z.exe",
	[string]$cmake = "C:\Program Files (x86)\CMake\bin\cmake.exe",
	[string]$vcvars = "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat", #$env:VCINSTALLDIR
	[string]$opensslver = "openssl-1.0.2e",
	[string]$libxml2ver = "libxml2-2.9.3",
	[string]$zlibver = "zlib-1.2.8",
	[switch]$openssl = $false,
	[switch]$libxml2 = $false,
	[switch]$zlib = $false
)

$libdigidoc = split-path -parent $MyInvocation.MyCommand.Definition
if(!(Test-Path -Path $target)){
	New-Item -ItemType directory -Path $target
}
Push-Location -Path $target

$shell = new-object -com shell.application
$client = new-object System.Net.WebClient

function openssl() {
	$client.DownloadFile("https://www.openssl.org/source/$opensslver.tar.gz", "$target\$opensslver.tar.gz")
	& $7zip x "$opensslver.tar.gz"
	& $7zip x "$opensslver.tar"
	Push-Location -Path $opensslver
	& $vcvars x86 "&&" perl Configure VC-WIN32 no-asm "&&" ms\do_ms "&&" nmake -f ms\ntdll.mak install INSTALLTOP=\OpenSSL-Win32 OPENSSLDIR=\OpenSSL-Win32\bin
	Pop-Location
	Remove-Item $opensslver -Force -Recurse

	& $7zip x "$opensslver.tar"
	Push-Location -Path $opensslver
	& $vcvars x86_amd64 "&&" perl Configure VC-WIN64A no-asm "&&" ms\do_win64a "&&" nmake -f ms\ntdll.mak install INSTALLTOP=\OpenSSL-Win64 OPENSSLDIR=\OpenSSL-Win64\bin
	Pop-Location
	Remove-Item $opensslver -Force -Recurse
	Remove-Item "$opensslver.tar"
}

function libxml2() {
	$client.DownloadFile("http://xmlsoft.org/sources/$libxml2ver.tar.gz", "$target\$libxml2ver.tar.gz")
	& $7zip x "$libxml2ver.tar.gz"
	& $7zip x "$libxml2ver.tar"

	Push-Location -Path "$libxml2ver\win32"
	& cscript configure.js iconv=no iso8859x=yes "prefix=$target\libxml2\x86"
	& $vcvars x86 "&&" nmake -f Makefile.msvc install
	Pop-Location
	Remove-Item $libxml2ver -Force -Recurse
	& $7zip x "$libxml2ver.tar"
	foreach($item in $shell.NameSpace("$libdigidoc\$libxml2ver-patches.zip").items()) {
		$shell.Namespace($target).CopyHere($item,0x14)
	}

	Push-Location -Path "$libxml2ver\win32"
	& cscript configure.js iconv=no iso8859x=yes "prefix=$target\libxml2\x64"
	& $vcvars x86_amd64 "&&" nmake -f Makefile.msvc install
	Pop-Location
	Remove-Item $libxml2ver -Force -Recurse
	Remove-Item "$libxml2ver.tar" -Force -Recurse
}

function zlib() {
	$client.DownloadFile("http://zlib.net/$zlibver.tar.gz", "$target\$zlibver.tar.gz")
	& $7zip x "$zlibver.tar.gz"
	& $7zip x "$zlibver.tar"
	Push-Location -Path $zlibver
	& $vcvars x86 "&&" $cmake -DBUILD_SHARED_LIBS=YES -DCMAKE_BUILD_TYPE=Release "-DCMAKE_INSTALL_PREFIX=$target\zlib\x86" "-GNMake Makefiles" . "&&" nmake install
	Pop-Location
	Remove-Item $zlibver -Force -Recurse

	& $7zip x "$zlibver.tar"
	Push-Location -Path $zlibver
	& $vcvars x86_amd64 "&&" $cmake -DBUILD_SHARED_LIBS=YES -DCMAKE_BUILD_TYPE=Release "-DCMAKE_INSTALL_PREFIX=$target\zlib\x64" "-GNMake Makefiles" . "&&" nmake install
	Pop-Location
	Remove-Item $zlibver -Force -Recurse
	Remove-Item "$zlibver.tar"
}

if($openssl) {
	openssl
}
if($libxml2) {
	libxml2
}
if($zlib) {
	zlib
}
if(!$openssl -and !$libxml2 -and !$zlib) {
	openssl
	libxml2
	zlib
}
Pop-Location