@@ -10,67 +10,64 @@ newaction {
1010 execute = function () main () end
1111}
1212
13- newoption {
14- trigger = " debug-symbols" ,
15- description = " Makes a release which contains public debug symbols, which allows better user debugging" ,
16- }
17-
1813newoption {
1914 trigger = " toolset" ,
2015 value = " tools" ,
21- description = " The toolset used to compile the release build" ,
22- allowed = {
23- { " vs2013" , " Microsoft Visual Studio 2013" },
24- { " vs2015" , " Microsoft Visual Studio 2015" },
25- { " gcc" , " GNU Compiler Collection" }
26- }
16+ description = " The toolset used to compile the release build (vs20xx or gcc)" ,
2717}
2818
19+ newoption {
20+ trigger = " final-release" ,
21+ description = " Public release build."
22+ }
2923
3024toolset = _OPTIONS [" toolset" ]
25+ final_flag = _OPTIONS [" final-release" ] and " --final-release" or " "
3126action = (toolset == " gcc" and " gmake" or toolset )
3227compiler = (toolset == " gcc" and " gcc" or " cl" )
3328build = (toolset == " gcc" and " make" or " msbuild" )
3429
3530function main ()
3631
37- local debugsymbols = _OPTIONS [" debug-symbols" ]
38-
3932 if not toolset then
4033 print (" No toolset defined.\n Aborting." )
4134 exit ()
4235 end
4336
37+ if toolset ~= " gcc" and not toolset :match (" ^vs" ) then
38+ print (" Unsupported toolset '" .. toolset .. " ' (use a vs* premake action or gcc).\n Aborting." )
39+ exit ()
40+ end
41+
42+ require_tools ()
43+
4444 local install = function ()
4545 print " Making release directory tree..."
46- execute (" premake5 install ./release/" )
47- os .copyfile (" ./release/modloader/.data/Readme.md" , " ./release/Readme.txt" )
48- os .copyfile (" ./release/modloader/.data/Leia-me.md" , " ./release/Leia-me.txt" )
49- os .mkdir (" ./release/modloader/.profiles" )
46+ execute (" premake5 install ./release/binaries/ " )
47+ os .copyfile (" ./release/binaries/ modloader/.data/Readme.md" , " ./release/binaries /Readme.txt" )
48+ os .copyfile (" ./release/binaries/ modloader/.data/Leia-me.md" , " ./release/binaries /Leia-me.txt" )
49+ os .mkdir (" ./release/binaries/ modloader/.profiles" )
5050 end
5151
5252 print " Cleaning workspace..."
5353 execute (" premake5 clean" )
5454
5555 print " Generating build files..."
56- if toolset == " gmake " then
57- execute (string.format (" premake5 %s --cc=%s --outdir=build_temp" , action , compiler ))
56+ if toolset == " gcc " then
57+ execute (string.format (" premake5 %s --cc=%s --outdir=build_temp%s " , action , compiler , final_flag ))
5858 else
59- execute (string.format (" premake5 %s --outdir=build_temp" , action ))
59+ execute (string.format (" premake5 %s --outdir=build_temp%s " , action , final_flag ))
6060 end
6161
6262 print " Building..."
6363 if build == " msbuild" then
64-
64+
6565 -- also use 'set CL=/MP' at release.bat
6666 execute (" msbuild build_temp/modloader.sln /p:configuration=Release /p:platform=Win32 /m" )
6767
68- -- Install THEN move pdbs
6968 install ()
70- if debugsymbols then
71- pdbmove ()
72- end
73-
69+ pdbpackage ()
70+
7471 elseif compiler == " gcc" then
7572
7673 local cwd = os .getcwd ()
@@ -81,9 +78,9 @@ function main()
8178 -- Strip binaries (ALWAYS)
8279 gccstrip ()
8380 -- striping is not related to symbols, to have symbols send --export-all-symbols to the linker
84-
81+
8582 install ()
86-
83+
8784 else
8885 print (" Internal error" )
8986 exit ()
@@ -92,22 +89,21 @@ function main()
9289 os .rmdir (" build_temp" )
9390end
9491
92+ function pdbpackage ()
93+ print (" Packaging stripped debug symbols (release/symbols/)..." )
9594
95+ os .mkdir (" release/symbols" )
96+ os .mkdir (" release/symbols/modloader/.data/plugins/gta3" )
9697
98+ execute (' pdbcopy "bin/modloader.pdb" "release/symbols/modloader.pdb" -p' )
9799
98- function pdbmove ()
99- print (" Moving PDB files into release..." )
100- pdbcopy (" bin" , " release" , false )
101- pdbcopy (" bin/plugins" , " release/modloader/.data/plugins" , true )
102- end
103-
104- function pdbcopy (src , dest , recursive )
105- local cwd = os .getcwd ()
106- os .chdir (src )
107- for i , file in ipairs (os .matchfiles (recursive and " **.pdb" or " *.pdb" )) do
108- execute (string.format ([[ pdbcopy "%s" "%s" -p]] , file , cwd .. ' /' .. dest .. ' /' .. file ))
100+ for i , file in ipairs (os .matchfiles (" bin/plugins/gta3/*.pdb" )) do
101+ local name = path .getname (file )
102+ execute (string.format (
103+ ' pdbcopy "bin/plugins/gta3/%s" "release/symbols/modloader/.data/plugins/gta3/%s" -p' ,
104+ name , name
105+ ))
109106 end
110- os .chdir (cwd )
111107end
112108
113109function gccstrip ()
@@ -124,16 +120,45 @@ function gccstrip()
124120 os .chdir (cwd )
125121end
126122
123+ function require_tools ()
124+ require_on_path (" premake5" ,
125+ " Install Premake 5 and add it to PATH." )
127126
127+ if build == " msbuild" then
128+ require_on_path (" msbuild" ,
129+ " Install Visual Studio with MSBuild, then run this from the x86 Native Tools Command Prompt." )
130+ require_on_path (" pdbcopy" ,
131+ " Install the Debugging Tools for Windows component from the Windows SDK," ..
132+ " then add %ProgramFiles(x86)%\\ Windows Kits\\ 10\\ Debuggers\\ x86 to PATH." )
133+ elseif compiler == " gcc" then
134+ require_on_path (" mingw32-make" ,
135+ " Install MinGW and add mingw32-make to PATH." )
136+ end
137+ end
128138
129-
139+ function require_on_path (name , hint )
140+ if not os .ishost (" windows" ) then
141+ return
142+ end
143+ local found = os .outputof (" where " .. name .. " 2>nul" )
144+ if not found or found == " " then
145+ print (" Error: " .. name .. " is not on PATH." )
146+ if hint then
147+ print (hint )
148+ end
149+ exit ()
150+ end
151+ end
130152
131153function execute (command )
132- os.execute (command )
154+ local result = os.execute (command )
155+ if result == 0 or result == true then
156+ return
157+ end
158+ print (" Command failed: " .. command .. " \n Aborting." )
159+ exit ()
133160end
134161
135162function exit ()
136163 os.exit ()
137164end
138-
139-
0 commit comments