-
Notifications
You must be signed in to change notification settings - Fork 1
/
build_lua.ps1
74 lines (58 loc) · 1.63 KB
/
build_lua.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
74
#requires -version 3.0
# Author: Jon Maken
# License: 3-clause BSD
# Revision: 2021-05-31 00:56:59 -0600
param(
[parameter(Mandatory=$true,
Position=0,
HelpMessage='lua version to build (eg - 5.4.3)')]
[validateset('5.4.3')]
[alias('v')]
[string] $version,
[parameter(HelpMessage='perform a 64-bit build')]
[switch] $x64
)
$libname = 'lua'
$source = "${libname}-${version}.tar.gz"
$build_name = "${libname}-${version}"
$repo_root = "https://www.lua.org/ftp/"
$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-Archive
# patch, configure, build, archive
Push-Location "${build_src_dir}"
# activate toolchain
Activate-Toolchain
# configure
Configure-Build {
$maj_min = ($version -split '\.')[0..1] -join ''
$script:to_bin = 'lua.exe','luac.exe',"lua${maj_min}.dll"
$script:to_inc = 'lua.h','luaconf.h','lualib.h','lauxlib.h','lua.hpp'
$script:to_lib = 'liblua.a'
}
# build
New-Build {
Push-Location src
sh -c "make mingw" | Out-Null
Pop-Location
}
# install
Push-Location src
New-Item "$install_dir/bin","$install_dir/include","$install_dir/lib" -itemtype directory | Out-Null
mv $to_bin "$install_dir/bin"
mv $to_inc "$install_dir/include"
mv $to_lib "$install_dir/lib"
mv (Resolve-Path ../doc) "$install_dir"
Pop-Location
# archive
Archive-Build
Pop-Location
# cleanup
Clean-Build