Commit 1af52b71 authored by Daniel Bratell's avatar Daniel Bratell Committed by Commit Bot

[jumbo] Change how jumbo.gni handles headers in sources

Up until now headers were removed from |sources| and then
reinserted. Cleaner/easier is to never remove them from the start.

Change-Id: I8f7560ef96f409880647e2924c2f71317f519468
Reviewed-on: https://chromium-review.googlesource.com/c/1290969Reviewed-by: default avatarDirk Pranke <dpranke@chromium.org>
Commit-Queue: Daniel Bratell <bratell@opera.com>
Cr-Commit-Position: refs/heads/master@{#602363}
parent 79757960
...@@ -75,7 +75,7 @@ template("internal_jumbo_target") { ...@@ -75,7 +75,7 @@ template("internal_jumbo_target") {
excluded_sources = [] excluded_sources = []
if (defined(invoker.jumbo_excluded_sources)) { if (defined(invoker.jumbo_excluded_sources)) {
excluded_sources += invoker.jumbo_excluded_sources excluded_sources = invoker.jumbo_excluded_sources
} }
if (defined(invoker.sources)) { if (defined(invoker.sources)) {
...@@ -106,9 +106,11 @@ template("internal_jumbo_target") { ...@@ -106,9 +106,11 @@ template("internal_jumbo_target") {
has_c_file = false has_c_file = false
has_objective_c_file = false has_objective_c_file = false
has_S_file = false has_S_file = false
sources_in_jumbo_files = []
assert(merge_limit > 0) assert(merge_limit > 0)
foreach(source_file, invoker_sources) { foreach(source_file, invoker_sources) {
source_ext = get_path_info(source_file, "extension") source_ext = get_path_info(source_file, "extension")
is_source_file = true
if (source_ext == "c") { if (source_ext == "c") {
has_c_file = true has_c_file = true
} else if (source_ext == "mm") { } else if (source_ext == "mm") {
...@@ -123,6 +125,11 @@ template("internal_jumbo_target") { ...@@ -123,6 +125,11 @@ template("internal_jumbo_target") {
next_chunk_start += merge_limit next_chunk_start += merge_limit
} }
current_file_index += 1 current_file_index += 1
} else {
is_source_file = false
}
if (is_source_file) {
sources_in_jumbo_files += [ source_file ]
} }
} }
...@@ -130,9 +137,12 @@ template("internal_jumbo_target") { ...@@ -130,9 +137,12 @@ template("internal_jumbo_target") {
# Empty sources list or a sources list with only header files or # Empty sources list or a sources list with only header files or
# at most one non-header file. # at most one non-header file.
use_jumbo_build_for_target = false use_jumbo_build_for_target = false
assert(current_file_index <= 1) # Prevent "unused variable" not_needed([
assert(next_chunk_start >= 0) # Prevent "unused variable" "sources_in_jumbo_files",
assert(next_chunk_number <= 2) # Prevent "unused variable" "current_file_index",
"next_chunk_start",
"next_chunk_number",
])
} }
if (has_c_file) { if (has_c_file) {
...@@ -148,12 +158,13 @@ template("internal_jumbo_target") { ...@@ -148,12 +158,13 @@ template("internal_jumbo_target") {
if (use_jumbo_build_for_target) { if (use_jumbo_build_for_target) {
merge_action_name = target_name + "__jumbo_merge" merge_action_name = target_name + "__jumbo_merge"
sources_in_jumbo_files -= excluded_sources
# Create an action that calls a script that merges all the source files. # Create an action that calls a script that merges all the source files.
action(merge_action_name) { action(merge_action_name) {
script = "//build/config/merge_for_jumbo.py" script = "//build/config/merge_for_jumbo.py"
response_file_contents = response_file_contents =
rebase_path(invoker_sources - excluded_sources, root_build_dir) rebase_path(sources_in_jumbo_files, root_build_dir)
outputs = jumbo_files outputs = jumbo_files
args = [ "--outputs" ] + rebase_path(outputs, root_build_dir) + args = [ "--outputs" ] + rebase_path(outputs, root_build_dir) +
[ "--file-list={{response_file_name}}" ] [ "--file-list={{response_file_name}}" ]
...@@ -189,15 +200,7 @@ template("internal_jumbo_target") { ...@@ -189,15 +200,7 @@ template("internal_jumbo_target") {
variables_to_not_forward += [ "sources" ] variables_to_not_forward += [ "sources" ]
assert(jumbo_files != []) assert(jumbo_files != [])
set_sources_assignment_filter([]) # Prefiltered. set_sources_assignment_filter([]) # Prefiltered.
sources = jumbo_files + excluded_sources sources = invoker_sources - sources_in_jumbo_files + jumbo_files
# Need to keep the headers in sources so that dependency checks
# work.
foreach(source_file, invoker_sources) {
if (get_path_info(source_file, "extension") == "h") {
sources += [ source_file ]
}
}
# Change include_dirs to make sure that the jumbo file can find its # Change include_dirs to make sure that the jumbo file can find its
# #included files. # #included files.
......
...@@ -135,6 +135,7 @@ def main(): ...@@ -135,6 +135,7 @@ def main():
write_jumbo_files(inputs, outputs, written_input_set, written_output_set) write_jumbo_files(inputs, outputs, written_input_set, written_output_set)
assert set(args.outputs) == written_output_set, "Did not fill all outputs" assert set(args.outputs) == written_output_set, "Did not fill all outputs"
assert set(all_inputs) == written_input_set, "Did not use all inputs"
if args.verbose: if args.verbose:
print("Generated %s (%d files) based on %s" % ( print("Generated %s (%d files) based on %s" % (
str(args.outputs), len(written_input_set), args.file_list)) str(args.outputs), len(written_input_set), args.file_list))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment