[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:
Justin C. Miller
2022-02-06 10:18:51 -08:00
parent db23e4966e
commit 4545256b49
103 changed files with 362 additions and 5191 deletions

View File

@@ -0,0 +1,67 @@
#pragma once
/* OS glue functions declaration <glue.h>
This file is part of the Public Domain C Library (PDCLib).
Permission is granted to use, modify, and / or redistribute at will.
*/
#include "j6libc/int.h"
/* -------------------------------------------------------------------------- */
/* OS "glue", part 2 */
/* These are the functions you will have to touch, as they are where PDCLib */
/* interfaces with the operating system. */
/* They operate on data types partially defined by config.h. */
/* -------------------------------------------------------------------------- */
/* stdlib.h */
/* A system call that terminates the calling process, returning a given status
to the environment.
*/
_Noreturn void _PDCLIB_Exit( int status );
/* A system call that adds n pages of memory to the process heap (if n is
positive), or releases n pages from the process heap (if n is negative).
Return a (void *) pointing to the *former* end-of-heap if successful, NULL
otherwise.
*/
void * _PDCLIB_allocpages( int n );
/* stdio.h */
/* A system call that opens a file identified by name in a given mode. Return
a file descriptor uniquely identifying that file.
(The mode is the return value of the _PDCLIB_filemode() function.)
*/
_PDCLIB_fd_t _PDCLIB_open( const char * const filename, unsigned int mode );
/* A system call that writes a stream's buffer.
Returns 0 on success, EOF on write error.
Sets stream error flags and errno appropriately on error.
*/
int _PDCLIB_flushbuffer( struct _PDCLIB_file_t * stream );
/* A system call that fills a stream's buffer.
Returns 0 on success, EOF on read error / EOF.
Sets stream EOF / error flags and errno appropriately on error.
*/
int _PDCLIB_fillbuffer( struct _PDCLIB_file_t * stream );
/* A system call that repositions within a file. Returns new offset on success,
-1 / errno on error.
*/
int64_t _PDCLIB_seek( struct _PDCLIB_file_t * stream, int64_t offset, int whence );
/* A system call that closes a file identified by given file descriptor. Return
zero on success, non-zero otherwise.
*/
int _PDCLIB_close( _PDCLIB_fd_t fd );
/* A system call that renames a file from given old name to given new name.
Return zero on success, non-zero otherwise. In case of failure, the file
must still be accessible by old name. Any handling of open files etc. is
done by standard rename() already.
*/
int _PDCLIB_rename( const char * old, const char * new );