| 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;
|
| }
|
|
|