[all] Reference headers in src instead of copying

This is the second of two big changes to clean up includes throughout
the project. Since I've started using clangd with Neovim and using
VSCode's intellisense, my former strategy of copying all header files
into place in `build/include` means that the real files don't show up in
`compile_commands.json` and so display many include errors when viewing
those header files in those tools.

That setup was mostly predicated on a desire to keep directory depths
small, but really I don't think paths like `src/libraries/j6/j6` are
much better than `src/libraries/j6/include/j6`, and the latter doesn't
have the aforementioned issues, and is clearer to the casual observer as
well.

Some additional changes:

- Added a new module flag `copy_headers` for behavior similar to the old
  style, but placing headers in `$module_dir/include` instead of the
  global `build/include`. This was needed for external projects that
  don't follow the same source/headers folder structure - in this case,
  `zstd`.
- There is no longer an associated `headers.*.ninja` for each
  `module.*.ninja` file, as only parsed headers need to be listed; this
  functionality has been moved back into the module's ninja file.
This commit is contained in:
Justin C. Miller
2023-07-12 19:45:43 -07:00
parent f5208d1641
commit 5d1fdd0e81
98 changed files with 62 additions and 74 deletions

View File

@@ -72,22 +72,21 @@ class ParseSource(Source):
variables = dict(name=self.path),
)
class HeaderSource(Source):
class CopySource(ParseSource):
action = "cp"
gather = True
def __init__(self, path, root = "${module_dir}", deps=tuple(), prefix = ""):
self.path = path
self.root = root
self.deps = deps
self.prefix = prefix
@property
def outputs(self):
return (self.path,)
def output(self):
from pathlib import Path
return Path(self.prefix) / self.path
@property
def args(self):
return dict(
outputs = [mod_rel(self.path)],
inputs = [join(self.root, self.path)],
implicit = list(map(_resolve, self.deps)),
variables = dict(name=self.path),
)
class HeaderSource(Source): pass
class CompileSource(Source):
action = property(_dynamic_action("compile"))
@@ -117,3 +116,6 @@ def make_source(root, path):
return HeaderSource(path, root)
else:
raise RuntimeError(f"{path} has no Source type")
def make_copy_source(root, path, prefix = ""):
return CopySource(path, root, prefix=prefix)