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

Unified Diff: tools/gn/setup.cc

Issue 2936773006: Allow overriding script executable in .gn file (Closed)
Patch Set: Windows path handling 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 | « tools/gn/setup.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/setup.cc
diff --git a/tools/gn/setup.cc b/tools/gn/setup.cc
index 192230d67d99ef60c89b003a970c6c0a19744b35..7fc4a2ed4f29e09857304d0dc9abefc38fe9acf8 100644
--- a/tools/gn/setup.cc
+++ b/tools/gn/setup.cc
@@ -98,6 +98,11 @@ Variables
build file containing this target name. This defaults to "//:" which will
cause the file //BUILD.gn to be loaded.
+ script_executable [optional]
+ Path to specific Python executable or potentially a different language
+ interpreter that is used to execute scripts in action targets and
+ exec_script calls.
+
secondary_source [optional]
Label of an alternate directory tree to find input files. When searching
for a BUILD.gn file (or the build config file discussed above), the file
@@ -314,13 +319,6 @@ bool Setup::DoSetup(const std::string& build_dir, bool force_create) {
if (!FillBuildDir(build_dir, !force_create))
return false;
- // Check for unused variables in the .gn file.
- Err err;
- if (!dotfile_scope_.CheckForUnusedVars(&err)) {
- err.PrintToStdout();
- return false;
- }
-
// Apply project-specific default (if specified).
// Must happen before FillArguments().
if (default_args_) {
@@ -333,7 +331,15 @@ bool Setup::DoSetup(const std::string& build_dir, bool force_create) {
if (!FillArguments(*cmdline))
return false;
}
- FillPythonPath(*cmdline);
+ if (!FillPythonPath(*cmdline))
+ return false;
+
+ // Check for unused variables in the .gn file.
+ Err err;
+ if (!dotfile_scope_.CheckForUnusedVars(&err)) {
+ err.PrintToStdout();
+ return false;
+ }
return true;
}
@@ -626,12 +632,21 @@ bool Setup::FillBuildDir(const std::string& build_dir, bool require_exists) {
return true;
}
-void Setup::FillPythonPath(const base::CommandLine& cmdline) {
+bool Setup::FillPythonPath(const base::CommandLine& cmdline) {
// Trace this since it tends to be a bit slow on Windows.
ScopedTrace setup_trace(TraceItem::TRACE_SETUP, "Fill Python Path");
+ const Value* value = dotfile_scope_.GetValue("script_executable", true);
if (cmdline.HasSwitch(switches::kScriptExecutable)) {
build_settings_.set_python_path(
cmdline.GetSwitchValuePath(switches::kScriptExecutable));
+ } else if (value) {
+ Err err;
+ if (!value->VerifyTypeIs(Value::STRING, &err)) {
+ err.PrintToStdout();
+ return false;
+ }
+ build_settings_.set_python_path(
+ base::FilePath(UTF8ToFilePath(value->string_value())));
} else {
#if defined(OS_WIN)
base::FilePath python_path = FindWindowsPython();
@@ -645,6 +660,7 @@ void Setup::FillPythonPath(const base::CommandLine& cmdline) {
build_settings_.set_python_path(base::FilePath("python"));
#endif
}
+ return true;
}
bool Setup::RunConfigFile() {
« no previous file with comments | « tools/gn/setup.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698