0

[apple] Add a is_apple gn variable and use it

As https://crrev.com/c/2299189 adds `OS_MAC` & `OS_APPLE`, add a gn
variable `is_apple` that is true when `OS_APPLE` is defined. This
allow an easy mapping between gn variables and cpp macros.

Convert all usages of `is_ios || is_mac` or `is_mac || is_ios` to
use the new variable instead.

Bug: 1105907
Change-Id: I4cef55496a0ccf0a6162e60409ff3b7996f633dd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2315695
Commit-Queue: Nico Weber <thakis@chromium.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#791803}
This commit is contained in:
Sylvain Defresne
2020-07-27 14:16:50 +00:00
committed by Commit Bot
parent ffc377fd41
commit fafffe8843
40 changed files with 67 additions and 66 deletions
base
BUILD.gn
allocator
third_party
libevent
build
components
crash
core
common
handoff
policy
core
common
google_apis
media
net
remoting
host
resources
rlz/buildflags
skia
testing/gtest
third_party
abseil-cpp
absl
time
internal
grpc
libxml
mozilla
ocmock
openh264
sqlite
usrsctp
zlib
tools/grit
ui
base
clipboard
gfx
resources

@ -1333,7 +1333,7 @@ jumbo_component("base") {
if (use_allocator == "none") {
sources += [ "allocator/allocator_shim_default_dispatch_to_linker_wrapped_symbols.cc" ]
}
} else if (is_mac || is_ios) {
} else if (is_apple) {
sources += [
"allocator/allocator_shim_default_dispatch_to_mac_zoned_malloc.cc",
"allocator/allocator_shim_default_dispatch_to_mac_zoned_malloc.h",
@ -1352,7 +1352,7 @@ jumbo_component("base") {
# Allow more direct string conversions on platforms with native utf8
# strings
if (is_mac || is_ios || is_chromeos || is_chromecast || is_fuchsia) {
if (is_apple || is_chromeos || is_chromecast || is_fuchsia) {
defines += [ "SYSTEM_NATIVE_UTF8" ]
}
@ -1882,7 +1882,7 @@ jumbo_component("base") {
}
# Mac or iOS.
if (is_mac || is_ios) {
if (is_apple) {
sources -= [
"native_library_posix.cc",
"profiler/module_cache_posix.cc",
@ -2576,7 +2576,7 @@ bundle_data("base_unittests_bundle_data") {
"{{source_root_relative_dir}}/{{source_file_part}}" ]
}
if (is_ios || is_mac) {
if (is_apple) {
source_set("base_unittests_arc") {
testonly = true
sources = [ "mac/bind_objc_block_unittest_arc.mm" ]
@ -2937,7 +2937,7 @@ test("base_unittests") {
"//base/test:test_shared_library",
]
if (is_ios || is_mac) {
if (is_apple) {
deps += [ ":base_unittests_arc" ]
}
@ -3053,7 +3053,7 @@ test("base_unittests") {
# Allow more direct string conversions on platforms with native utf8
# strings
if (is_mac || is_ios || is_chromeos || is_chromecast || is_fuchsia) {
if (is_apple || is_chromeos || is_chromecast || is_fuchsia) {
defines += [ "SYSTEM_NATIVE_UTF8" ]
}

@ -6,8 +6,8 @@ import("//build/config/chromecast_build.gni")
import("//build/config/sanitizers/sanitizers.gni")
# Temporarily disable tcmalloc on arm64 linux to get rid of compilation errors.
if (is_android || is_mac || is_ios || is_asan || is_lsan || is_tsan ||
is_msan || is_win || is_fuchsia || (is_linux && target_cpu == "arm64") ||
if (is_android || is_apple || is_asan || is_lsan || is_tsan || is_msan ||
is_win || is_fuchsia || (is_linux && target_cpu == "arm64") ||
(is_cast_audio_only && target_cpu == "arm")) {
_default_allocator = "none"
} else {
@ -17,7 +17,7 @@ if (is_android || is_mac || is_ios || is_asan || is_lsan || is_tsan ||
# The debug CRT on Windows has some debug features that are incompatible with
# the shim. NaCl in particular does seem to link some binaries statically
# against the debug CRT with "is_nacl=false".
if ((is_linux || is_android || is_mac || is_ios ||
if ((is_linux || is_android || is_apple ||
(is_win && !is_component_build && !is_debug)) && !is_asan && !is_hwasan &&
!is_lsan && !is_tsan && !is_msan) {
_default_use_allocator_shim = true
@ -44,7 +44,7 @@ assert(!is_mac || use_allocator == "none", "Tcmalloc doesn't work on macOS.")
assert(!is_ios || use_allocator == "none", "Tcmalloc doesn't work on iOS.")
assert(
!use_allocator_shim || is_linux || is_android || is_win || is_mac || is_ios,
!use_allocator_shim || is_linux || is_android || is_win || is_apple,
"use_allocator_shim works only on Android, iOS, Linux, macOS, and Windows.")
if (is_win && use_allocator_shim) {

@ -36,7 +36,7 @@ static_library("libevent") {
defines = [ "HAVE_CONFIG_H" ]
if (is_mac || is_ios) {
if (is_apple) {
sources += [
"kqueue.c",
"mac/config.h",

@ -293,6 +293,7 @@ is_mac = current_os == "mac"
is_nacl = current_os == "nacl"
is_win = current_os == "win" || current_os == "winuwp"
is_apple = is_ios || is_mac
is_posix = !is_win && !is_fuchsia
# =============================================================================

@ -15,7 +15,7 @@ declare_args() {
# symbols are not exported.
# TODO(thomasanderson): Set this to true by default once rL352899 is available
# in MacOS's lldb.
libcxx_abi_unstable = !((is_mac || is_ios) && is_debug && is_component_build)
libcxx_abi_unstable = !(is_apple && is_debug && is_component_build)
}
# TODO(xiaohuic): https://crbug/917533 Crashes on internal ChromeOS build.

@ -294,7 +294,7 @@ config("compiler") {
if (fatal_linker_warnings && !is_mac && !is_ios && current_os != "aix") {
ldflags += [ "-Wl,--fatal-warnings" ]
}
if (fatal_linker_warnings && (is_mac || is_ios)) {
if (fatal_linker_warnings && is_apple) {
ldflags += [ "-Wl,-fatal_warnings" ]
}
} else {
@ -313,7 +313,7 @@ config("compiler") {
# Non-Mac Posix and Fuchsia compiler flags setup.
# -----------------------------------
if ((is_posix && !(is_mac || is_ios)) || is_fuchsia) {
if ((is_posix && !is_apple) || is_fuchsia) {
if (enable_profiling) {
if (!is_debug) {
cflags += [ "-g" ]
@ -725,7 +725,7 @@ config("compiler_cpu_abi") {
ldflags = []
defines = []
if ((is_posix && !(is_mac || is_ios)) || is_fuchsia) {
if ((is_posix && !is_apple) || is_fuchsia) {
# CPU architecture. We may or may not be doing a cross compile now, so for
# simplicity we always explicitly set the architecture.
if (current_cpu == "x64") {
@ -1180,7 +1180,7 @@ config("compiler_arm_fpu") {
config("compiler_arm_thumb") {
if (current_cpu == "arm" && arm_use_thumb && is_posix &&
!(is_mac || is_ios || is_nacl)) {
!(is_apple || is_nacl)) {
cflags = [ "-mthumb" ]
}
}
@ -1412,7 +1412,7 @@ config("default_warnings") {
]
}
} else {
if ((is_mac || is_ios) && !is_nacl) {
if (is_apple && !is_nacl) {
# When compiling Objective-C, warns if a method is used whose
# availability is newer than the deployment target.
cflags += [ "-Wunguarded-availability" ]
@ -1925,7 +1925,7 @@ if (is_win) {
}
}
if (is_mac || is_ios) {
if (is_apple) {
if (symbol_level == 2) {
# Mac dead code stripping requires symbols.
common_optimize_on_ldflags += [ "-Wl,-dead_strip" ]
@ -2439,7 +2439,7 @@ config("strip_debug") {
ldflags += [ "-Wl,--strip-debug" ]
}
if (is_ios || is_mac) {
if (is_apple) {
# On Mac and iOS, this enables support for ARC (automatic ref-counting).
# See http://clang.llvm.org/docs/AutomaticReferenceCounting.html.
config("enable_arc") {

@ -126,7 +126,7 @@ if (is_chromeos) {
# 32-bit builds (https://bugs.llvm.org/show_bug.cgi?id=18505) so disable them
# there to avoid the unnecessary overhead.
enable_frame_pointers = current_cpu != "arm"
} else if (is_mac || is_ios || is_linux) {
} else if (is_apple || is_linux) {
enable_frame_pointers = true
} else if (is_win) {
# 64-bit Windows ABI doesn't support frame pointers.

@ -89,7 +89,7 @@ if ((is_mac || is_win || (is_ios && !use_xcode_clang)) && is_asan) {
}
}
if (is_mac || is_ios) {
if (is_apple) {
bundle_data("asan_runtime_bundle_data") {
sources = get_target_outputs(":copy_asan_runtime")
outputs = [ "{{bundle_executable_dir}}/{{source_file_part}}" ]
@ -99,7 +99,7 @@ if ((is_mac || is_win || (is_ios && !use_xcode_clang)) && is_asan) {
}
config("sanitizer_options_link_helper") {
if (is_mac || is_ios) {
if (is_apple) {
ldflags = [ "-Wl,-U,_sanitizer_options_link_helper" ]
} else if (!is_win) {
ldflags = [ "-Wl,-u_sanitizer_options_link_helper" ]

@ -16,7 +16,7 @@ if (current_cpu == "x64") {
x64_arch = ""
}
if ((is_posix && !(is_mac || is_ios)) || is_fuchsia) {
if ((is_posix && !is_apple) || is_fuchsia) {
if (x64_arch == "") {
x64_arch = "x86-64"
}

@ -62,7 +62,7 @@ import("//testing/test.gni")
declare_args() {
# TODO(crbug.com/105388): make sure no-compile test is not flaky.
enable_nocompile_tests =
(is_linux || is_mac || is_ios) && is_clang && host_cpu == target_cpu
(is_linux || is_apple) && is_clang && host_cpu == target_cpu
}
if (enable_nocompile_tests) {

@ -54,7 +54,7 @@ assert(!use_xcode_clang || target_os == "ios",
"Using Xcode's clang is only supported in iOS builds")
# Extension for shared library files (including leading dot).
if (is_mac || is_ios) {
if (is_apple) {
shlib_extension = ".dylib"
} else if (is_android && is_component_build) {
# By appending .cr, we prevent name collisions with libraries already

@ -16,7 +16,7 @@ group("common") {
":crash_key_utils",
]
if (is_mac || is_ios) {
if (is_apple) {
public_deps += [ ":zombies" ]
}
@ -129,7 +129,7 @@ static_library("crash_key_utils") {
]
}
if (is_mac || is_ios) {
if (is_apple) {
component("zombies") {
visibility = [ ":common" ]
@ -176,7 +176,7 @@ source_set("unit_tests") {
"//testing/gtest",
]
if (is_mac || is_ios) {
if (is_apple) {
sources += [ "objc_zombie_unittest.mm" ]
}

@ -3,7 +3,7 @@
# found in the LICENSE file.
source_set("handoff") {
if (is_mac || is_ios) {
if (is_apple) {
sources = [
"handoff_manager.h",
"handoff_manager.mm",

@ -257,7 +257,7 @@ jumbo_source_set("internal") {
"cloud/user_cloud_policy_store.h",
]
}
if (is_ios || is_mac) {
if (is_apple) {
sources += [
"mac_util.cc",
"mac_util.h",
@ -451,7 +451,7 @@ source_set("unit_tests") {
"config_dir_policy_loader_unittest.cc",
]
}
if (is_mac || is_ios) {
if (is_apple) {
sources += [ "mac_util_unittest.cc" ]
if (is_mac) {

@ -153,7 +153,7 @@ template("google_apis_tmpl") {
deps += invoker.deps
}
if (is_mac || is_ios) {
if (is_apple) {
set_sources_assignment_filter([])
sources += [
"google_api_keys_mac.h",
@ -252,7 +252,7 @@ test("google_apis_unittests") {
deps += [ "//google_apis/drive:drive_unittests" ]
}
if (is_mac || is_ios) {
if (is_apple) {
set_sources_assignment_filter([])
sources += [ "google_api_keys_mac_unittest.mm" ]
set_sources_assignment_filter(sources_assignment_filter)

@ -118,7 +118,7 @@ component("media") {
]
# This must be included here since it actually depends on //media/base.
if (is_mac || is_ios) {
if (is_apple) {
public_deps += [ "//media/base/mac" ]
}
}

@ -24,7 +24,7 @@ jumbo_source_set("base") {
# TODO(dalecurtis): Replace this with empty targets on non-mac so
# we can just include //media/base/mac in media_subcomponent_deps.
if (is_ios || is_mac) {
if (is_apple) {
visibility += [ "//media/base/mac" ]
}
@ -605,7 +605,7 @@ source_set("unit_tests") {
"//ui/gfx",
]
if (is_mac || is_ios) {
if (is_apple) {
deps += [ "//media/base/mac:unit_tests" ]
}

@ -4,7 +4,7 @@
import("//build/config/jumbo.gni")
assert(is_mac || is_ios)
assert(is_apple)
jumbo_source_set("mac") {
# Note: This source_set is depended on only by //media. In the component

@ -165,7 +165,7 @@ jumbo_source_set("sender") {
]
# iOS and OS X encoders
if (is_ios || is_mac) {
if (is_apple) {
sources += [
"sender/h264_vt_encoder.cc",
"sender/h264_vt_encoder.h",
@ -355,7 +355,7 @@ test("cast_unittests") {
]
}
if (is_ios || is_mac) {
if (is_apple) {
sources += [ "sender/h264_vt_encoder_unittest.cc" ]
deps += [ "//third_party/ffmpeg" ]

@ -1282,7 +1282,7 @@ component("net") {
]
}
if (is_ios || is_mac) {
if (is_apple) {
sources += [
"base/mac/url_conversions.h",
"base/mac/url_conversions.mm",
@ -4604,7 +4604,7 @@ test("net_unittests") {
]
}
if (is_mac || is_ios) {
if (is_apple) {
sources += [ "base/mac/url_conversions_unittest.mm" ]
}

@ -23,7 +23,7 @@ declare_args() {
disable_brotli_filter = false
# Multicast DNS.
enable_mdns = is_win || is_linux || is_fuchsia || is_mac || is_ios
enable_mdns = is_win || is_linux || is_fuchsia || is_apple
# Reporting not used on iOS.
enable_reporting = !is_ios

@ -50,7 +50,7 @@ source_set("common") {
deps += [ "//remoting/host/mac:permission_checking" ]
}
if (is_mac || is_ios) {
if (is_apple) {
deps += [ "//remoting/host/mac:constants" ]
}

@ -98,7 +98,7 @@ action("copy_locales") {
[ "$root_gen_dir/remoting/resources/{{source_name_part}}.pak" ])
# Likewise, process the outputs in the same way as the inputs.
if (is_mac || is_ios) {
if (is_apple) {
# On mac, use underscores instead of hyphens and put the files in a
# different place.
outputs = process_file_template(

@ -6,6 +6,6 @@ import("//build/config/chrome_build.gni")
# Whether we are using the rlz library or not. Platforms like Android send
# rlz codes for searches but do not use the library.
enable_rlz_support = is_win || is_mac || is_ios || is_chromeos
enable_rlz_support = is_win || is_apple || is_chromeos
enable_rlz = is_chrome_branded && enable_rlz_support

@ -437,7 +437,7 @@ component("skia") {
]
}
if (is_mac || is_ios) {
if (is_apple) {
set_sources_assignment_filter([])
sources += [
"//third_party/skia/include/ports/SkFontMgr_mac_ct.h",
@ -847,7 +847,7 @@ if (is_fuchsia) {
outputs = [ "$root_out_dir/test_fonts/{{source_file_part}}" ]
}
}
if (is_mac || is_ios) {
if (is_apple) {
bundle_data("test_fonts_bundle_data") {
public_deps = [ "//third_party/test_fonts" ]
@ -864,7 +864,7 @@ group("test_fonts_resources") {
deps = []
data_deps = []
if (is_mac || is_ios) {
if (is_apple) {
deps += [ ":test_fonts_bundle_data" ]
data_deps += [ ":test_fonts_bundle_data" ]
} else {

@ -55,7 +55,7 @@ static_library("gtest") {
sources += [ "../platform_test.h" ]
}
if ((is_mac || is_ios) && gtest_include_objc_support) {
if (is_apple && gtest_include_objc_support) {
if (is_ios) {
set_sources_assignment_filter([])
}

@ -36,7 +36,7 @@ absl_source_set("time_zone") {
"include/cctz/time_zone.h",
"include/cctz/zone_info_source.h",
]
if (is_mac || is_ios) {
if (is_apple) {
frameworks = [ "Foundation.framework" ]
}
deps = [

@ -25,7 +25,7 @@ config("grpc_internal_config") {
config("nanopb_config") {
include_dirs = [ "src/third_party/nanopb" ]
defines = [ "PB_FIELD_32BIT=1" ]
if (is_mac || is_ios) {
if (is_apple) {
defines += [ "PB_NO_PACKED_STRUCTS=1" ]
}
}

@ -6,7 +6,7 @@
# headers. These were generated by running the configure script offline.
if (is_linux || is_android || is_nacl || is_fuchsia) {
os_include = "linux"
} else if (is_mac || is_ios) {
} else if (is_apple) {
os_include = "mac"
} else if (is_win) {
os_include = "win32"
@ -300,7 +300,7 @@ static_library("libxml") {
public_deps = [ "//third_party/icu:icuuc" ]
deps = [ "//third_party/zlib" ]
if (is_mac || is_ios || is_android || is_fuchsia) {
if (is_apple || is_android || is_fuchsia) {
# http://www.xmlsoft.org/threads.html says that this is required when using
# libxml from several threads, which can possibly happen in chrome. On
# linux, this is picked up by transitivity from pkg-config output from

@ -22,7 +22,7 @@ component("mozilla") {
"//url",
]
if (is_component_build && (is_mac || is_ios)) {
if (is_component_build && is_apple) {
# Needed to link to Obj-C static libraries.
ldflags = [ "-Wl,-ObjC" ]
}

@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
assert(is_mac || is_ios)
assert(is_apple)
config("ocmock_config") {
include_dirs = [ "//third_party/ocmock" ]

@ -53,7 +53,7 @@ use_assembler = (is_win || is_linux) &&
if (use_assembler) {
asm_defines = []
if (!is_component_build) {
if (is_mac || is_ios) {
if (is_apple) {
asm_defines += [ "WELS_PRIVATE_EXTERN=private_extern" ]
} else if (is_linux || is_android || is_fuchsia) {
asm_defines += [ "WELS_PRIVATE_EXTERN=hidden" ]

@ -226,7 +226,7 @@ component("chromium_sqlite3") {
":sqlite_warnings",
]
if (is_mac || is_ios) {
if (is_apple) {
frameworks = [ "CoreFoundation.framework" ]
if (!is_ios) {
frameworks += [ "CoreServices.framework" ]
@ -305,7 +305,7 @@ component("dev_sqlite3") {
":sqlite_warnings",
]
if (is_mac || is_ios) {
if (is_apple) {
frameworks = [ "CoreFoundation.framework" ]
if (!is_ios) {
frameworks += [ "CoreServices.framework" ]

@ -126,7 +126,7 @@ static_library("usrsctp") {
"__Userspace_os_Linux",
"_GNU_SOURCE",
]
} else if (is_mac || is_ios) {
} else if (is_apple) {
defines += [
"HAVE_SA_LEN",
"HAVE_SCONN_LEN",

@ -358,7 +358,7 @@ static_library("minizip") {
]
}
if (is_mac || is_ios || is_android || is_nacl) {
if (is_apple || is_android || is_nacl) {
# Mac, Android and the BSDs don't have fopen64, ftello64, or fseeko64. We
# use fopen, ftell, and fseek instead on these systems.
defines = [ "USE_FILE32API" ]

@ -112,7 +112,7 @@ if (is_mac || is_win || is_linux || is_ios) {
}
# Mac and iOS want Title Case strings.
use_titlecase_in_grd_files = is_mac || is_ios
use_titlecase_in_grd_files = is_apple
if (use_titlecase_in_grd_files) {
grit_defines += [
"-D",

@ -32,7 +32,7 @@ jumbo_component("clipboard_types") {
sources += [ "clipboard_format_type_mac.mm" ]
}
if (is_mac || is_ios) {
if (is_apple) {
sources += [ "clipboard_constants_mac.mm" ]
}
@ -51,7 +51,7 @@ jumbo_component("clipboard_types") {
deps = [ "//base" ]
frameworks = []
if (is_mac || is_ios) {
if (is_apple) {
frameworks += [ "Foundation.framework" ]
}
if (is_mac) {

@ -793,7 +793,7 @@ test("gfx_unittests") {
data_deps = [ "//ui/resources:ui_test_pak_data" ]
if (is_mac || is_ios) {
if (is_apple) {
deps += [ "//ui/resources:ui_test_pak_bundle_data" ]
}

@ -19,7 +19,7 @@ jumbo_component("range") {
"range_f.h",
]
if (is_ios || is_mac) {
if (is_apple) {
sources += [ "range_mac.mm" ]
}

@ -66,7 +66,7 @@ if (!is_mac) {
# On iOS and Mac the string resources need to go into a locale subfolder, which
# introduces an extra dependency.
if (is_ios || is_mac) {
if (is_apple) {
group("ui_test_pak") {
public_deps = [
":repack_ui_test_mac_locale_pack",