mirror of
https://github.com/justinian/jsix.git
synced 2025-12-09 16:04:32 -08:00
[build] Move to python build scripts per module
This change moves Bonnibel from a separate project into the jsix tree, and alters the project configuration to be jsix-specific. (I stopped using bonnibel for any other projects, so it's far easier to make it a custom generator for jsix.) The build system now also uses actual python code in `*.module` files to configure modules instead of TOML files. Target configs (boot, kernel-mode, user-mode) now moved to separate TOML files under `configs/` and can inherit from one another.
This commit is contained in:
43
configs/base.toml
Normal file
43
configs/base.toml
Normal file
@@ -0,0 +1,43 @@
|
||||
[variables]
|
||||
cc = "clang"
|
||||
cxx = "clang++"
|
||||
ld = "ld.lld"
|
||||
ar = "ar"
|
||||
nasm = "nasm"
|
||||
objcopy = "objcopy"
|
||||
cog = "cog"
|
||||
|
||||
ccflags = [
|
||||
"-I${source_root}/src/include",
|
||||
"-I${source_root}/src/include/x86_64",
|
||||
"-fcolor-diagnostics",
|
||||
"-DVERSION_MAJOR=${version_major}",
|
||||
"-DVERSION_MINOR=${version_minor}",
|
||||
"-DVERSION_PATCH=${version_patch}",
|
||||
"-DVERSION_GITSHA=0x${version_sha}",
|
||||
'-DGIT_VERSION=\"${version_major}.${version_minor}.${version_patch}+${version_sha}\"',
|
||||
'-DGIT_VERSION_WIDE=L\"${version_major}.${version_minor}.${version_patch}+${version_sha}\"',
|
||||
"-Wformat=2", "-Winit-self", "-Wfloat-equal", "-Winline", "-Wmissing-format-attribute",
|
||||
"-Wmissing-include-dirs", "-Wswitch", "-Wundef", "-Wdisabled-optimization",
|
||||
"-Wpointer-arith", "-Wno-attributes", "-Wno-sign-compare", "-Wno-multichar",
|
||||
"-Wno-div-by-zero", "-Wno-endif-labels", "-Wno-pragmas", "-Wno-format-extra-args",
|
||||
"-Wno-unused-result", "-Wno-deprecated-declarations", "-Wno-unused-function",
|
||||
"-Wno-address-of-packed-member", "-Wno-invalid-offsetof", "-Werror",
|
||||
]
|
||||
|
||||
asflags = [
|
||||
"-DVERSION_MAJOR=${version_major}",
|
||||
"-DVERSION_MINOR=${version_minor}",
|
||||
"-DVERSION_PATCH=${version_patch}",
|
||||
"-DVERSION_GITSHA=0x${version_sha}",
|
||||
"-I${source_root}/src/include",
|
||||
]
|
||||
|
||||
cflags = ["-std=c11"]
|
||||
cxxflags = ["-std=c++17"]
|
||||
|
||||
cogflags = [
|
||||
"-I", "${source_root}/scripts",
|
||||
"-D", "definitions_path=${source_root}/definitions"
|
||||
]
|
||||
|
||||
35
configs/boot-debug.toml
Normal file
35
configs/boot-debug.toml
Normal file
@@ -0,0 +1,35 @@
|
||||
extends = "base"
|
||||
|
||||
[variables]
|
||||
|
||||
ld = "clang++"
|
||||
|
||||
ccflags = [
|
||||
"-I${source_root}/external",
|
||||
"--target=x86_64-unknown-windows",
|
||||
"-ffreestanding",
|
||||
"-mno-red-zone",
|
||||
"-fshort-wchar",
|
||||
"-fno-omit-frame-pointer",
|
||||
"-ggdb",
|
||||
"-g3",
|
||||
'-DKERNEL_FILENAME=L"jsix.elf"',
|
||||
]
|
||||
|
||||
|
||||
cflags = [
|
||||
]
|
||||
|
||||
cxxflags = [
|
||||
"-fno-exceptions",
|
||||
"-fno-rtti",
|
||||
]
|
||||
|
||||
ldflags = [
|
||||
"--target=x86_64-unknown-windows",
|
||||
"-nostdlib",
|
||||
"-Wl,-entry:efi_main",
|
||||
"-Wl,-subsystem:efi_application",
|
||||
"-fuse-ld=lld-link",
|
||||
"-g"
|
||||
]
|
||||
@@ -1,76 +0,0 @@
|
||||
|
||||
rule makest
|
||||
description = Making symbol table
|
||||
command = nm -n -S --demangle $in | ${source_root}/scripts/build_symbol_table.py $out
|
||||
|
||||
rule makefat
|
||||
description = Creating $name
|
||||
command = $
|
||||
cp ${source_root}/assets/diskbase.img $out; $
|
||||
mcopy -s -D o -i $out@@1M ${build_root}/fatroot/* ::/
|
||||
|
||||
rule strip
|
||||
description = Stripping $name
|
||||
command = $
|
||||
cp $in $out; $
|
||||
objcopy --only-keep-debug $out $out.debug; $
|
||||
strip -g $out; $
|
||||
objcopy --add-gnu-debuglink=$out.debug $out
|
||||
|
||||
|
||||
build ${build_root}/ovmf_vars.fd : cp ${source_root}/assets/ovmf/x64/ovmf_vars.fd
|
||||
name = ovmf_vars.fd
|
||||
|
||||
build ${build_root}/ovmf_vars_d.fd : cp ${source_root}/assets/ovmf/x64/ovmf_vars_d.fd
|
||||
name = ovmf_vars_d.fd
|
||||
|
||||
build ${build_root}/jsix.elf | ${build_root}/jsix.elf.debug : strip ${build_root}/kernel/jsix.elf
|
||||
name = kernel
|
||||
|
||||
build ${build_root}/jsix.dump : dump ${build_root}/kernel/jsix.elf
|
||||
name = kernel
|
||||
|
||||
build ${build_root}/jsix.elf-gdb.py : cp ${source_root}/assets/debugging/jsix.elf-gdb.py
|
||||
name = kernel debug python scripts
|
||||
|
||||
build ${build_root}/fatroot/jsix.elf : cp ${build_root}/jsix.elf
|
||||
name = kernel to FAT image
|
||||
|
||||
build ${build_root}/fatroot/efi/boot/bootx64.efi : cp ${build_root}/boot/boot.efi
|
||||
name = bootloader to FAT image
|
||||
|
||||
build ${build_root}/fatroot/testapp.elf : cp ${build_root}/user/testapp.elf
|
||||
name = null driver to FAT image
|
||||
|
||||
build ${build_root}/panic.serial.elf : strip ${build_root}/kernel/panic.serial.elf
|
||||
name = Serial panic handler
|
||||
|
||||
build ${build_root}/fatroot/panic.serial.elf : cp ${build_root}/panic.serial.elf
|
||||
name = Serial panic handler to FAT image
|
||||
|
||||
build ${build_root}/fatroot/drv.uefi_fb.elf : cp ${build_root}/user/drv.uefi_fb.elf
|
||||
name = UEFI framebuffer driver to FAT image
|
||||
|
||||
build ${build_root}/fatroot/srv.init.elf : cp ${build_root}/user/srv.init.elf
|
||||
name = Init server to FAT image
|
||||
|
||||
build ${build_root}/fatroot/symbol_table.dat : makest ${build_root}/jsix.elf
|
||||
|
||||
build ${build_root}/jsix.img : makefat | $
|
||||
${build_root}/fatroot/symbol_table.dat $
|
||||
${build_root}/fatroot/testapp.elf $
|
||||
${build_root}/fatroot/drv.uefi_fb.elf $
|
||||
${build_root}/fatroot/srv.init.elf $
|
||||
${build_root}/fatroot/jsix.elf $
|
||||
${build_root}/fatroot/panic.serial.elf $
|
||||
${build_root}/fatroot/efi/boot/bootx64.efi
|
||||
name = jsix.img
|
||||
|
||||
default $
|
||||
${build_root}/ovmf_vars.fd $
|
||||
${build_root}/ovmf_vars_d.fd $
|
||||
${build_root}/jsix.dump $
|
||||
${build_root}/jsix.elf-gdb.py $
|
||||
${build_root}/jsix.img
|
||||
|
||||
# vim: ft=ninja et ts=4 sts=4 sw=4
|
||||
@@ -1,132 +0,0 @@
|
||||
[targets.boot]
|
||||
cc = "clang"
|
||||
cxx = "clang++"
|
||||
ld = "clang++"
|
||||
ar = "ar"
|
||||
nasm = "nasm"
|
||||
objcopy = "objcopy"
|
||||
|
||||
ccflags = [
|
||||
"${ccflags}",
|
||||
"-I${source_root}/external",
|
||||
"--target=x86_64-unknown-windows",
|
||||
"-ffreestanding",
|
||||
"-mno-red-zone",
|
||||
"-fshort-wchar",
|
||||
"-fno-omit-frame-pointer",
|
||||
"-ggdb",
|
||||
"-g3",
|
||||
'-DKERNEL_FILENAME=L"jsix.elf"',
|
||||
]
|
||||
|
||||
cxxflags = [
|
||||
"${cxxflags}",
|
||||
"-fno-exceptions",
|
||||
"-fno-rtti",
|
||||
]
|
||||
|
||||
ldflags = [
|
||||
"${ldflags}",
|
||||
"--target=x86_64-unknown-windows",
|
||||
"-nostdlib",
|
||||
"-Wl,-entry:efi_main",
|
||||
"-Wl,-subsystem:efi_application",
|
||||
"-fuse-ld=lld-link",
|
||||
"-g"
|
||||
]
|
||||
|
||||
|
||||
[targets.kernel]
|
||||
cc = "clang"
|
||||
cxx = "clang++"
|
||||
ld = "ld.lld"
|
||||
ar = "ar"
|
||||
nasm = "nasm"
|
||||
objcopy = "objcopy"
|
||||
|
||||
asflags = [
|
||||
"${asflags}",
|
||||
"-I${source_root}/src/kernel/",
|
||||
]
|
||||
|
||||
ccflags = [
|
||||
"${ccflags}",
|
||||
"--target=x86_64-unknown-elf",
|
||||
"-I${source_root}/external",
|
||||
"-nostdlib",
|
||||
"-ffreestanding",
|
||||
"-nodefaultlibs",
|
||||
"-fno-builtin",
|
||||
"-mno-sse",
|
||||
"-fno-omit-frame-pointer",
|
||||
"-mno-red-zone",
|
||||
"-g",
|
||||
"-mcmodel=large",
|
||||
"-D__ELF__",
|
||||
"-D__JSIX__",
|
||||
"-isystem${source_root}/sysroot/include",
|
||||
"-isystem${source_root}/src/libraries/libc/include",
|
||||
"--sysroot='${source_root}/sysroot'",
|
||||
"-U__linux",
|
||||
"-U__linux__",
|
||||
]
|
||||
|
||||
cxxflags = [
|
||||
"${cxxflags}",
|
||||
"-fno-exceptions",
|
||||
"-fno-rtti",
|
||||
"-isystem${source_root}/sysroot/include/c++/v1"
|
||||
]
|
||||
|
||||
ldflags = [
|
||||
"${ldflags}",
|
||||
"-g",
|
||||
"-nostdlib",
|
||||
"-Bstatic",
|
||||
"-z", "norelro",
|
||||
"-z", "separate-code",
|
||||
]
|
||||
|
||||
|
||||
[targets.user]
|
||||
cc = "clang"
|
||||
cxx = "clang++"
|
||||
ld = "ld.lld"
|
||||
ar = "ar"
|
||||
nasm = "nasm"
|
||||
objcopy = "objcopy"
|
||||
|
||||
asflags = [
|
||||
"${asflags}",
|
||||
"-I${source_root}/src/kernel/",
|
||||
]
|
||||
|
||||
ccflags = [
|
||||
"${ccflags}",
|
||||
"-mno-sse",
|
||||
"-fno-omit-frame-pointer",
|
||||
"-g",
|
||||
"-D__ELF__",
|
||||
"-D__JSIX__",
|
||||
"-isystem${source_root}/sysroot/include",
|
||||
"-isystem${source_root}/src/libraries/libc/include",
|
||||
"--sysroot='${source_root}/sysroot'",
|
||||
"-U__linux",
|
||||
"-U__linux__",
|
||||
]
|
||||
|
||||
cxxflags = [
|
||||
"${cxxflags}",
|
||||
"-fno-exceptions",
|
||||
"-fno-rtti",
|
||||
"-isystem${source_root}/sysroot/include/c++/v1"
|
||||
]
|
||||
|
||||
ldflags = [
|
||||
"${ldflags}",
|
||||
"-g",
|
||||
"-Bstatic",
|
||||
"--sysroot='${source_root}/sysroot'",
|
||||
"-L", "${source_root}/sysroot/lib",
|
||||
"-z", "separate-code",
|
||||
]
|
||||
47
configs/kernel-debug.toml
Normal file
47
configs/kernel-debug.toml
Normal file
@@ -0,0 +1,47 @@
|
||||
extends = "base"
|
||||
|
||||
[variables]
|
||||
asflags = [
|
||||
"-I${source_root}/src/kernel/",
|
||||
]
|
||||
|
||||
ccflags = [
|
||||
"--target=x86_64-unknown-elf",
|
||||
"-I${source_root}/external",
|
||||
"-nostdlib",
|
||||
"-ffreestanding",
|
||||
"-nodefaultlibs",
|
||||
"-fno-builtin",
|
||||
"-mno-sse",
|
||||
"-fno-omit-frame-pointer",
|
||||
"-mno-red-zone",
|
||||
"-g",
|
||||
"-mcmodel=large",
|
||||
"-D__ELF__",
|
||||
"-D__JSIX__",
|
||||
"-isystem${source_root}/sysroot/include",
|
||||
"-isystem${source_root}/src/libraries/libc/include",
|
||||
"--sysroot='${source_root}/sysroot'",
|
||||
"-U__linux",
|
||||
"-U__linux__",
|
||||
]
|
||||
|
||||
cflags = [
|
||||
'-nostdinc',
|
||||
]
|
||||
|
||||
cxxflags = [
|
||||
"-fno-exceptions",
|
||||
"-fno-rtti",
|
||||
'-nostdinc',
|
||||
"-isystem${source_root}/sysroot/include/c++/v1"
|
||||
]
|
||||
|
||||
ldflags = [
|
||||
"-g",
|
||||
"-nostdlib",
|
||||
"-Bstatic",
|
||||
"-z", "norelro",
|
||||
"-z", "separate-code",
|
||||
]
|
||||
|
||||
75
configs/rules.ninja
Normal file
75
configs/rules.ninja
Normal file
@@ -0,0 +1,75 @@
|
||||
# This file is automatically generated by bonnibel
|
||||
|
||||
rule compile_c
|
||||
command = $cc -MMD -MF $out.d $cflags $ccflags -o $out -c $in
|
||||
description = Compiling $name
|
||||
depfile = $out.d
|
||||
deps = gcc
|
||||
|
||||
rule dump_c_defs
|
||||
command = echo | $cc $ccflags $cflags -dM -E - > $out
|
||||
description = Dumping C defines for $target
|
||||
|
||||
rule dump_c_run
|
||||
command = echo '#!/bin/bash' > $out; echo '$cc $ccflags $cflags $$*' >> $
|
||||
$out; chmod a+x $out
|
||||
description = Dumping C arguments for $target
|
||||
|
||||
rule compile_cxx
|
||||
command = $cxx -MMD -MF $out.d $cxxflags $ccflags -o $out -c $in
|
||||
description = Compiling $name
|
||||
depfile = $out.d
|
||||
deps = gcc
|
||||
|
||||
rule dump_cpp_defs
|
||||
command = echo | $cxx -x c++ $ccflags $cxxflags -dM -E - > $out
|
||||
description = Dumping C++ defines for $target
|
||||
|
||||
rule dump_cpp_run
|
||||
command = echo '#!/bin/bash' > $out; echo '$cxx $ccflags $cxxflags $$*' $
|
||||
>> $out; chmod a+x $out
|
||||
description = Dumping C++ arguments for $target
|
||||
|
||||
rule compile_asm
|
||||
command = $nasm -o $out -felf64 -MD $out.d $asflags $in
|
||||
description = Assembling $name
|
||||
depfile = $out.d
|
||||
deps = gcc
|
||||
|
||||
rule parse_cog
|
||||
command = $cog -o $out -d $cogflags $in
|
||||
description = Parsing $name
|
||||
|
||||
rule exe
|
||||
command = $ld $ldflags -o $out $in $libs
|
||||
description = Linking $name
|
||||
|
||||
rule lib
|
||||
command = $ar qcs $out $in
|
||||
description = Archiving $name
|
||||
|
||||
rule cp
|
||||
command = cp $in $out
|
||||
description = Copying $name
|
||||
|
||||
rule dump
|
||||
command = objdump -DSC -M intel $in > $out
|
||||
description = Dumping decompiled $name
|
||||
|
||||
rule makest
|
||||
description = Making symbol table
|
||||
command = nm -n -S --demangle $in | ${source_root}/scripts/build_symbol_table.py $out
|
||||
|
||||
rule makefat
|
||||
description = Creating $name
|
||||
command = $
|
||||
cp $in $out; $
|
||||
mcopy -s -D o -i $out@@1M ${build_root}/fatroot/* ::/
|
||||
|
||||
rule strip
|
||||
description = Stripping $name
|
||||
command = $
|
||||
cp $in $out; $
|
||||
objcopy --only-keep-debug $out $debug; $
|
||||
strip -g $out; $
|
||||
objcopy --add-gnu-debuglink=$debug $out
|
||||
34
configs/user-debug.toml
Normal file
34
configs/user-debug.toml
Normal file
@@ -0,0 +1,34 @@
|
||||
extends = "base"
|
||||
|
||||
[variables]
|
||||
asflags = [
|
||||
"-I${source_root}/src/kernel/",
|
||||
]
|
||||
|
||||
ccflags = [
|
||||
"-mno-sse",
|
||||
"-fno-omit-frame-pointer",
|
||||
"-g",
|
||||
"-D__ELF__",
|
||||
"-D__JSIX__",
|
||||
"-isystem${source_root}/sysroot/include",
|
||||
"-isystem${source_root}/src/libraries/libc/include",
|
||||
"--sysroot='${source_root}/sysroot'",
|
||||
"-U__linux",
|
||||
"-U__linux__",
|
||||
]
|
||||
|
||||
cxxflags = [
|
||||
"-fno-exceptions",
|
||||
"-fno-rtti",
|
||||
"-isystem${source_root}/sysroot/include/c++/v1"
|
||||
]
|
||||
|
||||
ldflags = [
|
||||
"-g",
|
||||
"-Bstatic",
|
||||
"--sysroot='${source_root}/sysroot'",
|
||||
"-L", "${source_root}/sysroot/lib",
|
||||
"-z", "separate-code",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user