| 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 "base/sys_info.h" | 7 #include "base/sys_info.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "tools/gn/variables.h" | 9 #include "tools/gn/variables.h" |
| 10 | 10 |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 os = "netbsd"; | 262 os = "netbsd"; |
| 263 #else | 263 #else |
| 264 #error Unknown OS type. | 264 #error Unknown OS type. |
| 265 #endif | 265 #endif |
| 266 | 266 |
| 267 // Host architecture. | 267 // Host architecture. |
| 268 static const char kX86[] = "x86"; | 268 static const char kX86[] = "x86"; |
| 269 static const char kX64[] = "x64"; | 269 static const char kX64[] = "x64"; |
| 270 static const char kArm[] = "arm"; | 270 static const char kArm[] = "arm"; |
| 271 static const char kMips[] = "mipsel"; | 271 static const char kMips[] = "mipsel"; |
| 272 static const char kS390X[] = "s390x"; |
| 273 static const char kPPC64[] = "ppc64"; |
| 272 const char* arch = nullptr; | 274 const char* arch = nullptr; |
| 273 | 275 |
| 274 // Set the host CPU architecture based on the underlying OS, not | 276 // Set the host CPU architecture based on the underlying OS, not |
| 275 // whatever the current bit-tedness of the GN binary is. | 277 // whatever the current bit-tedness of the GN binary is. |
| 276 std::string os_arch = base::SysInfo::OperatingSystemArchitecture(); | 278 std::string os_arch = base::SysInfo::OperatingSystemArchitecture(); |
| 277 if (os_arch == "x86") | 279 if (os_arch == "x86") |
| 278 arch = kX86; | 280 arch = kX86; |
| 279 else if (os_arch == "x86_64") | 281 else if (os_arch == "x86_64") |
| 280 arch = kX64; | 282 arch = kX64; |
| 281 else if (os_arch.substr(0, 3) == "arm") | 283 else if (os_arch.substr(0, 3) == "arm") |
| 282 arch = kArm; | 284 arch = kArm; |
| 283 else if (os_arch == "mips") | 285 else if (os_arch == "mips") |
| 284 arch = kMips; | 286 arch = kMips; |
| 287 else if (os_arch == "s390x") |
| 288 arch = kS390X; |
| 289 else if (os_arch == "mips") |
| 290 arch = kPPC64; |
| 285 else | 291 else |
| 286 CHECK(false) << "OS architecture not handled."; | 292 CHECK(false) << "OS architecture not handled. (" << os_arch << ")"; |
| 287 | 293 |
| 288 // Save the OS and architecture as build arguments that are implicitly | 294 // Save the OS and architecture as build arguments that are implicitly |
| 289 // declared. This is so they can be overridden in a toolchain build args | 295 // declared. This is so they can be overridden in a toolchain build args |
| 290 // override, and so that they will appear in the "gn args" output. | 296 // override, and so that they will appear in the "gn args" output. |
| 291 Value empty_string(nullptr, std::string()); | 297 Value empty_string(nullptr, std::string()); |
| 292 | 298 |
| 293 Value os_val(nullptr, std::string(os)); | 299 Value os_val(nullptr, std::string(os)); |
| 294 dest->SetValue(variables::kHostOs, os_val, nullptr); | 300 dest->SetValue(variables::kHostOs, os_val, nullptr); |
| 295 dest->SetValue(variables::kTargetOs, empty_string, nullptr); | 301 dest->SetValue(variables::kTargetOs, empty_string, nullptr); |
| 296 dest->SetValue(variables::kCurrentOs, empty_string, nullptr); | 302 dest->SetValue(variables::kCurrentOs, empty_string, nullptr); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 Scope* scope) const { | 354 Scope* scope) const { |
| 349 lock_.AssertAcquired(); | 355 lock_.AssertAcquired(); |
| 350 return declared_arguments_per_toolchain_[scope->settings()]; | 356 return declared_arguments_per_toolchain_[scope->settings()]; |
| 351 } | 357 } |
| 352 | 358 |
| 353 Scope::KeyValueMap& Args::OverridesForToolchainLocked( | 359 Scope::KeyValueMap& Args::OverridesForToolchainLocked( |
| 354 Scope* scope) const { | 360 Scope* scope) const { |
| 355 lock_.AssertAcquired(); | 361 lock_.AssertAcquired(); |
| 356 return toolchain_overrides_[scope->settings()]; | 362 return toolchain_overrides_[scope->settings()]; |
| 357 } | 363 } |
| OLD | NEW |