From d75b8b5d0738bf930f66a3b09e6245a80854e896 Mon Sep 17 00:00:00 2001 From: Motomu Utsumi Date: Fri, 2 Dec 2022 14:29:00 +0900 Subject: [PATCH 01/16] gn2bp: Update _is_value_arg Test: ./update_results.sh Change-Id: I55c016404533c9fb37e32e818dd47081ee2e82fa --- tools/gn2bp/gen_android_bp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tools/gn2bp/gen_android_bp b/tools/gn2bp/gen_android_bp index ce71938b35..705021652e 100755 --- a/tools/gn2bp/gen_android_bp +++ b/tools/gn2bp/gen_android_bp @@ -654,10 +654,7 @@ class BaseActionSanitizer(): # Whether an arg value pair appears exactly once def _is_value_arg(self, arg): - if operator.countOf(self.target.args, arg) != 1: - return False - i = self.target.args.index(arg) - return not self.target.args[i + 1].startswith('--') + return operator.countOf(self.target.args, arg) == 1 and self._is_list_arg(arg) def _get_value_arg(self, arg): assert(self._is_value_arg(arg)) From 8be8a266e500bcfcc45a3ce947a4ff8bcefc173e Mon Sep 17 00:00:00 2001 From: Motomu Utsumi Date: Fri, 2 Dec 2022 14:35:15 +0900 Subject: [PATCH 02/16] gn2bp: Update the comment for value args and list args Test: ./update_results.sh Change-Id: I0f28041f0c6e83ff9dd20c74b0a4dbd684b3f2e0 --- tools/gn2bp/gen_android_bp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/gn2bp/gen_android_bp b/tools/gn2bp/gen_android_bp index 705021652e..5a49d4fe04 100755 --- a/tools/gn2bp/gen_android_bp +++ b/tools/gn2bp/gen_android_bp @@ -627,10 +627,9 @@ class BaseActionSanitizer(): # - flags (--flag) # - value args (--arg value) # - list args (--arg value1 --arg value2) + # value args have exactly one arg value pair and list args have one or more arg value pairs. # Note that the set of list args contains the set of value args. - # value args must have exactly one arg value pair but list args could have one arg value pair. - # This is because list args with one arg value pair and value args can not be distinguished only - # from the desc.json + # This is because list and value args are identical when the list args has only one arg value pair # Some functions provide special implementations for each type, while others # work on all of them. def _has_arg(self, arg): From 9752bd356c688d12ea9219a47d086167e1007225 Mon Sep 17 00:00:00 2001 From: Motomu Utsumi Date: Fri, 2 Dec 2022 15:16:55 +0900 Subject: [PATCH 03/16] gn2bp: Normalize args by for loop instead of comprehension Upcoming CL will make this normalization a bit more complex, this CL is a preparation for that. Test: ./update_results. Change-Id: I8248c68d30b21682f5521435f85cd555033b51c6 --- tools/gn2bp/gen_android_bp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/gn2bp/gen_android_bp b/tools/gn2bp/gen_android_bp index 5a49d4fe04..5295fde82d 100755 --- a/tools/gn2bp/gen_android_bp +++ b/tools/gn2bp/gen_android_bp @@ -620,8 +620,14 @@ class BaseActionSanitizer(): def __init__(self, target): # Just to be on the safe side, create a deep-copy. self.target = copy.deepcopy(target) + self.target.args = self._normalize_args() + + def _normalize_args(self): # Convert ['--param=value'] to ['--param', 'value'] for consistency. - self.target.args = [str for it in self.target.args for str in it.split('=')] + normalized_args = [] + for arg in self.target.args: + normalized_args.extend(arg.split('=')) + return normalized_args # There are three types of args: # - flags (--flag) From 1339932ba7662d14f7f6da7031b042a175618975 Mon Sep 17 00:00:00 2001 From: Motomu Utsumi Date: Fri, 2 Dec 2022 15:36:48 +0900 Subject: [PATCH 04/16] gn2bp: Fix arg normalization and remove hack in the VersionSanitizer There are cmd diffs in Android.bp.swp but it is verified the updated cmds works. Test: ./update_results.sh Change-Id: Iaf916f9de12b18b4e5402fcccd2b154f72a6ac8d --- tools/gn2bp/Android.bp.swp | 12 ++++++------ tools/gn2bp/gen_android_bp | 17 +++++------------ 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/tools/gn2bp/Android.bp.swp b/tools/gn2bp/Android.bp.swp index 990bbbe488..db9ff67eec 100644 --- a/tools/gn2bp/Android.bp.swp +++ b/tools/gn2bp/Android.bp.swp @@ -7844,7 +7844,7 @@ java_genrule { "-f " + "$(location build/util/LASTCHANGE) " + "-e " + - "API_LEVEL='20' " + + "API_LEVEL=20 " + "-o " + "$(out) " + "$(location components/cronet/android/java/src/org/chromium/net/impl/ImplVersion.template)", @@ -7885,7 +7885,7 @@ java_genrule { "-f " + "$(location build/util/LASTCHANGE) " + "-e " + - "API_LEVEL='20' " + + "API_LEVEL=20 " + "-o " + "$(out) " + "$(location components/cronet/android/api/src/org/chromium/net/ApiVersion.template)", @@ -8264,7 +8264,7 @@ cc_genrule { cmd: "$(location build/util/version.py) -f " + "$(location chrome/VERSION) " + "-e " + - "VERSION_FULL='\"%s.%s.%s.%s\" % (MAJOR,MINOR,BUILD,PATCH)' " + + "VERSION_FULL=\"%s.%s.%s.%s\" % (MAJOR,MINOR,BUILD,PATCH) " + "-o " + "$(out) " + "$(location components/cronet/version.h.in)", @@ -8289,7 +8289,7 @@ cc_genrule { cmd: "$(location build/util/version.py) -f " + "$(location chrome/VERSION) " + "-e " + - "VERSION_FULL='\"%s.%s.%s.%s\" % (MAJOR,MINOR,BUILD,PATCH)' " + + "VERSION_FULL=\"%s.%s.%s.%s\" % (MAJOR,MINOR,BUILD,PATCH) " + "-o " + "$(out) " + "$(location components/cronet/version.h.in)", @@ -8314,7 +8314,7 @@ cc_genrule { cmd: "$(location build/util/version.py) -f " + "$(location chrome/VERSION) " + "-e " + - "VERSION_FULL='\"%s.%s.%s.%s\" % (MAJOR,MINOR,BUILD,PATCH)' " + + "VERSION_FULL=\"%s.%s.%s.%s\" % (MAJOR,MINOR,BUILD,PATCH) " + "-o " + "$(out) " + "$(location components/cronet/version.h.in)", @@ -8339,7 +8339,7 @@ cc_genrule { cmd: "$(location build/util/version.py) -f " + "$(location chrome/VERSION) " + "-e " + - "VERSION_FULL='\"%s.%s.%s.%s\" % (MAJOR,MINOR,BUILD,PATCH)' " + + "VERSION_FULL=\"%s.%s.%s.%s\" % (MAJOR,MINOR,BUILD,PATCH) " + "-o " + "$(out) " + "$(location components/cronet/version.h.in)", diff --git a/tools/gn2bp/gen_android_bp b/tools/gn2bp/gen_android_bp index 5295fde82d..26f57261bd 100755 --- a/tools/gn2bp/gen_android_bp +++ b/tools/gn2bp/gen_android_bp @@ -626,7 +626,10 @@ class BaseActionSanitizer(): # Convert ['--param=value'] to ['--param', 'value'] for consistency. normalized_args = [] for arg in self.target.args: - normalized_args.extend(arg.split('=')) + if arg.startswith('-'): + normalized_args.extend(arg.split('=')) + else: + normalized_args.append(arg) return normalized_args # There are three types of args: @@ -768,22 +771,12 @@ class JniRegistrationGeneratorSanitizer(BaseActionSanitizer): return super().get_args() class VersionSanitizer(BaseActionSanitizer): - def _sanitize_eval(self): - assert (self._is_value_arg('-e')) - # arg for -e EVAL option should be passed in -e PATCH_HI=int(PATCH)//256 format. - index = self.target.args.index('-e') - value = '%s=\'%s\'' % (self.target.args[index + 1], self.target.args[index + 2]) - # escape '"' in the value - value = value.replace('"', r'\"') - self._set_arg_at(index + 1, value) - self.target.args.pop(index + 2) - def get_args(self): self._set_value_arg('-o', '$(out)') # args for the version.py contain file path without leading --arg key. So apply sanitize # function for all the args. self._update_all_args(self._sanitize_filepath_with_location_tag) - self._sanitize_eval() + self._update_value_arg('-e', lambda arg: arg.replace('"', r'\"')) return super().get_args() class JavaCppEnumSanitizer(BaseActionSanitizer): From 5afd081a49f0eb81d668c56147f05fab9673bc8d Mon Sep 17 00:00:00 2001 From: Motomu Utsumi Date: Fri, 2 Dec 2022 15:43:36 +0900 Subject: [PATCH 05/16] gn2bp: Add get_outputs to the BaseActionSanitizer Test: ./update_results.sh Change-Id: I242b68800bdcabe7cf955046e12ef9c112c0d321 --- tools/gn2bp/gen_android_bp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/gn2bp/gen_android_bp b/tools/gn2bp/gen_android_bp index 26f57261bd..49217f0f36 100755 --- a/tools/gn2bp/gen_android_bp +++ b/tools/gn2bp/gen_android_bp @@ -728,6 +728,9 @@ class BaseActionSanitizer(): def get_args(self): return self.target.args + def get_outputs(self): + return self.target.outputs + class WriteBuildDateHeaderSanitizer(BaseActionSanitizer): def get_args(self): self._set_arg_at(0, '$(out)') @@ -841,6 +844,7 @@ def create_action_module(blueprint, target, type): sanitizer = get_action_sanitizer(target) target.args = sanitizer.get_args() + target.outputs = sanitizer.get_outputs() if target.script == '//base/android/jni_generator/jni_generator.py': # fix target.output directory to match #include statements. From b9ef35c954572a81d6fc0f9cd7e86f4e23e3a6b6 Mon Sep 17 00:00:00 2001 From: Motomu Utsumi Date: Fri, 2 Dec 2022 15:55:06 +0900 Subject: [PATCH 06/16] gn2bp: Fix to use set for target.outputs Test: ./update_results.sh Change-Id: Ia5aff5ebcba3574c7b3871482a859e7fc2589ef4 --- tools/gn2bp/gen_android_bp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/gn2bp/gen_android_bp b/tools/gn2bp/gen_android_bp index 49217f0f36..7524b35354 100755 --- a/tools/gn2bp/gen_android_bp +++ b/tools/gn2bp/gen_android_bp @@ -848,7 +848,7 @@ def create_action_module(blueprint, target, type): if target.script == '//base/android/jni_generator/jni_generator.py': # fix target.output directory to match #include statements. - target.outputs = [re.sub('^jni_headers/', '', out) for out in target.outputs] + target.outputs = {re.sub('^jni_headers/', '', out) for out in target.outputs} # android_jar.classes should be part of the tools as it list implicit classes # for the script to generate JNI headers. From d4f72642328b69254028462eecfcad980e0c57e2 Mon Sep 17 00:00:00 2001 From: Motomu Utsumi Date: Fri, 2 Dec 2022 16:01:59 +0900 Subject: [PATCH 07/16] gn2bp: Add get_outputs to JniGeneratorSanitizer Test: ./update_results.sh Change-Id: I7416b18d4ed659158d44752e4143c13efacf0a80 --- tools/gn2bp/gen_android_bp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/gn2bp/gen_android_bp b/tools/gn2bp/gen_android_bp index 7524b35354..58a83463db 100755 --- a/tools/gn2bp/gen_android_bp +++ b/tools/gn2bp/gen_android_bp @@ -762,6 +762,11 @@ class JniGeneratorSanitizer(BaseActionSanitizer): self._update_list_arg('--input_file', self._add_location_tag_to_filepath) return super().get_args() + def get_outputs(self): + # fix target.output directory to match #include statements. + self.target.outputs = {re.sub('^jni_headers/', '', out) for out in self.target.outputs} + return super().get_outputs() + class JniRegistrationGeneratorSanitizer(BaseActionSanitizer): def get_args(self): self._update_value_arg('--depfile', self._sanitize_filepath) @@ -847,9 +852,6 @@ def create_action_module(blueprint, target, type): target.outputs = sanitizer.get_outputs() if target.script == '//base/android/jni_generator/jni_generator.py': - # fix target.output directory to match #include statements. - target.outputs = {re.sub('^jni_headers/', '', out) for out in target.outputs} - # android_jar.classes should be part of the tools as it list implicit classes # for the script to generate JNI headers. module.tool_files.add("base/android/jni_generator/android_jar.classes") From 242132378fa76db3d13c7e279a7428ada6d1699e Mon Sep 17 00:00:00 2001 From: Motomu Utsumi Date: Fri, 2 Dec 2022 16:04:05 +0900 Subject: [PATCH 08/16] gn2bp: Use the result of get_outputs as module.out Test: ./update_results.sh Change-Id: Ia3a1b2e8fd1beb71fe5778dc786422309730719a --- tools/gn2bp/gen_android_bp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/gn2bp/gen_android_bp b/tools/gn2bp/gen_android_bp index 58a83463db..512b0db755 100755 --- a/tools/gn2bp/gen_android_bp +++ b/tools/gn2bp/gen_android_bp @@ -849,7 +849,7 @@ def create_action_module(blueprint, target, type): sanitizer = get_action_sanitizer(target) target.args = sanitizer.get_args() - target.outputs = sanitizer.get_outputs() + module.out = sanitizer.get_outputs() if target.script == '//base/android/jni_generator/jni_generator.py': # android_jar.classes should be part of the tools as it list implicit classes @@ -908,8 +908,6 @@ def create_action_module(blueprint, target, type): if script in module.srcs: module.srcs.remove(script) - module.out.update(target.outputs) - if target.script == '//base/android/jni_generator/jni_registration_generator.py': # jni_registration_generator.py doesn't work with python2 module.cmd = "python3 " + module.cmd From d22edf0b0dbf169ff9e7370f3b24308648820587 Mon Sep 17 00:00:00 2001 From: Motomu Utsumi Date: Fri, 2 Dec 2022 16:06:26 +0900 Subject: [PATCH 09/16] gn2bp: Remove unrequired hack for action_with_pydeps Test: ./update_results.sh Change-Id: Iee268ae92fa5f90d859b533304c102e3a17d04cf --- tools/gn2bp/gen_android_bp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tools/gn2bp/gen_android_bp b/tools/gn2bp/gen_android_bp index 512b0db755..6864ed19b5 100755 --- a/tools/gn2bp/gen_android_bp +++ b/tools/gn2bp/gen_android_bp @@ -903,11 +903,6 @@ def create_action_module(blueprint, target, type): else: module.tool_files.add(gn_utils.label_to_path(it)) - # Actions using template "action_with_pydeps" also put script inside inputs. - # TODO: it might make sense to filter inputs inside GnParser. - if script in module.srcs: - module.srcs.remove(script) - if target.script == '//base/android/jni_generator/jni_registration_generator.py': # jni_registration_generator.py doesn't work with python2 module.cmd = "python3 " + module.cmd From 7db7583ba19c62dc5a906ab684446192e10ba6f0 Mon Sep 17 00:00:00 2001 From: Motomu Utsumi Date: Fri, 2 Dec 2022 16:46:22 +0900 Subject: [PATCH 10/16] gn2bp: Add is_header_generated to the BaseActionSanitizer Test: ./update_results.sh Change-Id: I0ce8fa4cc9b483e9ae19a3383e4fe8d0ab5f4bf3 --- tools/gn2bp/gen_android_bp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/gn2bp/gen_android_bp b/tools/gn2bp/gen_android_bp index 6864ed19b5..d735a314c7 100755 --- a/tools/gn2bp/gen_android_bp +++ b/tools/gn2bp/gen_android_bp @@ -731,6 +731,10 @@ class BaseActionSanitizer(): def get_outputs(self): return self.target.outputs + # Whether this target generates header files + def is_header_generated(self): + return False + class WriteBuildDateHeaderSanitizer(BaseActionSanitizer): def get_args(self): self._set_arg_at(0, '$(out)') @@ -850,6 +854,8 @@ def create_action_module(blueprint, target, type): sanitizer = get_action_sanitizer(target) target.args = sanitizer.get_args() module.out = sanitizer.get_outputs() + if sanitizer.is_header_generated(): + module.genrule_headers.add(module.name) if target.script == '//base/android/jni_generator/jni_generator.py': # android_jar.classes should be part of the tools as it list implicit classes From 9701d2f0aec02e3076e6d354cd2e80a459eef320 Mon Sep 17 00:00:00 2001 From: Motomu Utsumi Date: Fri, 2 Dec 2022 16:53:06 +0900 Subject: [PATCH 11/16] gn2bp: Add MakeDafsaSanitizer Test: ./update_results.sh Change-Id: I6c18497ea0cfa1c28b44e2c80545b08fe34311ef --- tools/gn2bp/gen_android_bp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/gn2bp/gen_android_bp b/tools/gn2bp/gen_android_bp index d735a314c7..9b30095317 100755 --- a/tools/gn2bp/gen_android_bp +++ b/tools/gn2bp/gen_android_bp @@ -797,6 +797,10 @@ class JavaCppEnumSanitizer(BaseActionSanitizer): self._set_value_arg('--srcjar', '$(out)') return super().get_args() +class MakeDafsaSanitizer(BaseActionSanitizer): + def is_header_generated(self): + return super().is_header_generated() + def get_action_sanitizer(target): if target.script == "//build/write_buildflag_header.py": return WriteBuildFlagHeaderSanitizer(target) @@ -810,6 +814,8 @@ def get_action_sanitizer(target): return VersionSanitizer(target) elif target.script == "//build/android/gyp/java_cpp_enum.py": return JavaCppEnumSanitizer(target) + elif target.script == "//net/tools/dafsa/make_dafsa.py": + return MakeDafsaSanitizer(target) else: # TODO: throw exception here once all script hacks have been converted. return BaseActionSanitizer(target) From 1e028b80015164eabc9ac25c2ba1d3cbcbe1a9b0 Mon Sep 17 00:00:00 2001 From: Motomu Utsumi Date: Fri, 2 Dec 2022 16:54:20 +0900 Subject: [PATCH 12/16] gn2bp: Update is_header_generated of MakeDafsaSanitizer Test: ./update_results.sh Change-Id: Idc7a2ed2f72a5c0b2f9c623603a30e0fcd3f52c9 --- tools/gn2bp/gen_android_bp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tools/gn2bp/gen_android_bp b/tools/gn2bp/gen_android_bp index 9b30095317..3053d5d5ed 100755 --- a/tools/gn2bp/gen_android_bp +++ b/tools/gn2bp/gen_android_bp @@ -799,7 +799,9 @@ class JavaCppEnumSanitizer(BaseActionSanitizer): class MakeDafsaSanitizer(BaseActionSanitizer): def is_header_generated(self): - return super().is_header_generated() + # This script generates .cc files but they are #included by other sources + # (e.g. registry_controlled_domain.cc) + return True def get_action_sanitizer(target): if target.script == "//build/write_buildflag_header.py": @@ -875,10 +877,6 @@ def create_action_module(blueprint, target, type): target.deps.clear() target.inputs = [file for file in target.inputs if not file.startswith('//out/')] - elif target.script == "//net/tools/dafsa/make_dafsa.py": - # This script generates .cc files but source (registry_controlled_domain.cc) in the target that - # depends on this target includes .cc file this script generates. - module.genrule_headers.add(module.name) elif target.script == "//build/util/version.py": # android_chrome_version.py is not specified in anywhere but version.py imports this file module.tool_files.add('build/util/android_chrome_version.py') From a91ade6394fa58e308a422fd5bc4a983b853e7ed Mon Sep 17 00:00:00 2001 From: Motomu Utsumi Date: Fri, 2 Dec 2022 16:58:36 +0900 Subject: [PATCH 13/16] gn2bp: Update is_header_generated in the BaseActionSanitizer Test: ./update_results.sh Change-Id: I133dfdd72cb35ed9e47e64ef84b5c2f66e28580e --- tools/gn2bp/gen_android_bp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tools/gn2bp/gen_android_bp b/tools/gn2bp/gen_android_bp index 3053d5d5ed..032e5d7e33 100755 --- a/tools/gn2bp/gen_android_bp +++ b/tools/gn2bp/gen_android_bp @@ -733,7 +733,7 @@ class BaseActionSanitizer(): # Whether this target generates header files def is_header_generated(self): - return False + return any(os.path.splitext(it)[1] == '.h' for it in self.target.outputs) class WriteBuildDateHeaderSanitizer(BaseActionSanitizer): def get_args(self): @@ -901,9 +901,6 @@ def create_action_module(blueprint, target, type): # Pipe response file contents into script module.cmd = 'echo \'%s\' |%s%s' % (target.response_file_contents, NEWLINE, module.cmd) - if any(os.path.splitext(it)[1] == '.h' for it in target.outputs): - module.genrule_headers.add(bp_module_name) - # gn treats inputs and sources for actions equally. # soong only supports source files inside srcs, non-source files are added as # tool_files dependency. From cdb45eafe91fa3df3b983e806ca5e714c0d33c7f Mon Sep 17 00:00:00 2001 From: Motomu Utsumi Date: Fri, 2 Dec 2022 17:05:07 +0900 Subject: [PATCH 14/16] gn2bp: Add sanitize API to the BaseActionSanitizer Currently, Sanitizer modifies target attributes in the get APIs. However, some sanitize methods are not idempotent (e.g. _add_location_tag). Also, get API could depends on the same target attributes, at this point, get_srcs and get_tool_files will depends on target.sources and target.inputs. This could easily cause issue by calling non idempotent sanitize methods multiple times. This CL introduces sanitize API to prevent this issue. sanitize API modifies all the required target attributes and other get APIs only read the sanitized target attributes. This makes it easy to guarantee that sanitization is done only once. Test: ./update_results.sh Change-Id: I1b4033ae161284ef07153b56e05217b8557b4cba --- tools/gn2bp/gen_android_bp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tools/gn2bp/gen_android_bp b/tools/gn2bp/gen_android_bp index 032e5d7e33..4029837411 100755 --- a/tools/gn2bp/gen_android_bp +++ b/tools/gn2bp/gen_android_bp @@ -731,6 +731,16 @@ class BaseActionSanitizer(): def get_outputs(self): return self.target.outputs + def _sanitize_args(self): + pass + + def _sanitize_outputs(self): + pass + + def sanitize(self): + self._sanitize_args() + self._sanitize_outputs() + # Whether this target generates header files def is_header_generated(self): return any(os.path.splitext(it)[1] == '.h' for it in self.target.outputs) @@ -860,6 +870,7 @@ def create_action_module(blueprint, target, type): module = Module(type, bp_module_name, target.name) sanitizer = get_action_sanitizer(target) + sanitizer.sanitize() target.args = sanitizer.get_args() module.out = sanitizer.get_outputs() if sanitizer.is_header_generated(): From 805591d7d8268cc87cfd4eaabd445ccfbd777af4 Mon Sep 17 00:00:00 2001 From: Motomu Utsumi Date: Fri, 2 Dec 2022 17:17:16 +0900 Subject: [PATCH 15/16] gn2bp: Move arg sanitizing from get_args to _sanitize_args Test: ./update_results.sh Change-Id: I00ae8f7d801c611aec1b8d279db81a372eb3b88d --- tools/gn2bp/gen_android_bp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tools/gn2bp/gen_android_bp b/tools/gn2bp/gen_android_bp index 4029837411..aef51b5d65 100755 --- a/tools/gn2bp/gen_android_bp +++ b/tools/gn2bp/gen_android_bp @@ -746,15 +746,15 @@ class BaseActionSanitizer(): return any(os.path.splitext(it)[1] == '.h' for it in self.target.outputs) class WriteBuildDateHeaderSanitizer(BaseActionSanitizer): - def get_args(self): + def _sanitize_args(self): self._set_arg_at(0, '$(out)') - return super().get_args() + super()._sanitize_args() class WriteBuildFlagHeaderSanitizer(BaseActionSanitizer): - def get_args(self): + def _sanitize_args(self): self._set_value_arg('--gen-dir', '.') self._set_value_arg('--output', '$(out)') - return super().get_args() + super()._sanitize_args() class JniGeneratorSanitizer(BaseActionSanitizer): def _add_location_tag_to_filepath(self, arg): @@ -764,7 +764,7 @@ class JniGeneratorSanitizer(BaseActionSanitizer): arg = self._add_location_tag(arg) return arg - def get_args(self): + def _sanitize_args(self): self._update_value_arg('--jar_file', self._sanitize_filepath, False) self._update_value_arg('--jar_file', self._add_location_tag, False) if self._has_arg('--jar_file'): @@ -774,7 +774,7 @@ class JniGeneratorSanitizer(BaseActionSanitizer): self._delete_value_arg('--prev_output_dir', False) self._update_list_arg('--input_file', self._sanitize_filepath) self._update_list_arg('--input_file', self._add_location_tag_to_filepath) - return super().get_args() + super()._sanitize_args() def get_outputs(self): # fix target.output directory to match #include statements. @@ -782,7 +782,7 @@ class JniGeneratorSanitizer(BaseActionSanitizer): return super().get_outputs() class JniRegistrationGeneratorSanitizer(BaseActionSanitizer): - def get_args(self): + def _sanitize_args(self): self._update_value_arg('--depfile', self._sanitize_filepath) self._update_value_arg('--srcjar-path', self._sanitize_filepath) self._update_value_arg('--header-path', self._sanitize_filepath) @@ -790,22 +790,22 @@ class JniRegistrationGeneratorSanitizer(BaseActionSanitizer): # update_jni_registration_module removes them from the srcs of the module # It might be better to remove sources by '--sources-exclusions' self._delete_value_arg('--sources-exclusions') - return super().get_args() + super()._sanitize_args() class VersionSanitizer(BaseActionSanitizer): - def get_args(self): + def _sanitize_args(self): self._set_value_arg('-o', '$(out)') # args for the version.py contain file path without leading --arg key. So apply sanitize # function for all the args. self._update_all_args(self._sanitize_filepath_with_location_tag) self._update_value_arg('-e', lambda arg: arg.replace('"', r'\"')) - return super().get_args() + super()._sanitize_args() class JavaCppEnumSanitizer(BaseActionSanitizer): - def get_args(self): + def _sanitize_args(self): self._update_all_args(self._sanitize_filepath_with_location_tag) self._set_value_arg('--srcjar', '$(out)') - return super().get_args() + super()._sanitize_args() class MakeDafsaSanitizer(BaseActionSanitizer): def is_header_generated(self): From 9401996791c2e3a6a2ee4c57cb062d890720db9d Mon Sep 17 00:00:00 2001 From: Motomu Utsumi Date: Fri, 2 Dec 2022 17:18:58 +0900 Subject: [PATCH 16/16] gn2bp: Move arg output from get_outputs to _sanitize_outputs Test: ./update_results.sh Change-Id: I119583b64373e2a3ed78358dddead857fd6f4006 --- tools/gn2bp/gen_android_bp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/gn2bp/gen_android_bp b/tools/gn2bp/gen_android_bp index aef51b5d65..3f1318bcda 100755 --- a/tools/gn2bp/gen_android_bp +++ b/tools/gn2bp/gen_android_bp @@ -776,10 +776,10 @@ class JniGeneratorSanitizer(BaseActionSanitizer): self._update_list_arg('--input_file', self._add_location_tag_to_filepath) super()._sanitize_args() - def get_outputs(self): + def _sanitize_outputs(self): # fix target.output directory to match #include statements. self.target.outputs = {re.sub('^jni_headers/', '', out) for out in self.target.outputs} - return super().get_outputs() + super()._sanitize_outputs() class JniRegistrationGeneratorSanitizer(BaseActionSanitizer): def _sanitize_args(self):