Commit a104997e authored by phosek's avatar phosek Committed by Commit Bot

Allow overriding script executable in .gn file

This eliminates the need for using gn executable wrapper in cases
where a custom script interpreter is always being used.

Review-Url: https://codereview.chromium.org/2936773006
Cr-Commit-Position: refs/heads/master@{#481105}
parent 836e2631
...@@ -598,7 +598,7 @@ ...@@ -598,7 +598,7 @@
### <a name="gen:"></a>**gn gen**: Generate ninja files. ### <a name="gen:"></a>**gn gen**: Generate ninja files.
``` ```
gn gen [<ide options>] <out_dir> gn gen [--check] [<ide options>] <out_dir>
Generates ninja files from the current tree and puts them in the given output Generates ninja files from the current tree and puts them in the given output
directory. directory.
...@@ -608,6 +608,9 @@ ...@@ -608,6 +608,9 @@
Or it can be a directory relative to the current directory such as: Or it can be a directory relative to the current directory such as:
out/foo out/foo
"gn gen --check" is the same as running "gn check". See "gn help check"
for documentation on that mode.
See "gn help switches" for the common command-line switches. See "gn help switches" for the common command-line switches.
``` ```
...@@ -645,6 +648,11 @@ ...@@ -645,6 +648,11 @@
--no-deps --no-deps
Don't include targets dependencies to the solution. Changes the way how Don't include targets dependencies to the solution. Changes the way how
--filters option works. Only directly matching targets are included. --filters option works. Only directly matching targets are included.
--winsdk=<sdk_version>
Use the specified Windows 10 SDK version to generate project files.
As an example, "10.0.15063.0" can be specified to use Creators Update SDK
instead of the default one.
``` ```
#### **Xcode Flags** #### **Xcode Flags**
...@@ -688,9 +696,10 @@ ...@@ -688,9 +696,10 @@
#### **Generic JSON Output** #### **Generic JSON Output**
``` ```
Dumps target information to JSON file and optionally invokes python script on Dumps target information to a JSON file and optionally invokes a
generated file. See comments at the beginning of json_project_writer.cc and python script on the generated file. See the comments at the beginning
desc_builder.cc for overview of JSON file format. of json_project_writer.cc and desc_builder.cc for an overview of the JSON
file format.
--json-file-name=<json_file_name> --json-file-name=<json_file_name>
Overrides default file name (project.json) of generated JSON file. Overrides default file name (project.json) of generated JSON file.
...@@ -1932,7 +1941,7 @@ ...@@ -1932,7 +1941,7 @@
get_label_info(":foo", "name") get_label_info(":foo", "name")
# Returns string "foo". # Returns string "foo".
get_label_info("//foo/bar:baz", "gen_dir") get_label_info("//foo/bar:baz", "target_gen_dir")
# Returns string "//out/Debug/gen/foo/bar". # Returns string "//out/Debug/gen/foo/bar".
``` ```
### <a name="get_path_info"></a>**get_path_info**: Extract parts of a file or directory name. ### <a name="get_path_info"></a>**get_path_info**: Extract parts of a file or directory name.
...@@ -5358,6 +5367,11 @@ ...@@ -5358,6 +5367,11 @@
build file containing this target name. This defaults to "//:" which will build file containing this target name. This defaults to "//:" which will
cause the file //BUILD.gn to be loaded. 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] secondary_source [optional]
Label of an alternate directory tree to find input files. When searching 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 for a BUILD.gn file (or the build config file discussed above), the file
......
...@@ -98,6 +98,11 @@ Variables ...@@ -98,6 +98,11 @@ Variables
build file containing this target name. This defaults to "//:" which will build file containing this target name. This defaults to "//:" which will
cause the file //BUILD.gn to be loaded. 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] secondary_source [optional]
Label of an alternate directory tree to find input files. When searching 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 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) { ...@@ -314,13 +319,6 @@ bool Setup::DoSetup(const std::string& build_dir, bool force_create) {
if (!FillBuildDir(build_dir, !force_create)) if (!FillBuildDir(build_dir, !force_create))
return false; 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). // Apply project-specific default (if specified).
// Must happen before FillArguments(). // Must happen before FillArguments().
if (default_args_) { if (default_args_) {
...@@ -333,7 +331,15 @@ bool Setup::DoSetup(const std::string& build_dir, bool force_create) { ...@@ -333,7 +331,15 @@ bool Setup::DoSetup(const std::string& build_dir, bool force_create) {
if (!FillArguments(*cmdline)) if (!FillArguments(*cmdline))
return false; 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; return true;
} }
...@@ -626,12 +632,21 @@ bool Setup::FillBuildDir(const std::string& build_dir, bool require_exists) { ...@@ -626,12 +632,21 @@ bool Setup::FillBuildDir(const std::string& build_dir, bool require_exists) {
return true; 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. // Trace this since it tends to be a bit slow on Windows.
ScopedTrace setup_trace(TraceItem::TRACE_SETUP, "Fill Python Path"); ScopedTrace setup_trace(TraceItem::TRACE_SETUP, "Fill Python Path");
const Value* value = dotfile_scope_.GetValue("script_executable", true);
if (cmdline.HasSwitch(switches::kScriptExecutable)) { if (cmdline.HasSwitch(switches::kScriptExecutable)) {
build_settings_.set_python_path( build_settings_.set_python_path(
cmdline.GetSwitchValuePath(switches::kScriptExecutable)); 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 { } else {
#if defined(OS_WIN) #if defined(OS_WIN)
base::FilePath python_path = FindWindowsPython(); base::FilePath python_path = FindWindowsPython();
...@@ -645,6 +660,7 @@ void Setup::FillPythonPath(const base::CommandLine& cmdline) { ...@@ -645,6 +660,7 @@ void Setup::FillPythonPath(const base::CommandLine& cmdline) {
build_settings_.set_python_path(base::FilePath("python")); build_settings_.set_python_path(base::FilePath("python"));
#endif #endif
} }
return true;
} }
bool Setup::RunConfigFile() { bool Setup::RunConfigFile() {
......
...@@ -119,7 +119,7 @@ class Setup { ...@@ -119,7 +119,7 @@ class Setup {
// Fills the python path portion of the command line. On failure, sets // Fills the python path portion of the command line. On failure, sets
// it to just "python". // it to just "python".
void FillPythonPath(const base::CommandLine& cmdline); bool FillPythonPath(const base::CommandLine& cmdline);
// Run config file. // Run config file.
bool RunConfigFile(); bool RunConfigFile();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment