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

Unified Diff: build/gn_run_binary.py

Issue 2494853002: Make gn_run_binary.py do the right thing for compiled_action (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « build/compiled_action.gni ('k') | build/prebuilt_dart_sdk.gni » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/gn_run_binary.py
diff --git a/build/gn_run_binary.py b/build/gn_run_binary.py
index 5d3ba453558c3d858f9b4a271f6616133ff09188..76d19923dea8f59d4e3241722fc865b786a4ac4e 100755
--- a/build/gn_run_binary.py
+++ b/build/gn_run_binary.py
@@ -6,7 +6,12 @@
"""Helper script for GN to run an arbitrary binary. See compiled_action.gni.
Run with:
- python gn_run_binary.py <binary_name> [args ...]
+ python gn_run_binary.py <invoker> <binary_name> [args ...]
+
+Where <invoker> is either "compiled_action" or "exec_script". If it is
+"compiled_action" the script has a non-zero exit code on a failure. If it is
+"exec_script" the script has no output on success and produces output otherwise,
+but always has an exit code of 0.
"""
import os
@@ -23,24 +28,33 @@ def run_command(command):
"output: " + e.output)
def main(argv):
+ error_exit = 0
+ if argv[1] == "compiled_action":
+ error_exit = 1
+ elif argv[1] != "exec_script":
+ print ("The first argument should be either "
+ "'compiled_action' or 'exec_script")
+ return 1
+
# Unless the path is absolute, this script is designed to run binaries
# produced by the current build. We always prefix it with "./" to avoid
# picking up system versions that might also be on the path.
- if os.path.isabs(argv[1]):
- path = argv[1]
+ if os.path.isabs(argv[2]):
+ path = argv[2]
else:
- path = './' + argv[1]
+ path = './' + argv[2]
if not os.path.isfile(path):
print "Binary not found: " + path
- return 0
+ return error_exit
# The rest of the arguements are passed directly to the executable.
- args = [path] + argv[2:]
+ args = [path] + argv[3:]
result = run_command(args)
if result != 0:
print result
+ return error_exit
return 0
if __name__ == '__main__':
« no previous file with comments | « build/compiled_action.gni ('k') | build/prebuilt_dart_sdk.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698