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

Unified Diff: tools/gn/setup.cc

Issue 558763002: Require build directories exist for some GN commands. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: file path literal Created 6 years, 3 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 02ab3ca912de485883510b413ca202a974c88e59..7ffe2f89d1d8447e02e9b9822841bc05f10ef47c 100644
--- a/tools/gn/setup.cc
+++ b/tools/gn/setup.cc
@@ -225,7 +225,7 @@ Setup::Setup()
Setup::~Setup() {
}
-bool Setup::DoSetup(const std::string& build_dir) {
+bool Setup::DoSetup(const std::string& build_dir, bool force_create) {
CommandLine* cmdline = CommandLine::ForCurrentProcess();
scheduler_.set_verbose_logging(cmdline->HasSwitch(kSwitchVerbose));
@@ -241,8 +241,11 @@ bool Setup::DoSetup(const std::string& build_dir) {
return false;
if (!FillOtherConfig(*cmdline))
return false;
- if (!FillBuildDir(build_dir)) // Must be after FillSourceDir to resolve.
+
+ // Must be after FillSourceDir to resolve.
+ if (!FillBuildDir(build_dir, !force_create))
return false;
+
if (fill_arguments_) {
if (!FillArguments(*cmdline))
return false;
@@ -438,7 +441,7 @@ bool Setup::FillSourceDir(const CommandLine& cmdline) {
return true;
}
-bool Setup::FillBuildDir(const std::string& build_dir) {
+bool Setup::FillBuildDir(const std::string& build_dir, bool require_exists) {
SourceDir resolved =
SourceDirForCurrentDirectory(build_settings_.root_path()).
ResolveRelativeDir(build_dir);
@@ -451,6 +454,21 @@ bool Setup::FillBuildDir(const std::string& build_dir) {
if (scheduler_.verbose_logging())
scheduler_.Log("Using build dir", resolved.value());
+
+ if (require_exists) {
+ base::FilePath build_dir_path = build_settings_.GetFullPath(resolved);
+ if (!base::PathExists(build_dir_path.Append(
+ FILE_PATH_LITERAL("build.ninja")))) {
+ Err(Location(), "Not a build directory.",
+ "This command requires an existing build directory. I interpreted "
+ "your input\n\"" + build_dir + "\" as:\n " +
+ FilePathToUTF8(build_dir_path) +
+ "\nwhich doesn't seem to contain a previously-generated build.")
+ .PrintToStdout();
+ return false;
+ }
+ }
+
build_settings_.SetBuildDir(resolved);
return true;
}
« 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