# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# TODO(richkadel): added this import and modified the fuchsia_sdk assignment.
# See below.
import("//build/fuchsia/sdk.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 = "$fuchsia_sdk_path"

  # TODO(richkadel): Since flutter needs build rules from the GN SDK, but also
  # requires the Fuchsia _Core_ SDK (for dart libraries, in the core SDK, but
  # excluded from the GN SDK), the Fuchsia SDK assumption that the build files
  # are in the same SDK directory path as the APIs does not hold true. (And
  # there are a couple of other minor tweaks that appear to be needed, at
  # this time.) This use case will be discussed with the SDK team, to see if we
  # can come up with a cleaner solution.

  # Build ID uniquely identifying the Fuchsia IDK. 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. If it is empty, then it is most likely that something is fatally wrong.
  fuchsia_sdk_id = ""
}

declare_args() {
  # 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 use 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/x64"
  if (host_cpu == "x64" || host_cpu == "arm64") {
    fuchsia_tool_dir = "${fuchsia_sdk}/tools/${host_cpu}"
  }

  # fuchsia_auto_index_symbols when true adds the ids.txt file generated from a `fuchsia_package`
  # to the Fuchsia symbol index used to symbolize logs and to find source when using zxdb.
  # The default value is false, in order to be backwards compatibility with existing builds, and
  # only makes sense to set to true when building as a developer that will need to symbolize logs
  # or use the debugger with locally build code.
  fuchsia_auto_index_symbols = false
}

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
}
