[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:
Justin C. Miller
2021-08-26 01:47:58 -07:00
parent e19177d3ed
commit f79fe2e056
42 changed files with 1242 additions and 595 deletions

22
src/boot/boot.module Normal file
View File

@@ -0,0 +1,22 @@
# vim: ft=python
module("boot",
kind = "exe",
output = "boot.efi",
targets = [ "boot" ],
deps = [ "cpu", "elf", "kutil" ],
sources = [
"allocator.cpp",
"console.cpp",
"error.cpp",
"fs.cpp",
"hardware.cpp",
"loader.cpp",
"main.cpp",
"memory.cpp",
"memory_map.cpp",
"paging.cpp",
"status.cpp",
"support.cpp",
"video.cpp",
])

View File

@@ -1,20 +0,0 @@
name = "boot"
kind = "exe"
output = "boot.efi"
targets = ["boot"]
deps = ["cpu", "elf", "kutil"]
sources = [
"allocator.cpp",
"console.cpp",
"error.cpp",
"fs.cpp",
"hardware.cpp",
"loader.cpp",
"main.cpp",
"memory.cpp",
"memory_map.cpp",
"paging.cpp",
"status.cpp",
"support.cpp",
"video.cpp",
]

59
src/kernel/kernel.module Normal file
View File

@@ -0,0 +1,59 @@
# vim: ft=python
kernel = module("kernel",
kind = "exe",
default = True,
output = "jsix.elf",
targets = [ "kernel" ],
deps = [ "kutil", "cpu" ],
includes = [ "." ],
sources = [
"apic.cpp",
"ap_startup.s",
"boot.s",
"clock.cpp",
"console.cpp",
"cpprt.cpp",
"cpu.cpp",
"debug.cpp",
"debug.s",
"device_manager.cpp",
"frame_allocator.cpp",
"gdt.cpp",
"gdtidt.s",
"hpet.cpp",
"idt.cpp",
"interrupts.cpp",
"interrupts.s",
"io.cpp",
"log.cpp",
"main.cpp",
"memory_bootstrap.cpp",
"msr.cpp",
"objects/channel.cpp",
"objects/endpoint.cpp",
"objects/kobject.cpp",
"objects/thread.cpp",
"objects/process.cpp",
"objects/system.cpp",
"objects/vm_area.cpp",
"page_table.cpp",
"page_tree.cpp",
"pci.cpp",
"scheduler.cpp",
"serial.cpp",
"syscall.cpp",
"syscall.s",
"syscalls/channel.cpp",
"syscalls/endpoint.cpp",
"syscalls/object.cpp",
"syscalls/process.cpp",
"syscalls/system.cpp",
"syscalls/thread.cpp",
"syscalls/vm_area.cpp",
"task.s",
"tss.cpp",
"vm_space.cpp",
])
kernel.variables['ldflags'] = ["${ldflags}", "-T", "${source_root}/src/kernel/kernel.ld"]

View File

@@ -1,57 +0,0 @@
name = "kernel"
kind = "exe"
output = "jsix.elf"
targets = ["kernel"]
deps = ["kutil", "cpu"]
includes = ["src/kernel"]
sources = [
"apic.cpp",
"ap_startup.s",
"boot.s",
"clock.cpp",
"console.cpp",
"cpprt.cpp",
"cpu.cpp",
"debug.cpp",
"debug.s",
"device_manager.cpp",
"frame_allocator.cpp",
"gdt.cpp",
"gdtidt.s",
"hpet.cpp",
"idt.cpp",
"interrupts.cpp",
"interrupts.s",
"io.cpp",
"log.cpp",
"main.cpp",
"memory_bootstrap.cpp",
"msr.cpp",
"objects/channel.cpp",
"objects/endpoint.cpp",
"objects/kobject.cpp",
"objects/thread.cpp",
"objects/process.cpp",
"objects/system.cpp",
"objects/vm_area.cpp",
"page_table.cpp",
"page_tree.cpp",
"pci.cpp",
"scheduler.cpp",
"serial.cpp",
"syscall.cpp",
"syscall.s",
"syscalls/channel.cpp",
"syscalls/endpoint.cpp",
"syscalls/object.cpp",
"syscalls/process.cpp",
"syscalls/system.cpp",
"syscalls/thread.cpp",
"syscalls/vm_area.cpp",
"task.s",
"tss.cpp",
"vm_space.cpp",
]
[variables]
ldflags = ["${ldflags}", "-T", "${source_root}/src/kernel/kernel.ld"]

View File

@@ -1,16 +0,0 @@
name = "panic.serial"
kind = "exe"
output = "panic.serial.elf"
targets = ["kernel"]
deps = ["kutil", "elf"]
includes = ["src/kernel/panic.serial", "src/kernel"]
sources = [
"display.cpp",
"entry.s",
"main.cpp",
"serial.cpp",
"symbol_table.cpp",
]
[variables]
ldflags = ["${ldflags}", "-T", "${source_root}/src/kernel/panic.serial/panic.serial.ld"]

View File

@@ -0,0 +1,16 @@
# vim: ft=python
panic = module("panic.serial",
kind = "exe",
output = "panic.serial.elf",
targets = [ "kernel" ],
deps = [ "kutil", "elf", "kernel" ],
sources = [
"display.cpp",
"entry.s",
"main.cpp",
"serial.cpp",
"symbol_table.cpp",
])
panic.variables['ldflags'] = ["${ldflags}", "-T", "${source_root}/src/kernel/panic.serial/panic.serial.ld"]

View File

@@ -0,0 +1,8 @@
# vim: ft=python
module("cpu",
kind = "lib",
includes = ["include"],
sources = [
"cpu_id.cpp",
])

View File

@@ -1,4 +0,0 @@
name = "cpu"
kind = "lib"
includes = ["src/libraries/cpu/include"]
sources = ["cpu_id.cpp"]

View File

@@ -0,0 +1,8 @@
# vim: ft=python
module("elf",
kind = "lib",
includes = [ "include" ],
sources = [
"file.cpp",
])

View File

@@ -1,6 +0,0 @@
name = "elf"
kind = "lib"
includes = [ "src/libraries/elf/include" ]
sources = [
"file.cpp",
]

View File

@@ -0,0 +1,9 @@
# vim: ft=python
module("j6",
kind = "lib",
includes = [ "include" ],
sources = [
"init.cpp",
"syscalls.s",
])

View File

@@ -1,4 +0,0 @@
name = "j6"
kind = "lib"
includes = ["src/libraries/j6/include"]
sources = ["init.cpp", "syscalls.s"]

View File

@@ -0,0 +1,14 @@
# vim: ft=python
module("kutil",
kind = "lib",
includes = [ "include" ],
sources = [
"assert.cpp",
"bip_buffer.cpp",
"heap_allocator.cpp",
"logger.cpp",
"memory.cpp",
"printf.c",
"spinlock.cpp",
])

View File

@@ -1,12 +0,0 @@
name = "kutil"
kind = "lib"
includes = [ "src/libraries/kutil/include" ]
sources = [
"assert.cpp",
"bip_buffer.cpp",
"heap_allocator.cpp",
"logger.cpp",
"memory.cpp",
"printf.c",
"spinlock.cpp",
]

View File

@@ -0,0 +1,176 @@
# vim: ft=python
libc = module("libc",
kind = "lib",
output = "libc.a",
includes = [ "include" ],
deps = [ "j6" ],
sources = [
"arch/x86_64/_Exit.s",
"arch/x86_64/crt0.s",
"ctype/isalnum.c",
"ctype/isalpha.c",
"ctype/isblank.c",
"ctype/iscntrl.c",
"ctype/isdigit.c",
"ctype/isgraph.c",
"ctype/islower.c",
"ctype/isprint.c",
"ctype/ispunct.c",
"ctype/isspace.c",
"ctype/isupper.c",
"ctype/isxdigit.c",
"ctype/tolower.c",
"ctype/toupper.c",
"inttypes/imaxabs.c",
"inttypes/imaxdiv.c",
"inttypes/strtoimax.c",
"inttypes/strtoumax.c",
"locale/localeconv.c",
"locale/setlocale.c",
"j6libc/assert.c",
"j6libc/errno.c",
"j6libc/allocpages.c",
"j6libc/atomax.c",
"j6libc/closeall.c",
"j6libc/close.c",
"j6libc/digits.c",
"j6libc/filemode.c",
"j6libc/fillbuffer.c",
"j6libc/flushbuffer.c",
"j6libc/is_leap.c",
"j6libc/load_lc_collate.c",
"j6libc/load_lc_ctype.c",
"j6libc/load_lc_messages.c",
"j6libc/load_lc_monetary.c",
"j6libc/load_lc_numeric.c",
"j6libc/load_lc_time.c",
"j6libc/load_lines.c",
"j6libc/open.c",
"j6libc/prepread.c",
"j6libc/prepwrite.c",
"j6libc/print.c",
"j6libc/rename.c",
"j6libc/scan.c",
"j6libc/seed.c",
"j6libc/seek.c",
"j6libc/stdinit.c",
"j6libc/strtox_main.c",
"j6libc/strtox_prelim.c",
"j6libc/sbrk.c",
"signal/raise.c",
"signal/signal.c",
"stdio/clearerr.c",
"stdio/fclose.c",
"stdio/feof.c",
"stdio/ferror.c",
"stdio/fflush.c",
"stdio/fgetc.c",
"stdio/fgetpos.c",
"stdio/fgets.c",
"stdio/fopen.c",
"stdio/fprintf.c",
"stdio/fputc.c",
"stdio/fputs.c",
"stdio/fread.c",
"stdio/freopen.c",
"stdio/fscanf.c",
"stdio/fseek.c",
"stdio/fsetpos.c",
"stdio/ftell.c",
"stdio/fwrite.c",
"stdio/getc.c",
"stdio/getchar.c",
"stdio/perror.c",
"stdio/printf.c",
"stdio/putc.c",
"stdio/putchar.c",
"stdio/puts.c",
"stdio/remove.c",
"stdio/rename.c",
"stdio/rewind.c",
"stdio/scanf.c",
"stdio/setbuf.c",
"stdio/setvbuf.c",
"stdio/snprintf.c",
"stdio/sprintf.c",
"stdio/sscanf.c",
"stdio/tmpfile.c",
"stdio/tmpnam.c",
"stdio/ungetc.c",
"stdio/vfprintf.c",
"stdio/vfscanf.c",
"stdio/vprintf.c",
"stdio/vscanf.c",
"stdio/vsnprintf.c",
"stdio/vsprintf.c",
"stdio/vsscanf.c",
"stdlib/abort.c",
"stdlib/abs.c",
"stdlib/atexit.c",
"stdlib/atoi.c",
"stdlib/atol.c",
"stdlib/atoll.c",
"stdlib/bsearch.c",
"stdlib/div.c",
"stdlib/exit.c",
"stdlib/_Exit.c",
"stdlib/getenv.c",
"stdlib/labs.c",
"stdlib/ldiv.c",
"stdlib/llabs.c",
"stdlib/lldiv.c",
"stdlib/malloc.c",
"stdlib/qsort.c",
"stdlib/rand.c",
"stdlib/srand.c",
"stdlib/strtol.c",
"stdlib/strtoll.c",
"stdlib/strtoul.c",
"stdlib/strtoull.c",
"stdlib/system.c",
"string/memchr.c",
"string/memcmp.c",
"string/memcpy.c",
"string/memmove.c",
"string/memset.c",
"string/strcat.c",
"string/strchr.c",
"string/strcmp.c",
"string/strcoll.c",
"string/strcpy.c",
"string/strcspn.c",
"string/strerror.c",
"string/strlen.c",
"string/strncat.c",
"string/strncmp.c",
"string/strncpy.c",
"string/strpbrk.c",
"string/strrchr.c",
"string/strspn.c",
"string/strstr.c",
"string/strtok.c",
"string/strxfrm.c",
"time/asctime.c",
"time/clock.c",
"time/ctime.c",
"time/difftime.c",
"time/gmtime.c",
"time/localtime.c",
"time/mktime.c",
"time/strftime.c",
"time/time.c",
"time/timespec_get.c",
])
libc.variables["ccflags"] = [
"${ccflags}",
"-DDISABLE_SSE",
"-DLACKS_UNISTD_H",
"-DLACKS_FCNTL_H",
"-DLACKS_SYS_PARAM_H",
"-DLACKS_SYS_MMAN_H",
"-DLACKS_SCHED_H",
"-DLACKS_STRINGS_H",
"-DHAVE_MMAP=0",
]

View File

@@ -1,177 +0,0 @@
name = "libc"
kind = "lib"
output = "libc.a"
includes = "src/libraries/libc/include"
deps = ["j6"]
sources = [
"arch/x86_64/_Exit.s",
"arch/x86_64/crt0.s",
"ctype/isalnum.c",
"ctype/isalpha.c",
"ctype/isblank.c",
"ctype/iscntrl.c",
"ctype/isdigit.c",
"ctype/isgraph.c",
"ctype/islower.c",
"ctype/isprint.c",
"ctype/ispunct.c",
"ctype/isspace.c",
"ctype/isupper.c",
"ctype/isxdigit.c",
"ctype/tolower.c",
"ctype/toupper.c",
"inttypes/imaxabs.c",
"inttypes/imaxdiv.c",
"inttypes/strtoimax.c",
"inttypes/strtoumax.c",
"locale/localeconv.c",
"locale/setlocale.c",
"j6libc/assert.c",
"j6libc/errno.c",
"j6libc/allocpages.c",
"j6libc/atomax.c",
"j6libc/closeall.c",
"j6libc/close.c",
"j6libc/digits.c",
"j6libc/filemode.c",
"j6libc/fillbuffer.c",
"j6libc/flushbuffer.c",
"j6libc/is_leap.c",
"j6libc/load_lc_collate.c",
"j6libc/load_lc_ctype.c",
"j6libc/load_lc_messages.c",
"j6libc/load_lc_monetary.c",
"j6libc/load_lc_numeric.c",
"j6libc/load_lc_time.c",
"j6libc/load_lines.c",
"j6libc/open.c",
"j6libc/prepread.c",
"j6libc/prepwrite.c",
"j6libc/print.c",
"j6libc/rename.c",
"j6libc/scan.c",
"j6libc/seed.c",
"j6libc/seek.c",
"j6libc/stdinit.c",
"j6libc/strtox_main.c",
"j6libc/strtox_prelim.c",
"j6libc/sbrk.c",
"signal/raise.c",
"signal/signal.c",
"stdio/clearerr.c",
"stdio/fclose.c",
"stdio/feof.c",
"stdio/ferror.c",
"stdio/fflush.c",
"stdio/fgetc.c",
"stdio/fgetpos.c",
"stdio/fgets.c",
"stdio/fopen.c",
"stdio/fprintf.c",
"stdio/fputc.c",
"stdio/fputs.c",
"stdio/fread.c",
"stdio/freopen.c",
"stdio/fscanf.c",
"stdio/fseek.c",
"stdio/fsetpos.c",
"stdio/ftell.c",
"stdio/fwrite.c",
"stdio/getc.c",
"stdio/getchar.c",
"stdio/perror.c",
"stdio/printf.c",
"stdio/putc.c",
"stdio/putchar.c",
"stdio/puts.c",
"stdio/remove.c",
"stdio/rename.c",
"stdio/rewind.c",
"stdio/scanf.c",
"stdio/setbuf.c",
"stdio/setvbuf.c",
"stdio/snprintf.c",
"stdio/sprintf.c",
"stdio/sscanf.c",
"stdio/tmpfile.c",
"stdio/tmpnam.c",
"stdio/ungetc.c",
"stdio/vfprintf.c",
"stdio/vfscanf.c",
"stdio/vprintf.c",
"stdio/vscanf.c",
"stdio/vsnprintf.c",
"stdio/vsprintf.c",
"stdio/vsscanf.c",
"stdlib/abort.c",
"stdlib/abs.c",
"stdlib/atexit.c",
"stdlib/atoi.c",
"stdlib/atol.c",
"stdlib/atoll.c",
"stdlib/bsearch.c",
"stdlib/div.c",
"stdlib/exit.c",
"stdlib/_Exit.c",
"stdlib/getenv.c",
"stdlib/labs.c",
"stdlib/ldiv.c",
"stdlib/llabs.c",
"stdlib/lldiv.c",
"stdlib/malloc.c",
"stdlib/qsort.c",
"stdlib/rand.c",
"stdlib/srand.c",
"stdlib/strtol.c",
"stdlib/strtoll.c",
"stdlib/strtoul.c",
"stdlib/strtoull.c",
"stdlib/system.c",
"string/memchr.c",
"string/memcmp.c",
"string/memcpy.c",
"string/memmove.c",
"string/memset.c",
"string/strcat.c",
"string/strchr.c",
"string/strcmp.c",
"string/strcoll.c",
"string/strcpy.c",
"string/strcspn.c",
"string/strerror.c",
"string/strlen.c",
"string/strncat.c",
"string/strncmp.c",
"string/strncpy.c",
"string/strpbrk.c",
"string/strrchr.c",
"string/strspn.c",
"string/strstr.c",
"string/strtok.c",
"string/strxfrm.c",
"time/asctime.c",
"time/clock.c",
"time/ctime.c",
"time/difftime.c",
"time/gmtime.c",
"time/localtime.c",
"time/mktime.c",
"time/strftime.c",
"time/time.c",
"time/timespec_get.c",
]
[variables]
ccflags = [
"${ccflags}",
"-DDISABLE_SSE",
"-DLACKS_UNISTD_H",
"-DLACKS_FCNTL_H",
"-DLACKS_SYS_PARAM_H",
"-DLACKS_SYS_MMAN_H",
"-DLACKS_SCHED_H",
"-DLACKS_STRINGS_H",
"-DHAVE_MMAP=0",
]

View File

@@ -1,10 +0,0 @@
name = "drv.uefi_fb"
targets = ["user"]
deps = ["libc"]
sources = [
"font.cpp",
"main.cpp",
"screen.cpp",
"scrollback.cpp",
]

View File

@@ -0,0 +1,12 @@
# vim: ft=python
module("drv.uefi_fb",
targets = [ "user" ],
deps = [ "libc" ],
sources = [
"font.cpp",
"main.cpp",
"screen.cpp",
"scrollback.cpp",
])

View File

@@ -0,0 +1,10 @@
# vim: ft=python
module("srv.init",
targets = [ "user" ],
deps = [ "libc" ],
sources = [
"main.cpp",
"modules.cpp",
"start.s",
])

View File

@@ -1,8 +0,0 @@
name = "srv.init"
targets = ["user"]
deps = ["libc"]
sources = [
"main.cpp",
"modules.cpp",
"start.s",
]

View File

@@ -1,8 +0,0 @@
name = "testapp"
targets = ["user"]
deps = ["libc"]
sources = [
"io.cpp",
"main.cpp",
"serial.cpp",
]

View File

@@ -0,0 +1,10 @@
# vim: ft=python
module("testapp",
targets = [ "user" ],
deps = [ "libc" ],
sources = [
"io.cpp",
"main.cpp",
"serial.cpp",
])