-
Notifications
You must be signed in to change notification settings - Fork 0
/
xmake.lua
62 lines (46 loc) · 1.67 KB
/
xmake.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
set_project("ExampleOS")
add_rules("mode.debug", "mode.release")
add_requires("zig")
set_arch("i386")
set_optimize("fastest")
set_warnings("all", "extra", "pedantic", "error")
set_policy("run.autobuild", true)
set_policy("check.auto_ignore_flags", false)
target("kernel")
set_kind("binary")
set_languages("c23")
set_toolchains("@zig")
set_default(false)
add_includedirs("include")
add_files("src/**.s", "src/**.c")
add_ldflags("-target x86-freestanding")
add_cflags("-target x86-freestanding")
add_ldflags("-T src/linker.ld")
add_cflags("-m32", "-flto", "-mno-80387", "-mno-mmx", "-mno-sse", "-mno-sse2")
add_asflags("-Wno-unused-command-line-argument")
target("iso")
set_kind("phony")
add_deps("kernel")
set_default(true)
on_build(function (target)
import("core.project.project")
local iso_dir = "$(buildir)/iso_dir"
if os.exists(iso_dir) then os.rmdir(iso_dir) end
os.cp("assets", iso_dir)
local target = project.target("kernel")
os.cp(target:targetfile(), iso_dir .. "/kernel.elf")
local iso_file = "$(buildir)/exampleos.iso"
-- Limine Build ISO
local xorriso_flags = "-b limine/limine-bios-cd.bin -no-emul-boot -boot-info-table"
os.run("xorriso -as mkisofs %s %s -o %s", xorriso_flags, iso_dir, iso_file)
print("ISO image created at: " .. iso_file)
end)
on_run(function (target)
import("core.project.config")
local flags = {
"-M", "q35",
"-serial", "stdio",
"-cdrom", config.buildir() .. "/exampleos.iso"
}
os.runv("qemu-system-x86_64", flags)
end)