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 "tools/gn/settings.h"
6
7#include "base/logging.h"
8#include "build/build_config.h"
9#include "tools/gn/filesystem_utils.h"
10
11Settings::Settings(const BuildSettings* build_settings,
12                   const Toolchain* toolchain,
13                   const std::string& output_subdir_name)
14    : build_settings_(build_settings),
15      toolchain_(toolchain),
16      import_manager_(),
17      base_config_(this),
18      greedy_target_generation_(false) {
19  DCHECK(output_subdir_name.find('/') == std::string::npos);
20  if (output_subdir_name.empty()) {
21    toolchain_output_dir_ = build_settings->build_dir();
22  } else {
23    // We guarantee this ends in a slash.
24    toolchain_output_subdir_.value().append(output_subdir_name);
25    toolchain_output_subdir_.value().push_back('/');
26
27    toolchain_output_dir_ = SourceDir(build_settings->build_dir().value() +
28                                      toolchain_output_subdir_.value());
29  }
30  // The output dir will be null in some tests and when invoked to parsed
31  // one-off data without doing generation.
32  if (!toolchain_output_dir_.is_null())
33    toolchain_gen_dir_ = SourceDir(toolchain_output_dir_.value() + "gen/");
34
35
36#if defined(OS_WIN)
37  target_os_ = WIN;
38#elif defined(OS_MACOSX)
39  target_os_ = MAC;
40#elif defined(OS_LINUX)
41  target_os_ = LINUX;
42#else
43  #error implement me
44#endif
45}
46
47Settings::~Settings() {
48}
49
50
51