-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild_unqlite.ps1
73 lines (57 loc) · 1.78 KB
/
build_unqlite.ps1
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
#requires -version 3.0
# Author: Jon Maken
# License: 3-clause BSD
# Revision: 2013-11-10 15:10:29 -0600
param(
[parameter(Mandatory=$true,
Position=0,
HelpMessage='unqlite version to build (eg - 20130825-116).')]
[validateset('20130825-116')]
[alias('v')]
[string] $version,
[parameter(HelpMessage='perform a 64-bit build')]
[switch] $x64
)
$libname = 'unqlite'
$source = "${libname}-db-${version}.zip"
$source_dir = "${libname}-${version}"
$repo_root = 'http://unqlite.org/db/'
$archive = "${repo_root}${source}"
$hash_uri = "https://raw.github.com/jonforums/buildlets/master/hashery/${libname}.sha1"
# source the buildlet library
. "$PWD\buildlet_utils.ps1"
# download source archive
Fetch-Archive
# download hash data and validate source archive
Validate-Archive
# extract
Extract-CustomArchive
# patch, configure, build, archive
Push-Location "${source_dir}"
# activate toolchain
Activate-Toolchain
# configure
Configure-Build {
$defines = '-D_WIN32_WINNT=0x0501'
$script:cflags = "-g $defines -Wall -Wextra -O2"
}
# build
New-Build {
sh -c "gcc $cflags -c ${libname}.c -o ${libname}.o" | Out-Null
sh -c "gcc -shared -Wl,--output-def,${libname}.def -Wl,--out-implib,lib${libname}.dll.a -o ${libname}.dll ${libname}.o"
sh -c "ar rcs lib${libname}.a ${libname}.o" | Out-Null
}
# stage
Stage-Build {
New-Item "$install_dir/bin","$install_dir/include", "$install_dir/lib" `
-itemtype directory | Out-Null
cp "${libname}.dll" "$install_dir/bin" | Out-Null
cp "${libname}.h" "$install_dir/include" | Out-Null
cp "lib${libname}.a", "lib${libname}.dll.a" "$install_dir/lib" | Out-Null
cp "${libname}.def" "$install_dir/lib" | Out-Null
}
# archive
Archive-Build
Pop-Location
# cleanup
Clean-Build