• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "gn/settings.h"
6 
7 #include "base/logging.h"
8 #include "gn/filesystem_utils.h"
9 #include "util/build_config.h"
10 
Settings(const BuildSettings * build_settings,const std::string & output_subdir_name)11 Settings::Settings(const BuildSettings* build_settings,
12                    const std::string& output_subdir_name)
13     : build_settings_(build_settings), base_config_(this) {
14   if (output_subdir_name.empty()) {
15     toolchain_output_dir_ = build_settings->build_dir();
16   } else {
17     // We guarantee this ends in a slash.
18     DCHECK(output_subdir_name[output_subdir_name.size() - 1] == '/');
19     toolchain_output_subdir_.value().append(output_subdir_name);
20 
21     DCHECK(!build_settings->build_dir().is_null());
22     toolchain_output_dir_ = SourceDir(build_settings->build_dir().value() +
23                                       toolchain_output_subdir_.value());
24   }
25   // The output dir will be null in some tests and when invoked to parsed
26   // one-off data without doing generation.
27   if (!toolchain_output_dir_.is_null())
28     toolchain_gen_dir_ = SourceDir(toolchain_output_dir_.value() + "gen/");
29 }
30