Add a JSON output to generate_build_files.py.
gRPC are currently importing generate_build_files.py, injecting a
custom printer, and running into problems with the symlinks they set up
to make this work, as well as needing to delete duplicate generated
files.
https://github.com/grpc/grpc/blob/53a5ad34c0b5fca2cc9fd9ec4b354ff79c12948b/src/boringssl/gen_build_yaml.py#L130
https://boringssl-review.googlesource.com/c/boringssl/+/42164
Rather than layer on more hacks, add a JSON output to
generate_build_files.py. This outputs a sources.json file that folks
with especially custom builds can consume. (Looks like gRPC converts to
some home-grown YAML format which I imagine is further processed by some
other generator?) We can then add it to master-with-bazel's output.
Change-Id: I82b4ea0647386ca6c76a977f057b9962f40d41c8
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/42204
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/util/generate_build_files.py b/util/generate_build_files.py
index 6c3977d..7936528 100644
--- a/util/generate_build_files.py
+++ b/util/generate_build_files.py
@@ -618,6 +618,14 @@
''')
+class JSON(object):
+ def WriteFiles(self, files, asm_outputs):
+ sources = dict(files)
+ for ((osname, arch), asm_files) in asm_outputs:
+ sources['crypto_%s_%s' % (osname, arch)] = asm_files
+ with open('sources.json', 'w+') as f:
+ json.dump(sources, f, sort_keys=True, indent=2)
+
def FindCMakeFiles(directory):
"""Returns list of all CMakeLists.txt files recursively in directory."""
cmakefiles = []
@@ -947,10 +955,20 @@
return 0
+ALL_PLATFORMS = {
+ 'android': Android,
+ 'android-cmake': AndroidCMake,
+ 'bazel': Bazel,
+ 'cmake': CMake,
+ 'eureka': Eureka,
+ 'gn': GN,
+ 'gyp': GYP,
+ 'json': JSON,
+}
if __name__ == '__main__':
- parser = optparse.OptionParser(usage='Usage: %prog [--prefix=<path>]'
- ' [android|android-cmake|bazel|eureka|gn|gyp]')
+ parser = optparse.OptionParser(usage='Usage: %%prog [--prefix=<path>] [%s]' %
+ '|'.join(sorted(ALL_PLATFORMS.keys())))
parser.add_option('--prefix', dest='prefix',
help='For Bazel, prepend argument to all source files')
parser.add_option(
@@ -967,22 +985,10 @@
platforms = []
for s in args:
- if s == 'android':
- platforms.append(Android())
- elif s == 'android-cmake':
- platforms.append(AndroidCMake())
- elif s == 'bazel':
- platforms.append(Bazel())
- elif s == 'eureka':
- platforms.append(Eureka())
- elif s == 'gn':
- platforms.append(GN())
- elif s == 'gyp':
- platforms.append(GYP())
- elif s == 'cmake':
- platforms.append(CMake())
- else:
+ platform = ALL_PLATFORMS.get(s)
+ if platform is None:
parser.print_help()
sys.exit(1)
+ platforms.append(platform())
sys.exit(main(platforms))