| OLD | NEW | 
|    1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |    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 |    2 // Use of this source code is governed by a BSD-style license that can be | 
|    3 // found in the LICENSE file. |    3 // found in the LICENSE file. | 
|    4  |    4  | 
|    5 #include "tools/gn/args.h" |    5 #include "tools/gn/args.h" | 
|    6  |    6  | 
|    7 #include "build/build_config.h" |    7 #include "build/build_config.h" | 
|    8 #include "tools/gn/variables.h" |    8 #include "tools/gn/variables.h" | 
|    9  |    9  | 
|   10 #if defined(OS_WIN) |   10 #if defined(OS_WIN) | 
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  172 #elif defined(OS_LINUX) |  172 #elif defined(OS_LINUX) | 
|  173   os = "linux"; |  173   os = "linux"; | 
|  174 #else |  174 #else | 
|  175   #error Unknown OS type. |  175   #error Unknown OS type. | 
|  176 #endif |  176 #endif | 
|  177   Value os_val(NULL, std::string(os)); |  177   Value os_val(NULL, std::string(os)); | 
|  178   dest->SetValue(variables::kBuildOs, os_val, NULL); |  178   dest->SetValue(variables::kBuildOs, os_val, NULL); | 
|  179   dest->SetValue(variables::kOs, os_val, NULL); |  179   dest->SetValue(variables::kOs, os_val, NULL); | 
|  180  |  180  | 
|  181   // Host architecture. |  181   // Host architecture. | 
|  182   static const char kIa32[] = "ia32"; |  182   static const char kX86[] = "x86"; | 
|  183   static const char kIa64[] = "ia64"; |  183   static const char kX64[] = "x64"; | 
|  184   const char* arch = NULL; |  184   const char* arch = NULL; | 
|  185 #if defined(OS_WIN) |  185 #if defined(OS_WIN) | 
|  186   // ...on Windows, set the CPU architecture based on the underlying OS, not |  186   // ...on Windows, set the CPU architecture based on the underlying OS, not | 
|  187   // whatever the current bit-tedness of the GN binary is. |  187   // whatever the current bit-tedness of the GN binary is. | 
|  188   const base::win::OSInfo* os_info = base::win::OSInfo::GetInstance(); |  188   const base::win::OSInfo* os_info = base::win::OSInfo::GetInstance(); | 
|  189   switch (os_info->architecture()) { |  189   switch (os_info->architecture()) { | 
|  190     case base::win::OSInfo::X86_ARCHITECTURE: |  190     case base::win::OSInfo::X86_ARCHITECTURE: | 
|  191       arch = kIa32; |  191       arch = kX86; | 
|  192       break; |  192       break; | 
|  193     case base::win::OSInfo::X64_ARCHITECTURE: |  193     case base::win::OSInfo::X64_ARCHITECTURE: | 
|  194       arch = kIa64; |  194       arch = kX64; | 
|  195       break; |  195       break; | 
|  196     default: |  196     default: | 
|  197       CHECK(false) << "Windows architecture not handled."; |  197       CHECK(false) << "Windows architecture not handled."; | 
|  198       break; |  198       break; | 
|  199   } |  199   } | 
|  200 #else |  200 #else | 
|  201   // ...on all other platforms, just use the bit-tedness of the current |  201   // ...on all other platforms, just use the bit-tedness of the current | 
|  202   // process. |  202   // process. | 
|  203   #if defined(ARCH_CPU_X86_64) |  203   #if defined(ARCH_CPU_X86_64) | 
|  204     arch = kIa64; |  204     arch = kX64; | 
|  205   #elif defined(ARCH_CPU_X86) |  205   #elif defined(ARCH_CPU_X86) | 
|  206     arch = kIa32; |  206     arch = kX86; | 
|  207   #elif defined(ARCH_CPU_ARMEL) |  207   #elif defined(ARCH_CPU_ARMEL) | 
|  208     static const char kArm[] = "arm"; |  208     static const char kArm[] = "arm"; | 
|  209     arch = kArm; |  209     arch = kArm; | 
|  210   #else |  210   #else | 
|  211     #error Unknown architecture. |  211     #error Unknown architecture. | 
|  212   #endif |  212   #endif | 
|  213 #endif |  213 #endif | 
|  214   // Avoid unused var warning. |  214   // Avoid unused var warning. | 
|  215   (void)kIa32; |  215   (void)kX86; | 
|  216   (void)kIa64; |  216   (void)kX64; | 
|  217  |  217  | 
|  218   Value arch_val(NULL, std::string(arch)); |  218   Value arch_val(NULL, std::string(arch)); | 
|  219   dest->SetValue(variables::kBuildCpuArch, arch_val, NULL); |  219   dest->SetValue(variables::kBuildCpuArch, arch_val, NULL); | 
|  220   dest->SetValue(variables::kCpuArch, arch_val, NULL); |  220   dest->SetValue(variables::kCpuArch, arch_val, NULL); | 
|  221  |  221  | 
|  222   // Save the OS and architecture as build arguments that are implicitly |  222   // Save the OS and architecture as build arguments that are implicitly | 
|  223   // declared. This is so they can be overridden in a toolchain build args |  223   // declared. This is so they can be overridden in a toolchain build args | 
|  224   // override, and so that they will appear in the "gn args" output. |  224   // override, and so that they will appear in the "gn args" output. | 
|  225   // |  225   // | 
|  226   // Do not declare the build* variants since these shouldn't be changed. |  226   // Do not declare the build* variants since these shouldn't be changed. | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
|  240        i != values.end(); ++i) |  240        i != values.end(); ++i) | 
|  241     scope->SetValue(i->first, i->second, i->second.origin()); |  241     scope->SetValue(i->first, i->second, i->second.origin()); | 
|  242 } |  242 } | 
|  243  |  243  | 
|  244 void Args::SaveOverrideRecord(const Scope::KeyValueMap& values) const { |  244 void Args::SaveOverrideRecord(const Scope::KeyValueMap& values) const { | 
|  245   base::AutoLock lock(lock_); |  245   base::AutoLock lock(lock_); | 
|  246   for (Scope::KeyValueMap::const_iterator i = values.begin(); |  246   for (Scope::KeyValueMap::const_iterator i = values.begin(); | 
|  247        i != values.end(); ++i) |  247        i != values.end(); ++i) | 
|  248     all_overrides_[i->first] = i->second; |  248     all_overrides_[i->first] = i->second; | 
|  249 } |  249 } | 
| OLD | NEW |