Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/third_party/chromium/build/config/ios/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 8 kB image not shown  

Quelle  BUILD.gn   Sprache: unbekannt

 
# Copyright 2014 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("//chromium/build/config/ios/ios_sdk.gni")
import("//chromium/build/toolchain/goma.gni")
import("//chromium/build/toolchain/toolchain.gni")
import("//build_overrides/build.gni")

declare_args() {
  # Enabling this option makes clang compile to an intermediate
  # representation ("bitcode"), and not to native code. This is preferred
  # when including WebRTC in the apps that will be sent to Apple's App Store
  # and mandatory for the apps that run on watchOS or tvOS.
  # The option only works when building with Xcode (use_xcode_clang = true).
  # Mimicking how Xcode handles it, the production builds (is_debug = false)
  # get real bitcode sections added, while the debug builds (is_debug = true)
  # only get bitcode-section "markers" added in them.
  enable_ios_bitcode = false
}

# This is included by reference in the //build/config/compiler config that
# is applied to all targets. It is here to separate out the logic.
config("compiler") {
  # These flags are shared between the C compiler and linker.
  common_flags = []

  # CPU architecture.
  if (target_cpu == "x64") {
    triplet_cpu = "x86_64"
  } else if (target_cpu == "x86") {
    triplet_cpu = "i386"
  } else if (target_cpu == "arm" || target_cpu == "armv7") {
    triplet_cpu = "armv7"
  } else if (target_cpu == "arm64") {
    triplet_cpu = "arm64"
  } else {
    assert(false, "unsupported cpu: $target_cpu")
  }

  # Environment.
  if (target_environment == "simulator") {
    triplet_environment = "-simulator"
  } else if (target_environment == "device") {
    triplet_environment = ""
  } else if (target_environment == "catalyst") {
    triplet_environment = "-macabi"
  } else {
    assert(false, "unsupported environment: $target_environment")
  }

  # OS.
  triplet_os = "apple-ios"

  # Set target.
  common_flags = [
    "-target",
    "$triplet_cpu-$triplet_os$ios_deployment_target$triplet_environment",
  ]

  # This is here so that all files get recompiled after an Xcode update.
  # (defines are passed via the command line, and build system rebuild things
  # when their commandline changes). Nothing should ever read this define.
  defines = [ "CR_XCODE_VERSION=$xcode_version" ]

  asmflags = common_flags
  cflags = common_flags
  swiftflags = common_flags

  swiftflags += [
    "-swift-version",
    "5",
  ]

  # Without this, the constructors and destructors of a C++ object inside
  # an Objective C struct won't be called, which is very bad.
  cflags_objcc = [ "-fobjc-call-cxx-cdtors" ]

  ldflags = common_flags
}

# 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") {
  # The variable ios_sdk_path is relative to root_build_dir when using Goma RBE
  # and system Xcode (since Goma RBE only supports paths relative to source).
  # Rebase the value in that case since gn does not convert paths in compiler
  # flags (since it is not aware they are paths).
  _sdk_root = ios_sdk_path
  if (use_system_xcode && use_goma) {
    _sdk_root = rebase_path(ios_sdk_path, root_build_dir)
  }

  common_flags = [
    "-isysroot",
    _sdk_root,
  ]
  swiftflags = [
    "-sdk",
    _sdk_root,
  ]

  if (target_environment == "catalyst") {
    common_flags += [
      "-isystem",
      "$_sdk_root/System/iOSSupport/usr/include",
      "-iframework",
      "$_sdk_root/System/iOSSupport/System/Library/Frameworks",
    ]
  }

  if (use_xcode_clang && enable_ios_bitcode) {
    if (is_debug) {
      common_flags += [ "-fembed-bitcode-marker" ]
    } else {
      common_flags += [ "-fembed-bitcode" ]
    }
  }

  asmflags = common_flags
  cflags = common_flags
  ldflags = common_flags
}

config("ios_executable_flags") {
  ldflags = []

  # On "catalyst", the bundle structure is different (uses the same structure
  # as a regular macOS app), so an additional -rpath is required.
  if (target_environment == "catalyst") {
    ldflags += [ "-Wl,-rpath,@loader_path/../Frameworks" ]
  }

  ldflags += [ "-Wl,-rpath,@executable_path/Frameworks" ]
}

