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

Unified Diff: tools/perf/conditionally_execute

Issue 2921353002: Refactor how we fetch Telemetry deps conditionally (Closed)
Patch Set: Update path ref Created 3 years, 6 months 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 | « DEPS ('k') | tools/perf/fetch_benchmark_deps.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/perf/conditionally_execute
diff --git a/tools/perf/conditionally_execute b/tools/perf/conditionally_execute
new file mode 100755
index 0000000000000000000000000000000000000000..7c35ad65ce4e81e8a80d0347b9f96ae6fe83538a
--- /dev/null
+++ b/tools/perf/conditionally_execute
@@ -0,0 +1,37 @@
+#!/usr/bin/env python
+# Copyright 2017 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+import argparse
+import os
+import subprocess
+import sys
+
+
+def main(args):
+ parser = argparse.ArgumentParser()
+ parser.add_argument(
+ '--gyp-condition', '-c', type=str, required=True,
+ help=('Name of environment variable that acts as the switch. If the '
Kai Ninomiya 2017/06/05 21:58:51 nit: it's not really an environment variable that
nednguyen 2017/06/05 22:24:24 Done.
+ 'variable is set in the environment, this will execute the target '
+ 'script'))
+ options, script_args = parser.parse_known_args()
+
+ # Make sure that we always execute target script with python.
+ if 'python' not in script_args[0]:
+ script_args.insert(0, sys.executable)
+
+ gyp_defines = os.environ.get('GYP_DEFINES', '')
+ if options.gyp_condition in gyp_defines:
Kai Ninomiya 2017/06/05 21:58:51 This may not matter since this should get replaced
nednguyen 2017/06/05 22:24:24 Done.
+ print 'Found matching condition in GYP_DEFINES. Execute: %s' % (
+ ' '.join(script_args))
+ subprocess.check_call(script_args)
+ else:
+ print ('Not found "%s" condition in GYP_DEFINES="%s". '
+ 'Skip script execution.' %
+ (options.gyp_condition, gyp_defines))
+ return 0
+
+
+if __name__ == '__main__':
+ main(sys.argv[1:])
« no previous file with comments | « DEPS ('k') | tools/perf/fetch_benchmark_deps.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698