gn2bp: Replace arg by $(out) if possible
This change may not work for the other targets.
Test: //base:base_static
Change-Id: Ia92c41906876b5d952f84f917060d1e8f4d731b5
diff --git a/tools/gn2bp/gen_android_bp b/tools/gn2bp/gen_android_bp
index ee092db..d3b43a8 100755
--- a/tools/gn2bp/gen_android_bp
+++ b/tools/gn2bp/gen_android_bp
@@ -671,6 +671,11 @@
script = gn_utils.label_to_path(target.script)
module.tool_files.add(script)
+ # Replace arg by {$out} if possible
+ if len(target.outputs) == 1:
+ out = list(target.outputs)[0]
+ target.args = ['$(out)' if arg == out else arg for arg in target.args]
+
# Handle passing parameters via response file by piping them into the script
# and reading them from /dev/stdin.
response_file = '{{response_file_name}}'