forked from thelink2012/modloader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.lua
139 lines (104 loc) · 3.47 KB
/
release.lua
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
--[[
release.lua
Prepares a public release
Use 'premake5 --file=release.lua --help' for help
--]]
newaction {
trigger = "prepare",
description = "Automatically makes 'n builds a release build, preparing it to be zipped into a public release",
execute = function() main() end
}
newoption {
trigger = "debug-symbols",
description = "Makes a release which contains public debug symbols, which allows better user debugging",
}
newoption {
trigger = "toolset",
value = "tools",
description = "The toolset used to compile the release build",
allowed = {
{ "vs2013", "Microsoft Visual Studio 2013" },
{ "vs2015", "Microsoft Visual Studio 2015" },
{ "gcc", "GNU Compiler Collection" }
}
}
toolset = _OPTIONS["toolset"]
action = (toolset == "gcc" and "gmake" or toolset)
compiler = (toolset == "gcc" and "gcc" or "cl")
build = (toolset == "gcc" and "make" or "msbuild")
function main()
local debugsymbols = _OPTIONS["debug-symbols"]
if not toolset then
print("No toolset defined.\nAborting.")
exit()
end
local install = function()
print "Making release directory tree..."
execute("premake5 install ./release/")
os.copyfile("./release/modloader/.data/Readme.md", "./release/Readme.txt")
os.copyfile("./release/modloader/.data/Leia-me.md", "./release/Leia-me.txt")
os.mkdir("./release/modloader/.profiles")
end
print "Cleaning workspace..."
execute("premake5 clean")
print "Generating build files..."
if toolset == "gmake" then
execute(string.format("premake5 %s --cc=%s --outdir=build_temp", action, compiler))
else
execute(string.format("premake5 %s --outdir=build_temp", action))
end
print "Building..."
if build == "msbuild" then
-- also use 'set CL=/MP' at release.bat
execute("msbuild build_temp/modloader.sln /p:configuration=Release /p:platform=Win32 /m")
-- Install THEN move pdbs
install()
if debugsymbols then
pdbmove()
end
elseif compiler == "gcc" then
local cwd = os.getcwd()
os.chdir("build_temp")
execute("mingw32-make CC=gcc")
os.chdir(cwd)
-- Strip binaries (ALWAYS)
gccstrip()
-- striping is not related to symbols, to have symbols send --export-all-symbols to the linker
install()
else
print("Internal error")
exit()
end
os.rmdir("build_temp")
end
function pdbmove()
print("Moving PDB files into release...")
pdbcopy("bin", "release", false)
pdbcopy("bin/plugins", "release/modloader/.data/plugins", true)
end
function pdbcopy(src, dest, recursive)
local cwd = os.getcwd()
os.chdir(src)
for i, file in ipairs(os.matchfiles(recursive and "**.pdb" or "*.pdb")) do
execute(string.format([[pdbcopy "%s" "%s" -p]], file, cwd .. '/' .. dest .. '/' .. file))
end
os.chdir(cwd)
end
function gccstrip()
print "Stripping GCC symbols..."
local cwd = os.getcwd()
os.chdir("bin")
for i, file in ipairs(os.matchfiles("*.asi")) do
execute(string.format([[strip "%s"]], file))
end
for i, file in ipairs(os.matchfiles("**.dll")) do
execute(string.format([[strip "%s"]], file))
end
os.chdir(cwd)
end
function execute(command)
os.execute(command)
end
function exit()
os.exit()
end