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

Unified Diff: tools/gn/args.cc

Issue 914873002: Rework handling of os and cpu_arch in GN. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 | « no previous file | tools/gn/command_args.cc » ('j') | tools/gn/format_test_data/030.golden » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/args.cc
diff --git a/tools/gn/args.cc b/tools/gn/args.cc
index c7c8a0939ca605ec632f6074874a507f3a6b92a1..2975cbd8689c052f9277ac32c5087b1c7e0766b5 100644
--- a/tools/gn/args.cc
+++ b/tools/gn/args.cc
@@ -18,10 +18,10 @@ const char kBuildArgs_Help[] =
"\n"
" First, system default arguments are set based on the current system.\n"
" The built-in arguments are:\n"
- " - cpu_arch (by default this is the same as \"default_cpu_arch\")\n"
- " - default_cpu_arch\n"
- " - default_os\n"
- " - os (by default this is the same as \"default_os\")\n"
+ " - build_cpu_arch\n"
+ " - build_os\n"
+ " - cpu_arch (by default this is the same as \"build_cpu_arch\")\n"
+ " - os (by default this is the same as \"build_os\")\n"
"\n"
" If specified, arguments from the --args command line flag are used. If\n"
" that flag is not specified, args from previous builds in the build\n"
@@ -123,6 +123,27 @@ bool Args::DeclareArgs(const Scope::KeyValueMap& args,
base::AutoLock lock(lock_);
for (const auto& arg : args) {
+ std::string arg_name = arg.first.as_string();
+
+ // TODO(dpranke): Figure out how to allow a declare_args() block
+ // to update the value of a built-in variable. I think we want
+ // something like:
+ //
+ // if (arg_name == variables::kBuildCpuArch ||
+ // arg_name == variables::kBuildOs ||
+ // arg_name == variables::kCpuArch ||
+ // arg_name == variables::kOs ||
+ // arg_name == variables::kTargetCpuArch ||
+ // arg_name == variables::kTargetOs) {
+ // Scope::KeyValueMap::iterator previously_declared =
+ // declared_arguments_.find(arg.first);
+ // CHECK(previously_declared != declared_arguments_.end());
+ // if (previously_declared->second.origin() == nullptr) {
+ // previously_declared->second.set_origin(arg.second.origin());
+ // // TODO: update the built-in variable's value somehow.
+ // }
+ // }
+
Dirk Pranke 2015/02/11 02:34:31 Brett: I couldn't figure out how to make this work
// Verify that the value hasn't already been declared. We want each value
// to be declared only once.
//
@@ -224,6 +245,7 @@ void Args::SetSystemVarsLocked(Scope* dest) const {
Value os_val(nullptr, std::string(os));
dest->SetValue(variables::kBuildOs, os_val, nullptr);
dest->SetValue(variables::kOs, os_val, nullptr);
+ dest->SetValue(variables::kTargetOs, os_val, nullptr);
// Host architecture.
static const char kX86[] = "x86";
@@ -246,19 +268,26 @@ void Args::SetSystemVarsLocked(Scope* dest) const {
Value arch_val(nullptr, std::string(arch));
dest->SetValue(variables::kBuildCpuArch, arch_val, nullptr);
dest->SetValue(variables::kCpuArch, arch_val, nullptr);
+ dest->SetValue(variables::kTargetCpuArch, arch_val, nullptr);
// Save the OS and architecture as build arguments that are implicitly
// declared. This is so they can be overridden in a toolchain build args
// override, and so that they will appear in the "gn args" output.
//
- // Do not declare the build* variants since these shouldn't be changed.
- //
// Mark these variables used so the build config file can override them
// without geting a warning about overwriting an unused variable.
+ declared_arguments_[variables::kBuildOs] = os_val;
declared_arguments_[variables::kOs] = os_val;
+ declared_arguments_[variables::kTargetOs] = os_val;
+ declared_arguments_[variables::kBuildCpuArch] = arch_val;
declared_arguments_[variables::kCpuArch] = arch_val;
+ declared_arguments_[variables::kTargetCpuArch] = arch_val;
+ dest->MarkUsed(variables::kBuildCpuArch);
dest->MarkUsed(variables::kCpuArch);
+ dest->MarkUsed(variables::kTargetCpuArch);
+ dest->MarkUsed(variables::kBuildOs);
dest->MarkUsed(variables::kOs);
+ dest->MarkUsed(variables::kTargetOs);
}
void Args::ApplyOverridesLocked(const Scope::KeyValueMap& values,
« no previous file with comments | « no previous file | tools/gn/command_args.cc » ('j') | tools/gn/format_test_data/030.golden » ('J')

Powered by Google App Engine
This is Rietveld 408576698