gn2bp: fix response_file_contents parsing
Test: //base:base
Change-Id: I6a90f684d31a83323580001822b0cc3745497baa
diff --git a/tools/gn2bp/gn_utils.py b/tools/gn2bp/gn_utils.py
index 82ff2bb..7e6752b 100644
--- a/tools/gn2bp/gn_utils.py
+++ b/tools/gn2bp/gn_utils.py
@@ -171,11 +171,19 @@
self.proto_libs = {}
def _get_response_file_contents(self, action_desc):
- contents = ' '.join(action_desc.get('response_file_contents', []))
- # escape both single and double quotes.
- contents.replace('"', '\"')
- contents.replace("'", '\'')
- return contents
+ # response_file_contents are formatted as:
+ # ['--flags', '--flag=true && false'] and need to be formatted as:
+ # '--flags --flag=\"true && false\"'
+ flags = action_desc.get('response_file_contents', [])
+ formatted_flags = []
+ for flag in flags:
+ if '=' in flag:
+ key, val = flag.split('=')
+ formatted_flags.append('%s=\\"%s\\"' % (key, val))
+ else:
+ formatted_flags.append(flag)
+
+ return ' '.join(formatted_flags)
def get_target(self, gn_target_name):
"""Returns a Target object from the fully qualified GN target name.