76 lines
2.4 KiB
Plaintext
76 lines
2.4 KiB
Plaintext
project_name "HOS"
|
|
path_prepend "x86_64-elf-gcc/bin"
|
|
|
|
configure do
|
|
rscons "x86_64-elf-gcc.rb", "-b", "#{build_dir}/x86_64-elf-gcc"
|
|
check_program "ldc2"
|
|
check_program "x86_64-w64-mingw32-gcc"
|
|
check_program "x86_64-elf-gcc"
|
|
check_c_compiler
|
|
check_program "mformat", on_fail: "Install the mtools package"
|
|
check_cfg package: "freetype2", on_fail: "Install libfreetype-dev", use: "freetype"
|
|
sh %w[git submodule update --init]
|
|
end
|
|
|
|
# Kernel default font size.
|
|
KFONT_SIZE = 15
|
|
|
|
class Image < Builder
|
|
def run(options)
|
|
unless @cache.up_to_date?(@target, nil, @sources, @env)
|
|
print_run_message("Creating disk image <target>#{@target}<reset>", nil)
|
|
File.binwrite(@target, "\0" * (1440 * 1024))
|
|
system(*%W[mformat -i #{@target} -f 1440 ::])
|
|
system(*%W[mmd -i #{@target} ::/EFI])
|
|
system(*%W[mmd -i #{@target} ::/EFI/BOOT])
|
|
system(*%W[mcopy -i #{@target} #{@sources.first} ::/EFI/BOOT])
|
|
@cache.register_build(@target, nil, @sources, @env)
|
|
end
|
|
true
|
|
end
|
|
end
|
|
|
|
class FontGen < Builder
|
|
def run(options)
|
|
if @command
|
|
finalize_command
|
|
else
|
|
fontgen = @vars["fontgen"]
|
|
@sources += [fontgen]
|
|
command = %W[#{fontgen} #{@sources.first} #{KFONT_SIZE} #{@target}]
|
|
standard_command("FontGen <target>#{@target}<reset>", command, {})
|
|
end
|
|
end
|
|
end
|
|
|
|
# FontGen Environment
|
|
fontgen_env = env "fontgen", use: "freetype" do |env|
|
|
env.Program("^/fontgen", glob("src/fontgen/**/*.c"))
|
|
end
|
|
|
|
## Kernel Environment
|
|
#kernel_env = env "kernel" do |env|
|
|
# env.add_builder(Image)
|
|
# env.add_builder(FontGen)
|
|
# env["OBJDUMP"] = "x86_64-elf-objdump"
|
|
# env["SIZE"] = "x86_64-elf-size"
|
|
# env["CCFLAGS"] += %w[-ffreestanding -Wall -O2]
|
|
# env["LDFLAGS"] += %w[-ffreestanding -nostdlib -T src/link.ld]
|
|
# env["LDFLAGS"] += %W[-Wl,-Map,${_TARGET}.map]
|
|
# env["LIBS"] += %w[gcc]
|
|
# env.FontGen("^/kfont/kfont.c", "font/Hack-Regular.ttf",
|
|
# "fontgen" => fontgen_env.expand("^/fontgen"))
|
|
# env.barrier
|
|
# env["CPPPATH"] += ["#{env.build_root}/kfont"]
|
|
# env.Program("^/hos.elf", glob("src/**/*.{S,c}") + ["^/kfont/kfont.c"])
|
|
# env.depends("#{env.build_root}/hos.elf", "src/link.ld")
|
|
# env.Disassemble("^/hos.elf.txt", "^/hos.elf")
|
|
# env.Size("^/hos.elf.size", "^/hos.elf")
|
|
# env.Image("^/hos.img", %w[^/hos.elf])
|
|
#end
|
|
|
|
task "run", desc: "Run HOS in QEMU" do
|
|
img = kernel_env.expand("^/hos.img")
|
|
sh %W[qemu-system-x86_64 -bios OVMF.fd -hda #{img}]
|
|
end
|