910e62b5创建于 1月15日历史提交
# Copyright 2023 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

assert(is_fuchsia)

# TODO(crbug.com/359657446): Remove the duplicate arguments in favor of
# using the ones in third_party/fuchsia-gn-sdk/. Some of them are needed
# by repos like webrtc which may not update to use the
# third_party/fuchsia-gn-sdk/src/gn_configs.gni.
declare_args() {
  # Path to the fuchsia SDK. This is intended for use in other templates &
  # rules to reference the contents of the fuchsia SDK.
  fuchsia_sdk = "//third_party/fuchsia-sdk/sdk"

  # ID uniquely identifying the Fuchsia IDK build. This is exposed as a
  # property so it can be used to locate images and packages on GCS and
  # as a marker to indicate the "version" of the IDK.
  # Defaults to the id found in the manifest.json file of the SDK.
  fuchsia_sdk_id = ""
}

# The SDK manifest file. This is useful to include as a dependency
# for some targets in order to cause a rebuild when the version of the
# SDK is changed.
fuchsia_sdk_manifest_file = "${fuchsia_sdk}/meta/manifest.json"

# fuchsia_tool_dir is used to specify the directory in the SDK to locate
# tools for the host cpu architecture. If the host_cpu is not recognized,
# then tool dir defaults to x64.
fuchsia_tool_dir = "${fuchsia_sdk}/tools/${host_cpu}"

if (fuchsia_sdk_id == "") {
  # Note: If we need to expose more than just the id in the future,
  # we should consider exposing the entire json object for the metadata vs.
  # adding a bunch of variables.
  _meta = read_file(fuchsia_sdk_manifest_file, "json")
  fuchsia_sdk_id = _meta.id
}

declare_args() {
  # Specify a readelf_exec path to use. If not specified, the host's system
  # executable will be used. Passed to populate_build_id_dir.py and
  # prepare_package_inputs.py via the --readelf-exec flag.
  # Must be a GN path (not an absolute path) since it is adjusted with
  # rebase_path().
  if (!defined(fuchsia_sdk_readelf_exec)) {
    fuchsia_sdk_readelf_exec = ""
  }
}

# Copy from third_party/fuchsia-gn-sdk/src/gn_configs.gni to avoid importing
# files from //third_party/ in //build/.
# Note, `current_cpu` should always exist in the //build/ tree, so the
# `target_cpu` fallback has been removed.
fuchsia_target_api_level = 29
fuchsia_arch_root =
    "${fuchsia_sdk}/obj/${target_cpu}-api-${fuchsia_target_api_level}"

# Write Fuchsia arch root paths to gn_logs.txt, so that Siso can reference
# these GN variables.
_fuchsia_arch_root = rebase_path(fuchsia_arch_root, "//")

# The legacy directory is still used. But, will be removed soon.
_fuchsia_legacy_arch_root =
    rebase_path("${fuchsia_sdk}/arch/${target_cpu}", "//")

fuchsia_gn_logs = [
  "fuchsia_arch_root=${_fuchsia_arch_root}",
  "fuchsia_legacy_arch_root=${_fuchsia_legacy_arch_root}",
]