Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4755)

Unified Diff: build/config/merge_for_jumbo.py

Issue 2972533002: Support C and Objective-C in jumbo base scripts. (Closed)
Patch Set: Fixup for fixup for core/editing for mac and objective-c Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: build/config/merge_for_jumbo.py
diff --git a/build/config/merge_for_jumbo.py b/build/config/merge_for_jumbo.py
index f6eb87dce72d09070b96b9288c0f379ccb043e0f..b4059fb3c429e27d6e33dd8ca5ccd6cc28537685 100755
--- a/build/config/merge_for_jumbo.py
+++ b/build/config/merge_for_jumbo.py
@@ -13,6 +13,24 @@ from __future__ import print_function
import argparse
+def write_jumbo_files(inputs, outputs, written_input_set, written_output_set):
+ output_count = len(outputs)
+ input_count = len(inputs)
+
+ written_inputs = 0
+ for output_index, output_file in enumerate(outputs):
+ written_output_set.add(output_file)
+ # TODO: Check if the file is right already and then do not update it.
Dirk Pranke 2017/07/04 17:15:16 You might as well do this before landing the chang
Daniel Bratell 2017/07/05 09:21:45 Done.
+ with open(output_file, "w") as out:
+ out.write("/* This is a Jumbo file. Don't edit. */\n\n")
+ out.write("/* Generated with jumbo.py. */\n\n")
+ input_limit = (output_index + 1) * input_count / output_count
+ while written_inputs < input_limit:
+ filename = inputs[written_inputs]
+ written_inputs += 1
+ out.write("#include \"%s\"\n" % filename)
+ written_input_set.add(filename)
+
def main():
parser = argparse.ArgumentParser()
@@ -22,41 +40,39 @@ def main():
parser.add_argument("--verbose", action="store_true")
args = parser.parse_args()
- output_count = len(args.outputs)
-
lines = []
# If written with gn |write_file| each file is on its own line.
with open(args.file_list) as file_list_file:
lines = [line.strip() for line in file_list_file if line.strip()]
# If written with gn |response_file_contents| the files are space separated.
- inputs = []
+ all_inputs = []
for line in lines:
- inputs.extend(line.split())
- input_count = len(inputs)
+ all_inputs.extend(line.split())
- written_inputs = 0
- for output_index, output_file in enumerate(args.outputs):
- # TODO: Check if the file is right already and then do not update it.
- with open(output_file, "w") as out:
- out.write("/* This is a Jumbo file. Don't edit. */\n\n")
- out.write("/* Generated with merge_for_jumbo.py. */\n\n")
- input_limit = (output_index + 1) * input_count / output_count
- while written_inputs < input_limit:
- filename = inputs[written_inputs]
- written_inputs += 1
- # The source list includes headers which should not be
- # compiled, and Objective C files which will be special cased
- # later since they will not compile correctly if included in a
- # C++ file. We will just skip them here for now.
- if filename.endswith((".h", ".mm")):
- continue
+ written_output_set = set() # Just for double checking
+ written_input_set = set() # Just for double checking
+ for language_ext in (".cc", ".c", ".mm"):
+ if language_ext == ".cc":
+ ext_pattern = (".cc", ".cpp")
+ else:
+ ext_pattern = tuple([language_ext])
- out.write("#include \"%s\"\n" % filename)
+ outputs = [x for x in args.outputs if x.endswith(ext_pattern)]
+ inputs = [x for x in all_inputs if x.endswith(ext_pattern)]
Dirk Pranke 2017/07/04 17:15:16 interesting, I didn't realize you could pass a tup
+
+ if not outputs:
+ assert not inputs
+ continue
+
+ write_jumbo_files(inputs, outputs, written_input_set, written_output_set)
+ header_files = set([x for x in all_inputs if x.endswith(".h")])
+ assert set(args.outputs) == written_output_set, "Did not fill all outputs"
+ files_not_included = set(all_inputs) - written_input_set - header_files
+ assert not files_not_included, "Did not include files: " + files_not_included
if args.verbose:
- print("Generated %s (%d files) based on %s" % (str(args.outputs),
- written_inputs,
- args.file_list))
+ print("Generated %s (%d files) based on %s" % (
+ str(args.outputs), written_inputs, args.file_list))
if __name__ == "__main__":
- main()
+ main()

Powered by Google App Engine
This is Rietveld 408576698