config("ios_extension_executable_flags") {
  configs = default_executable_configs

  ldflags = [
    "-e",
    "_NSExtensionMain",
    "-fapplication-extension",
  ]

  # On "catalyst", the bundle structure is different (uses the same structure
  # as a regular macOS app), so an additional -rpath is required.
  if (target_environment == "catalyst") {
    ldflags += [ "-Wl,-rpath,@loader_path/../../../../Frameworks" ]
  }

  ldflags += [ "-Wl,-rpath,@executable_path/../../Frameworks" ]
}

config("ios_dynamic_flags") {
  ldflags = [
    # Always load Objective-C categories and class.
    "-Wl,-ObjC",
  ]

  # The path to the Swift compatibility libraries (required to run code built
  # with version N of the SDK on older version of the OS) is relative to the
  # toolchains directory and changes with the environment.
  _swift_compatibility_libs_dir_prefix = "$ios_toolchains_path/usr/lib/swift"
  if (target_environment == "simulator") {
    _swift_compatibility_libs_dir =
        "$_swift_compatibility_libs_dir_prefix/iphonesimulator"
  } else if (target_environment == "device") {
    _swift_compatibility_libs_dir =
        "$_swift_compatibility_libs_dir_prefix/iphoneos"
  } else if (target_environment == "catalyst") {
    _swift_compatibility_libs_dir =
        "$_swift_compatibility_libs_dir_prefix/maccatalyst"
  }

  lib_dirs = [
    "$ios_sdk_path/usr/lib/swift",
    _swift_compatibility_libs_dir,
  ]
}

config("ios_shared_library_flags") {
  ldflags = [
    "-Wl,-rpath,@executable_path/Frameworks",
    "-Wl,-rpath,@loader_path/Frameworks",
  ]
}

config("disable_implicit_retain_self_warning") {
  cflags_objc = [ "-Wno-implicit-retain-self" ]
  cflags_objcc = cflags_objc
}

config("xctest_config") {
  # Use -iframework for XCTest.framework so that the compiler will treat it as a
  # system framework and ignore warnings in XCTest framework headers.
  common_flags = [
    "-iframework",
    rebase_path("$ios_sdk_platform_path/Developer/Library/Frameworks",
                root_build_dir),
  ]
  cflags = common_flags
  ldflags = common_flags

  frameworks = [
    "Foundation.framework",
    "XCTest.framework",
  ]
}

group("xctest") {
  public_configs = [ ":xctest_config" ]
}

_xctrunner_path =
    "$ios_sdk_platform_path/Developer/Library/Xcode/Agents/XCTRunner.app"

# When building with Goma RBE, $ios_sdk_platform_path corresponds to a symlink
# below $root_build_dir that points to the real SDK to use. Because the files
# are below $root_build_dir, it is not possible to list them as a target input
# without gn complaining (as it can't find a target creating those files).
#
# The symlinks are created by //build/config/apple/sdk_info.py script invoked
# via exec_script() from //build/config/{ios/ios_sdk.gni,mac/mac_sdk.gni}.
# As the invocation is done by exec_script, there is no target that can list
# those files as output.
#
# To workaround this, add a target that pretends to create those files
# (but does nothing). See https://crbug.com/1061487 for why this is needed.
if (use_system_xcode && use_goma) {
  action("copy_xctrunner_app") {
    testonly = true
    script = "//chromium/build/noop.py"
    outputs = [
      "$_xctrunner_path/Info.plist",
      "$_xctrunner_path/PkgInfo",
      "$_xctrunner_path/XCTRunner",
    ]
  }
}

# When creating the test runner for an XCUITest, the arm64e slice of the binary
# must be removed (at least until the app ships with arm64e slice which is not
# yet supported by Apple).
action("xctest_runner_without_arm64e") {
  testonly = true
  script = "//chromium/build/config/ios/strip_arm64e.py"
  sources = [ "$_xctrunner_path/XCTRunner" ]
  outputs = [ "$target_out_dir/XCTRunner" ]
  args = [
    "--output",
    rebase_path(outputs[0], root_build_dir),
    "--input",
    rebase_path(sources[0], root_build_dir),
    "--xcode-version",
    xcode_version,
  ]

  if (use_system_xcode && use_goma) {
    deps = [ ":copy_xctrunner_app" ]
  }
}

[ Dauer der Verarbeitung: 0.2 Sekunden  (vorverarbeitet)  ]