# Copyright 2018 The Hafnium Authors.
#
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/BSD-3-Clause.

import("//build/toolchain/embedded.gni")
import("//build/toolchain/host.gni")

host_toolchain("host") {
  use_platform = false
}

# Toolchain for building tests which run under Linux under Hafnium.
embedded_clang_toolchain("aarch64_linux_clang") {
  target = "aarch64-linux-musleabi"

  extra_cflags = "-nostdinc -isystem" +
                 rebase_path("//prebuilts/linux-aarch64/musl/include")
  extra_defines = "-D_LIBCPP_HAS_MUSL_LIBC=1 -D_GNU_SOURCE=1"
  extra_ldflags = "-no-pie -lc --library-path=" +
                  rebase_path("//prebuilts/linux-aarch64/musl/lib/") + " " +
                  rebase_path("//prebuilts/linux-aarch64/musl/lib/crt1.o")

  toolchain_args = {
    use_platform = true
    plat_arch = "fake"
    plat_boot_flow = "//src/arch/fake:boot_flow"
    plat_console = "//src/arch/fake:console"
    plat_iommu = "//src/iommu:absent"
    plat_memory_protect = "//src/memory_protect:absent"
  }
}
