-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpremake5.lua
More file actions
626 lines (519 loc) · 18 KB
/
premake5.lua
File metadata and controls
626 lines (519 loc) · 18 KB
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
workspace "UCodeLang"
configurations { "Debug", "Release", "Published" }
platforms {
"Win32" , "Win64" , "WinArm",
"linux32", "linux64", "linuxArm64",
"MacOS" ,
"Android",
"IOS",
"Web"
}
defines { "UCodeLangDebug", "ZYCORE_STATIC_BUILD", "ZYDIS_STATIC_BUILD", "UCodeLangExperimental" }
startproject "UCodeIDE"
cppdialect "c++17"
if os.host() == "windows" then
if os.is64bit() then
--if os.hostarch() == "ARM64" then
-- defaultplatform "WinArm"
--else
defaultplatform "Win64"
--end
else
defaultplatform "Win32"
end
end
if os.host() == "linux" then
if os.is64bit() then
--if os.hostarch() == "ARM64" then
-- defaultplatform "linuxArm64"
--else
defaultplatform "linux64"
--end
else
defaultplatform "linux32"
end
end
if os.host() == "macosx" then
if os.is64bit() then
defaultplatform "MacOS"
else
defaultplatform "MacOS"
end
end
OutDirPath = "%{cfg.platform}/%{cfg.buildcfg}"
UCPathExeDir = "%{wks.location}/Output/UCodeLangCL/" .. OutDirPath .. "/"
UCPathExeName = "uclang"
UCPathExe = UCPathExeDir .. UCPathExeName
if _ACTION == "vs2019" or _ACTION == "vs2022" then
flags { "MultiProcessorCompile" }
end
filter { "platforms:Win32" }
system "Windows"
architecture "x86"
filter { "platforms:Win64" }
system "Windows"
architecture "x86_64"
filter { "platforms:WinArm" }
system "Windows"
architecture "ARM64"
filter { "platforms:linuxArm64" }
system "linux"
architecture "ARM64"
gccprefix ("aarch64-linux-gnu-")
filter { "platforms:linux64" }
system "linux"
architecture "x86_64"
filter { "platforms:linux64" }
system "linux"
architecture "x86_64"
filter { "action:xcode*" }
xcodebuildsettings = { ["ALWAYS_SEARCH_USER_PATHS"] = "YES" }
filter { "platforms:MacOS" }
system "macosx"
architecture "universal"
toolset "clang"
filter { "platforms:Android" }
system "android"
architecture "ARM"
androidapilevel(22)
exceptionhandling("On")
rtti("On")
if cppstl ~= nil then
cppstl("c++")
end
filter { "platforms:IOS" }
system "ios"
architecture "universal"
toolset "clang"
filter { "platforms:Web" }
system "linux"
architecture "x86"
defines { "ZYAN_POSIX" }
targetextension(".html")
filter { "configurations:Debug" }
defines { "DEBUG" }
optimize "Debug"
symbols "On"
filter { "configurations:Release" }
defines { "RELASE" }
optimize "On"
symbols "On"
filter { "configurations:Published" }
defines { "PUBLISHED", "RELASE" }
optimize "Speed"
symbols "off"
filter {}
include "UCodeLang"
include "UCodeLangCL"
include "UCodeIDE"
include "UCApp"
include "UCodeLanguageSever"
include "UCodeLanguageSeverlib"
include "UCodeAPI/NStandardLibrary"
include "UCodeAPI/CompilerAPI"
include "UCodeAPI/StandardLibrary"
include "UCodeAPI/BuildSystem"
function executeorexit(str)
exit = os.execute(str)
if exit == nil then
os.exit(1)
end
if not exit == true then
os.exit(1)
end
end
newaction {
trigger = "export-commands",
description = "makes the compile-export-commands",
execute = function()
if os.istarget("linux") then
os.execute("premake5 export-compile-commands")
os.execute("cp ./compile_commands/debug_linux64.json ./compile_commands.json")
end
end
}
newaction {
trigger = "installdependencies",
description = "installsdependencies",
execute = function()
print("----installing Dependencies for " .. os.target())
if os.istarget("linux") then
executeorexit("sudo apt-get update")
print("----downloading libx11 Packages")
executeorexit("sudo apt-get install libxcursor-dev libxrandr-dev libxinerama-dev libxi-dev -y")
print("----downloading opengl Packages")
executeorexit("sudo apt install mesa-common-dev -y")
print("----installing tools completed");
end
if os.istarget("windows") then
end
if os.istarget("macosx") then
print("----downloading glfw Packages")
executeorexit("arch -arm64 brew install glfw")
print("----installing tools completed");
end
end
}
newaction {
trigger = "installinno",
description = "downloads inno setup and puts in output",
execute = function()
print("----installing inno setup tools for " .. os.target())
executeorexit("git clone https://github.com/LostbBlizzard/installed-inno Dependencies/bin/inno")
end
}
newaction {
trigger = "installzydis",
description = "downloads zydis and zycore and puts in Dependencies",
execute = function()
print("----installing zydis and zycore for " .. os.target())
executeorexit("git clone https://github.com/LostbBlizzard/zydis UCodeLang/Dependencies/zydis")
executeorexit("git clone https://github.com/LostbBlizzard/zycore-c UCodeLang/Dependencies/zycore")
end
}
---build
newaction {
trigger = "build",
description = "builds the everything",
execute = function()
if os.istarget("linux") then
executeorexit("make -j$(nproc)")
end
if os.istarget("windows") then
executeorexit("msbuild UCodeLang.sln /t:Build /p:Configuration=Debug /p:Platform=Win64 -maxcpucount")
end
if os.istarget("macosx") then
executeorexit("make UCApp -j$(getconf _NPROCESSORS_ONLN)")
executeorexit("make StandardLibrary -j$(getconf _NPROCESSORS_ONLN)")
executeorexit("make UCodeLanguageSever -j$(getconf _NPROCESSORS_ONLN)")
end
end
}
newaction {
trigger = "build_32bit",
description = "builds everything",
execute = function()
if os.istarget("linux") then
executeorexit("make UCApp config=debug_linux32 -j$(nproc)")
executeorexit("make StandardLibrary config=debug_linux32 -j$(getconf _NPROCESSORS_ONLN)")
executeorexit("make UCodeLanguageSever config=debug_linux32 -j$(nproc)")
end
if os.istarget("windows") then
executeorexit("msbuild UCodeLang.sln /t:Build /p:Configuration=Debug /p:Platform=Win32 -maxcpucount")
end
if os.istarget("macosx") then
-- We should do full build but macos keeps asking for glfw and i dont have a mac to fix it.
executeorexit("make UCApp -j$(getconf _NPROCESSORS_ONLN)")
executeorexit("make StandardLibrary -j$(getconf _NPROCESSORS_ONLN)")
executeorexit("make UCodeLanguageSever -j$(getconf _NPROCESSORS_ONLN)")
end
end
}
newaction {
trigger = "build_arm",
description = "builds everything",
execute = function()
if os.istarget("linux") then
executeorexit("make UCodeLang config=debug_linuxarm64 -j$(nproc)")
executeorexit("make UCodeLanguageSever config=debug_linuxarm64 -j$(nproc)")
executeorexit("make UCodeLangCL config=debug_linuxarm64 -j$(nproc)")
end
if os.istarget("windows") then
executeorexit("msbuild UCodeLang.sln /t:UCodeLang /p:Configuration=Debug /p:Platform=WinArm -maxcpucount")
executeorexit("msbuild UCodeLang.sln /t:UCodeLanguageSever /p:Configuration=Debug /p:Platform=WinArm -maxcpucount")
executeorexit("msbuild UCodeLang.sln /t:UCodeLangCL /p:Configuration=Debug /p:Platform=WinArm -maxcpucount")
end
if os.istarget("macosx") then
end
end
}
newaction {
trigger = "build_published",
description = "builds everything",
execute = function()
if os.istarget("linux") then
executeorexit("make config=published_linux64 -j$(nproc)")
end
if os.istarget("windows") then
executeorexit("msbuild UCodeLang.sln /t:Build /p:Configuration=Published /p:Platform=Win64 -maxcpucount")
end
if os.istarget("macosx") then
-- We should do full build but macos keeps asking for glfw and i dont have a mac to fix it.
executeorexit("make UCodeLang config=published_macos -j$(getconf _NPROCESSORS_ONLN)")
executeorexit("make StandardLibrary config=published_macos -j$(getconf _NPROCESSORS_ONLN)")
executeorexit("make UCodeLanguageSever config=published_macos -j$(getconf _NPROCESSORS_ONLN)")
end
end
}
newaction {
trigger = "build_published_32bit",
description = "builds the everything",
execute = function()
if os.istarget("linux") then
executeorexit("make UCodeLanguageSever config=published_linux32 -j$(nproc)")
executeorexit("make UCodeLangCL config=published_linux32 -j$(nproc)")
end
if os.istarget("windows") then
executeorexit("msbuild UCodeLang.sln /t:Build /p:Configuration=Published /p:Platform=Win32 -maxcpucount")
end
if os.istarget("macosx") then
executeorexit("make config=published_macos -j$(getconf _NPROCESSORS_ONLN)")
end
end
}
newaction {
trigger = "build_published_arm64",
description = "builds the everything",
execute = function()
if os.istarget("linux") then
executeorexit("make UCodeLang config=published_linuxarm64 -j$(nproc)")
executeorexit("make UCodeLanguageSever config=published_linuxarm64 -j$(nproc)")
executeorexit("make UCodeLangCL config=published_linuxarm64 -j$(nproc)")
end
if os.istarget("windows") then
executeorexit("msbuild UCodeLang.sln /t:UCodeLang /p:Configuration=Published /p:Platform=WinArm -maxcpucount")
executeorexit("msbuild UCodeLang.sln /t:UCodeLanguageSever /p:Configuration=Published /p:Platform=WinArm -maxcpucount")
executeorexit("msbuild UCodeLang.sln /t:UCodeLangCL /p:Configuration=Published /p:Platform=WinArm -maxcpucount")
end
if os.istarget("macosx") then
end
end
}
---test
newaction {
trigger = "test",
description = "runs tests",
execute = function()
if os.istarget("linux") then
executeorexit("cd ./UCApp;../Output/UCApp/linux64/Debug/UCApp --RunTests")
end
if os.istarget("windows") then
executeorexit("cd ./UCApp && ..\\Output\\UCApp\\Win64\\Debug\\UCApp.exe --RunTests")
end
if os.istarget("macosx") then
executeorexit("cd ./UCApp;../Output/UCApp/MacOS/Debug/UCApp --RunTests")
end
end
}
newaction {
trigger = "build_android",
description = "builds Android",
execute = function()
executeorexit(
"export PREMAKE_ANDROIDNDK_CONFIGURATIONS=\"Debug\";export NDK_PROJECT_PATH=.;export APP_BUILD_SCRIPT=UCodeLang/UCodeLang.prj.Android.mk;ndk-build UCodeLang config=Android -j$(getconf _NPROCESSORS_ONLN) NDK_APPLICATION_MK=UCodeLang.Application.mk")
end
}
newaction {
trigger = "test_32bit",
description = "runs test for 32bit mode",
execute = function()
if os.istarget("linux") then
executeorexit("cd ./UCApp;../Output/UCApp/linux32/Debug/UCApp --RunTests")
end
if os.istarget("windows") then
executeorexit("cd ./UCApp && ..\\Output\\UCApp\\Win32\\Debug\\UCApp.exe --RunTests")
end
if os.istarget("macosx") then
end
end
}
---clean
newaction {
trigger = "clean",
description = "clean project outputs",
execute = function()
if os.istarget("linux") then
executeorexit("make clean")
end
if os.istarget("windows") then
executeorexit("msbuild UCodeLang.sln /t:Clean")
end
if os.istarget("macosx") then
executeorexit("make clean")
end
end
}
--Docs
newaction {
trigger = "build_docs",
description = "build Docs",
execute = function()
if os.istarget("linux") or os.istarget("macosx") then
executeorexit(
"cd ./doc;mdbook build --dest-dir ../Output/UCodeDocumentation;cp -r ../Output/UCodeDocumentation ../website/static/doc")
end
if os.istarget("windows") then
executeorexit(
"cd doc && mdbook build --dest-dir ..\\Output\\UCodeDocumentation && xcopy /e /i /q ..\\Output\\UCodeDocumentation ..\\website\\static\\doc")
end
end
}
-- Website
newaction {
trigger = "build_website",
description = "build website",
execute = function()
end
}
--web
newaction {
trigger = "web_build",
description = "Builds for the Web",
execute = function()
if os.istarget("macosx") then
executeorexit("emmake make UCodeLang config=debug_web -j$(getconf _NPROCESSORS_ONLN)")
else
executeorexit("emmake make UCodeLang config=debug_web -j$(nproc)")
end
end
}
newaction {
trigger = "web_build_published",
description = "Builds for the Web",
execute = function()
if os.istarget("macosx") then
executeorexit("emmake make UCodeLang config=published_web -j$(getconf _NPROCESSORS_ONLN)")
else
executeorexit("emmake make UCodeLang config=published_web -j$(nproc)")
end
end
}
newaction {
trigger = "buildinstaller",
description = "build the installer",
execute = function()
if os.istarget("linux") then
end
if os.istarget("windows") then
executeorexit("Dependencies\\bin\\inno\\ISCC.exe install.iss")
end
if os.istarget("macosx") then
end
end
}
function readAll(file)
local f = assert(io.open(file, "rb"))
local content = f:read("*all")
f:close()
return content
end
function mysplit(inputstr, sep)
if sep == nil then
sep = "%s"
end
local t = {}
for str in string.gmatch(inputstr, "([^" .. sep .. "]+)") do
table.insert(t, str)
end
return t
end
function replacetextinfile(file_path, stringtomatch, replacement)
local file = io.open(file_path, "r")
if not file then
print("Error: File not found or unable to open.")
return
end
local content = file:read("*a")
file:close()
local modified_content = content:gsub(stringtomatch, replacement)
local new_file = io.open(file_path, "w")
if not new_file then
print("Error: Unable to write to file.")
return
end
new_file:write(modified_content)
new_file:close()
end
function isdigit(char)
if char == '0' or char == '1' or char == '2'
or char == '3' or char == '4' or char == '5'
or char == '6' or char == '6' or char == '7' or char == '8'
or char == '8' or char == '9'
then
return true
else
return false
end
end
function keeponlyfirstnumberpart(str)
local r = ""
for i = 1, string.len(str) do
local cha = str:sub(i, i) --lua cant index strings? why
if not isdigit(cha) then
break
end
r = r .. cha
end
return r
end
function file_exists(name)
local f = io.open(name, "r")
return f ~= nil and io.close(f)
end
newaction {
trigger = "updateverion",
description = "updates the verion number",
execute = function()
local major = "0"
local minor = "0"
local patch = "0"
local veriontext = readAll("version.txt")
local verionspit = mysplit(veriontext, ".");
major = verionspit[1]
major = verionspit[2]
patch = keeponlyfirstnumberpart(verionspit[3])
print("updating source files to " .. major .. "." .. minor .. "." .. patch)
--Version.hpp
local file = io.open("./UCodeLang/UCodeLang/LangCore/Version.hpp", "w")
file:write("#pragma once\n")
file:write("#define UCodeLangMajorVersion " .. major .. "\n")
file:write("#define UCodeLangMinorVersion " .. minor .. "\n")
file:write("#define UCodeLangPatchVersion " .. patch .. "\n\n")
file:write(
"#define UCodeLangVersionNumber (UCodeLangMajorVersion << 16) + (UCodeLangMinorVersion << 8) + UCodeLangPatchVersion")
file:close()
--install.sh
replacetextinfile("./install.sh", "#VersionMajor#", major)
replacetextinfile("./install.sh", "#VersionMinor#", minor)
replacetextinfile("./install.sh", "#VersionPatch#", patch)
--install.iss
replacetextinfile("./install.iss", "#VersionMajor#", major)
replacetextinfile("./install.iss", "#VersionMinor#", minor)
replacetextinfile("./install.iss", "#VersionPatch#", patch)
end
}
newaction {
trigger = "zipforunix",
description = "makes a zip file for install.sh to use",
execute = function()
local files = "./LICENSE.txt ./UCodeAPI ./Output/UCodeDocumentation "
if os.istarget("linux") then
if file_exists("./Output/UCodeLangCL/linux64/Published/uclang") then
files = files .. "./Output/UCodeLangCL/linux64/Published/uclang "
end
if file_exists("./Output/UCodeLanguageSever/linux64/Published/uclanglsp") then
files = files .. "./Output/UCodeLanguageSever/linux64/Published/uclanglsp "
end
if file_exists("./Output/UCodeLangCL/linux32/Published/uclang") then
files = files .. "./Output/UCodeLangCL/linux32/Published/uclang "
end
if file_exists("./Output/UCodeLanguageSever/linux32/Published/uclanglsp") then
files = files .. "./Output/UCodeLanguageSever/linux32/Published/uclanglsp "
end
end
if os.istarget("macos") then
files = files ..
"./Output/UCodeLangCL/MacOS/Published/uclang " ..
"./Output/UCodeLanguageSever/MacOS/Published/uclanglsp "
end
executeorexit("tar -czvf ./Output/ULangPacked.tar.gz " .. files)
end
}
newaction {
trigger = "fixios",
description = "",
execute = function()
replacetextinfile("./UCodeLang/UCodeLang.xcodeproj/project.pbxproj", "ALWAYS_SEARCH_USER_PATHS = NO",
"ALWAYS_SEARCH_USER_PATHS = YES")
end
}