| 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/string_utils.h" | 9 #include "tools/gn/string_utils.h" |
| 10 #include "tools/gn/variables.h" | 10 #include "tools/gn/variables.h" |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 #if defined(OS_WIN) | 295 #if defined(OS_WIN) |
| 296 os = "win"; | 296 os = "win"; |
| 297 #elif defined(OS_MACOSX) | 297 #elif defined(OS_MACOSX) |
| 298 os = "mac"; | 298 os = "mac"; |
| 299 #elif defined(OS_LINUX) | 299 #elif defined(OS_LINUX) |
| 300 os = "linux"; | 300 os = "linux"; |
| 301 #elif defined(OS_ANDROID) | 301 #elif defined(OS_ANDROID) |
| 302 os = "android"; | 302 os = "android"; |
| 303 #elif defined(OS_NETBSD) | 303 #elif defined(OS_NETBSD) |
| 304 os = "netbsd"; | 304 os = "netbsd"; |
| 305 #elif defined(OS_AIX) |
| 306 os = "aix"; |
| 305 #else | 307 #else |
| 306 #error Unknown OS type. | 308 #error Unknown OS type. |
| 307 #endif | 309 #endif |
| 308 | 310 |
| 309 // Host architecture. | 311 // Host architecture. |
| 310 static const char kX86[] = "x86"; | 312 static const char kX86[] = "x86"; |
| 311 static const char kX64[] = "x64"; | 313 static const char kX64[] = "x64"; |
| 312 static const char kArm[] = "arm"; | 314 static const char kArm[] = "arm"; |
| 313 static const char kArm64[] = "arm64"; | 315 static const char kArm64[] = "arm64"; |
| 314 static const char kMips[] = "mipsel"; | 316 static const char kMips[] = "mipsel"; |
| 315 static const char kS390X[] = "s390x"; | 317 static const char kS390X[] = "s390x"; |
| 316 static const char kPPC64[] = "ppc64"; | 318 static const char kPPC64[] = "ppc64"; |
| 317 const char* arch = nullptr; | 319 const char* arch = nullptr; |
| 318 | 320 |
| 319 // Set the host CPU architecture based on the underlying OS, not | 321 // Set the host CPU architecture based on the underlying OS, not |
| 320 // whatever the current bit-tedness of the GN binary is. | 322 // whatever the current bit-tedness of the GN binary is. |
| 321 std::string os_arch = base::SysInfo::OperatingSystemArchitecture(); | 323 std::string os_arch = base::SysInfo::OperatingSystemArchitecture(); |
| 322 if (os_arch == "x86") | 324 if (os_arch == "x86") |
| 323 arch = kX86; | 325 arch = kX86; |
| 324 else if (os_arch == "x86_64") | 326 else if (os_arch == "x86_64") |
| 325 arch = kX64; | 327 arch = kX64; |
| 326 else if (os_arch.substr(0, 3) == "arm") | 328 else if (os_arch.substr(0, 3) == "arm") |
| 327 arch = kArm; | 329 arch = kArm; |
| 328 else if (os_arch == "aarch64") | 330 else if (os_arch == "aarch64") |
| 329 arch = kArm64; | 331 arch = kArm64; |
| 330 else if (os_arch == "mips") | 332 else if (os_arch == "mips") |
| 331 arch = kMips; | 333 arch = kMips; |
| 332 else if (os_arch == "s390x") | 334 else if (os_arch == "s390x") |
| 333 arch = kS390X; | 335 arch = kS390X; |
| 334 else if (os_arch == "mips") | 336 else if (os_arch == "ppc64" || os_arch == "ppc64le") |
| 337 // We handle the endianness inside //build/config/host_byteorder.gni. |
| 338 // This allows us to use the same toolchain as ppc64 BE |
| 339 // and specific flags are included using the host_byteorder logic. |
| 335 arch = kPPC64; | 340 arch = kPPC64; |
| 336 else | 341 else |
| 337 CHECK(false) << "OS architecture not handled. (" << os_arch << ")"; | 342 CHECK(false) << "OS architecture not handled. (" << os_arch << ")"; |
| 338 | 343 |
| 339 // Save the OS and architecture as build arguments that are implicitly | 344 // Save the OS and architecture as build arguments that are implicitly |
| 340 // declared. This is so they can be overridden in a toolchain build args | 345 // declared. This is so they can be overridden in a toolchain build args |
| 341 // override, and so that they will appear in the "gn args" output. | 346 // override, and so that they will appear in the "gn args" output. |
| 342 Value empty_string(nullptr, std::string()); | 347 Value empty_string(nullptr, std::string()); |
| 343 | 348 |
| 344 Value os_val(nullptr, std::string(os)); | 349 Value os_val(nullptr, std::string(os)); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 Scope* scope) const { | 404 Scope* scope) const { |
| 400 lock_.AssertAcquired(); | 405 lock_.AssertAcquired(); |
| 401 return declared_arguments_per_toolchain_[scope->settings()]; | 406 return declared_arguments_per_toolchain_[scope->settings()]; |
| 402 } | 407 } |
| 403 | 408 |
| 404 Scope::KeyValueMap& Args::OverridesForToolchainLocked( | 409 Scope::KeyValueMap& Args::OverridesForToolchainLocked( |
| 405 Scope* scope) const { | 410 Scope* scope) const { |
| 406 lock_.AssertAcquired(); | 411 lock_.AssertAcquired(); |
| 407 return toolchain_overrides_[scope->settings()]; | 412 return toolchain_overrides_[scope->settings()]; |
| 408 } | 413 } |
| OLD | NEW |