Skip to content

Commit

Permalink
[build] Query Ninja graph for generated headers
Browse files Browse the repository at this point in the history
Still need to do the non-generated headers, e.g. cpp/*.h and mycpp/*.h
  • Loading branch information
Andy C committed Sep 12, 2023
1 parent 49499b3 commit 1a0c59f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
7 changes: 7 additions & 0 deletions build/ninja_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,13 @@ def SourcesForBinary(self, main_cc):
sources.extend(self.cc_libs[label].srcs)
return sources

def HeadersForBinary(self, main_cc):
deps = self.cc_binary_deps[main_cc]
headers = []
for label in deps:
headers.extend(self.cc_libs[label].generated_headers)
return headers

def asdl_library(self, asdl_path, deps = None,
pretty_print_methods=True):

Expand Down
18 changes: 8 additions & 10 deletions build/ninja_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
BUILD_NINJA = 'build.ninja'


def TarballManifest(cc_sources):
def TarballManifest(cc_h_files):
names = []

# Text
Expand All @@ -47,18 +47,14 @@ def TarballManifest(cc_sources):
names.extend(glob('build/detect-*.c'))

# Code we know about
names.extend(cc_sources)

names.extend(glob('mycpp/*.h'))
names.extend(cc_h_files)

# TODO: crawl headers
names.extend(glob('mycpp/*.h'))
names.extend(glob('cpp/*.h'))

# TODO: Put these in Ninja.
names.extend(glob('_gen/asdl/*.h'))
# for types.asdl_c.h, which is in build/py.sh, not Ninja
names.extend(glob('_gen/frontend/*.h'))
names.extend(glob('_gen/core/*.h'))
names.extend(glob('_gen/ysh/*.h'))

# ONLY the headers
names.extend(glob('prebuilt/*/*.h'))
Expand All @@ -77,7 +73,6 @@ def TarballManifest(cc_sources):

# Generated
'_build/oils.sh',
'_build/git-commit.txt',
])

for name in names:
Expand Down Expand Up @@ -394,7 +389,8 @@ def main(argv):
log(' (%s) -> %s', argv[0], out)

elif action == 'tarball-manifest':
TarballManifest(cc_sources)
h = ru.HeadersForBinary('_gen/bin/oils_for_unix.mycpp.cc')
TarballManifest(cc_sources + h)

else:
raise RuntimeError('Invalid action %r' % action)
Expand All @@ -406,3 +402,5 @@ def main(argv):
except RuntimeError as e:
print('FATAL: %s' % e, file=sys.stderr)
sys.exit(1)

# vim: sw=2

0 comments on commit 1a0c59f

Please sign in to comment.