diff --git a/config/BUILDCONFIG.gn b/config/BUILDCONFIG.gn index 8811465da..643ded82c 100644 --- a/config/BUILDCONFIG.gn +++ b/config/BUILDCONFIG.gn @@ -359,7 +359,6 @@ if (is_win) { _native_compiler_configs += [ "//build/config/win:lean_and_mean", "//build/config/win:nominmax", - "//build/config/win:sdk", "//build/config/win:unicode", "//build/config/win:winver", ] @@ -375,16 +374,6 @@ if (is_posix) { ] } -if (is_linux) { - _native_compiler_configs += [ "//build/config/linux:sdk" ] -} else if (is_mac) { - _native_compiler_configs += [ "//build/config/mac:sdk" ] -} else if (is_ios) { - _native_compiler_configs += [ "//build/config/ios:sdk" ] -} else if (is_android) { - _native_compiler_configs += [ "//build/config/android:sdk" ] -} - if (is_android) { _native_compiler_configs += [ "//build/config/android:default_cygprofile_instrumentation" ] diff --git a/config/android/BUILD.gn b/config/android/BUILD.gn index 0503bef1e..618d0961e 100644 --- a/config/android/BUILD.gn +++ b/config/android/BUILD.gn @@ -195,23 +195,6 @@ config("runtime_library") { } } -config("sdk") { - if (sysroot != "") { - cflags = [ "--sysroot=" + sysroot ] - asmflags = [ "--sysroot=" + sysroot ] - ldflags = [ "--sysroot=" + sysroot ] - - # Need to get some linker flags out of the sysroot. - sysroot_ld_path = rebase_path("//build/config/linux/sysroot_ld_path.py") - ldflags += [ exec_script(sysroot_ld_path, - [ - rebase_path("//build/linux/sysroot_ld_path.sh"), - sysroot, - ], - "value") ] - } -} - config("executable_config") { cflags = [ "-fPIE" ] asmflags = [ "-fPIE" ] diff --git a/config/compiler/BUILD.gn b/config/compiler/BUILD.gn index ef8fbd418..31815c367 100644 --- a/config/compiler/BUILD.gn +++ b/config/compiler/BUILD.gn @@ -493,10 +493,20 @@ config("runtime_library") { # smaller. if (is_win) { configs += [ "//build/config/win:runtime_library" ] + } else if (is_linux) { + configs += [ "//build/config/linux:runtime_library" ] + } else if (is_ios) { + configs += [ "//build/config/ios:runtime_library" ] + } else if (is_mac) { + configs += [ "//build/config/mac:runtime_library" ] } else if (is_android) { configs += [ "//build/config/android:runtime_library" ] } + if (is_posix) { + configs += [ "//build/config/posix:runtime_library" ] + } + if (is_component_build) { defines += [ "COMPONENT_BUILD" ] } diff --git a/config/ios/BUILD.gn b/config/ios/BUILD.gn index d69f423a0..07e8a86d9 100644 --- a/config/ios/BUILD.gn +++ b/config/ios/BUILD.gn @@ -5,7 +5,11 @@ import("//build/config/sysroot.gni") import("//build/config/ios/ios_sdk.gni") -config("sdk") { +# This is included by reference in the //build/config/compiler:runtime_library +# config that is applied to all targets. It is here to separate out the logic +# that is iOS-only. Please see that target for advice on what should go in +# :runtime_library vs. :compiler. +config("runtime_library") { common_flags = [ "-isysroot", sysroot, diff --git a/config/linux/BUILD.gn b/config/linux/BUILD.gn index 45d1dd59f..e39155c61 100644 --- a/config/linux/BUILD.gn +++ b/config/linux/BUILD.gn @@ -7,21 +7,11 @@ import("//build/config/features.gni") import("//build/config/sysroot.gni") import("//build/config/ui.gni") -config("sdk") { - if (sysroot != "") { - cflags = [ "--sysroot=" + sysroot ] - ldflags = [ "--sysroot=" + sysroot ] - - # Need to get some linker flags out of the sysroot. - ldflags += [ exec_script("sysroot_ld_path.py", - [ - rebase_path("//build/linux/sysroot_ld_path.sh", - root_build_dir), - sysroot, - ], - "value") ] - } - +# This is included by reference in the //build/config/compiler:runtime_library +# config that is applied to all targets. It is here to separate out the logic +# that is Linux-only. Please see that target for advice on what should go in +# :runtime_library vs. :compiler. +config("runtime_library") { # Set here because OS_CHROMEOS cannot be autodetected in build_config.h like # OS_LINUX and the like. if (is_chromeos) { diff --git a/config/mac/BUILD.gn b/config/mac/BUILD.gn index 7653b9664..16dc52eb0 100644 --- a/config/mac/BUILD.gn +++ b/config/mac/BUILD.gn @@ -5,7 +5,11 @@ import("//build/config/sysroot.gni") import("//build/config/mac/mac_sdk.gni") -config("sdk") { +# This is included by reference in the //build/config/compiler:runtime_library +# config that is applied to all targets. It is here to separate out the logic +# that is Mac-only. Please see that target for advice on what should go in +# :runtime_library vs. :compiler. +config("runtime_library") { common_flags = [ "-isysroot", sysroot, diff --git a/config/posix/BUILD.gn b/config/posix/BUILD.gn new file mode 100644 index 000000000..6f65443d7 --- /dev/null +++ b/config/posix/BUILD.gn @@ -0,0 +1,29 @@ +# Copyright 2015 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//build/config/sysroot.gni") + +assert(is_posix) + +# This is included by reference in the //build/config/compiler:runtime_library +# config that is applied to all targets. It is here to separate out the logic +# that is Posix-only. Please see that target for advice on what should go in +# :runtime_library vs. :compiler. +config("runtime_library") { + if (!is_mac && sysroot != "") { + # Pass the sysroot to all C compiler variants, the assembler, and linker. + cflags = [ "--sysroot=" + sysroot ] + asmflags = cflags + ldflags = cflags + + # Need to get some linker flags out of the sysroot. + ldflags += [ exec_script("sysroot_ld_path.py", + [ + rebase_path("//build/linux/sysroot_ld_path.sh", + root_build_dir), + sysroot, + ], + "value") ] + } +} diff --git a/config/linux/sysroot_ld_path.py b/config/posix/sysroot_ld_path.py similarity index 100% rename from config/linux/sysroot_ld_path.py rename to config/posix/sysroot_ld_path.py diff --git a/config/win/BUILD.gn b/config/win/BUILD.gn index d1f670e9f..daa07741c 100644 --- a/config/win/BUILD.gn +++ b/config/win/BUILD.gn @@ -84,6 +84,7 @@ config("compiler") { config("runtime_library") { cflags = [] + # Defines that set up the CRT. defines = [ "__STD_C", "_CRT_RAND_S", @@ -92,6 +93,20 @@ config("runtime_library") { "_SCL_SECURE_NO_DEPRECATE", ] + # Defines that set up the Windows SDK. + defines += [ + "_ATL_NO_OPENGL", + "_WINDOWS", + "CERT_CHAIN_PARA_HAS_EXTRA_FIELDS", + "NTDDI_VERSION=0x06030000", + "PSAPI_VERSION=1", + "WIN32", + "_SECURE_ATL", + + # This is required for ATL to use XP-safe versions of its functions. + "_USING_V110_SDK71_", + ] + if (is_component_build) { # Component mode: dynamic CRT. Since the library is shared, it requires # exceptions or will give errors about things not matching, so keep @@ -120,25 +135,6 @@ config("runtime_library") { } } -# Compiler setup for the Windows SDK. Applied to all targets. -config("sdk") { - # The include path is the stuff returned by the script. - #include_dirs = msvc_config[0] TODO(brettw) make this work. - - defines = [ - "_ATL_NO_OPENGL", - "_WINDOWS", - "CERT_CHAIN_PARA_HAS_EXTRA_FIELDS", - "NTDDI_VERSION=0x06030000", - "PSAPI_VERSION=1", - "WIN32", - "_SECURE_ATL", - - # This is required for ATL to use XP-safe versions of its functions. - "_USING_V110_SDK71_", - ] -} - # Sets the default Windows build version. This is separated because some # targets need to manually override it for their compiles. config("winver") {