# Copyright (c) 2013 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.

# This header file defines the "sysroot" variable which is the absolute path
# of the sysroot. If no sysroot applies, the variable will be an empty string.

declare_args() {
  # The absolute path of the sysroot that is applied when compiling using
  # the target toolchain.
  target_sysroot = ""
  use_sysroot = current_cpu == "arm" || (!is_linux && current_cpu == "arm64") ||
                current_cpu == "riscv64"
}

if (current_os == target_os && current_cpu == target_cpu &&
    target_sysroot != "") {
  sysroot = target_sysroot
} else if (is_ohos) {
  import("//build/config/ohos/config.gni")
  sysroot = "${musl_sysroot}"
} else if (is_android || (is_linux && use_sysroot)) {
  import("//build_plugins/config/aosp/sysroot.gni")
} else if (is_mac) {
  import("//build/config/mac/mac_sdk.gni")
  sysroot = mac_sdk_path
} else if (is_ios) {
  import("//build_plugins/config/ios/ios_sdk.gni")
  sysroot = ios_sdk_path
} else {
  sysroot = ""
}

if (!defined(link_sysroot)) {
  link_sysroot = sysroot
}