[build] Move headers out of target dirs
The great header shift: It didn't make sense to regenerate headers for the same module for every target (boot/kernel/user) it appeared in. And now that core headers are out of src/include, this was going to cause problems for the new libc changes I've been working on. So I went back to re-design how module headers work. Pre-requisites: - A module's public headers should all be available in one location, not tied to target. - No accidental includes. Another module should not be able to include anything (creating an implicit dependency) from a module without declaring an explicit dependency. - Exception to the previous: libc's headers should be available to all, at least for the freestanding headers. New system: - A new "public_headers" property of module declares all public headers that should be available to dependant modules - All public headers (after possible processing) are installed relative to build/include/<module> with the same path as their source - This also means no "include" dir in modules is necessary. If a header should be included as <j6/types.h> then its source should be src/libraries/j6/j6/types.h - this caused the most churn as all public header sources moved one directory up. - The "includes" property of a module is local only to that module now, it does not create any implicit public interface Other changes: - The bonnibel concept of sources changed: instead of sources having actions, they themselves are an instance of a (sub)class of Source, which provides all the necessary information itself. - Along with the above, rule names were standardized into <type>.<ext>, eg "compile.cpp" or "parse.cog" - cog and cogflags variables moved from per-target scope to global scope in the build files. - libc gained a more dynamic .module file
This commit is contained in:
@@ -1,166 +1,33 @@
|
||||
# vim: ft=python
|
||||
|
||||
# Normally I prefer listing every source file so that ninja can pick
|
||||
# up on added files and regenerate appropriately, but libc has _so_
|
||||
# many files that it's unweildy. So if a file is added or removed in
|
||||
# libc, remember to run configure again.
|
||||
|
||||
def glob(ext):
|
||||
from glob import glob
|
||||
|
||||
def resolve(path):
|
||||
from pathlib import Path
|
||||
return str(Path(path).relative_to(module_root))
|
||||
|
||||
return list(map(resolve, glob(f"{module_root}/**/*.{ext}", recursive=True)))
|
||||
|
||||
sources = []
|
||||
for ext in ("c", "cpp", "s"):
|
||||
sources += glob(ext) + glob(ext + ".cog")
|
||||
|
||||
headers = []
|
||||
for ext in ("h", "inc"):
|
||||
headers += glob(ext) + glob(ext + ".cog")
|
||||
|
||||
libc = module("libc",
|
||||
kind = "lib",
|
||||
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",
|
||||
])
|
||||
sources = sources,
|
||||
public_headers = headers,
|
||||
)
|
||||
|
||||
libc.variables["ccflags"] = [
|
||||
"${ccflags}",
|
||||
|
||||
Reference in New Issue
Block a user