blob: e49593c203d6aac1bf09ec4133698f685658f471 [file] [log] [blame]
# Copyright 2017 The Fuchsia 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 step shouldn't run in a target toolchain, since it produces the sysroot
# that the target toolchain uses as input.
assert(current_toolchain == "//build/toolchain/fuchsia:${target_cpu}-sysroot")
if (target_cpu == "x64") {
fuchsia_target_arch = "x86_64"
} else if (target_cpu == "arm64") {
fuchsia_target_arch = "aarch64"
}
if (host_cpu == "arm64") {
clang_cpu = "aarch64"
} else if (host_cpu == "x64") {
clang_cpu = "x86_64"
} else {
assert(false, "Host CPU not supported")
}
clang_os = host_os
if (host_os == "mac") {
clang_os = "darwin"
}
magenta_build_dir = rebase_path("//out/build-magenta/build-$magenta_project")
magenta_sysroot_list = magenta_build_dir + "/sysroot.list"
toolchain_sysroot = rebase_path(
"//buildtools/toolchain/clang+llvm-$clang_cpu-$clang_os/$fuchsia_target_arch-fuchsia")
group("sysroot") {
deps = [
":assemble_sysroot",
]
}
# This step combines the magenta sysroot and the C++ standard library headers
# from the libcxx repo into the sysroot in the output directory. This step
# should re-run whenever any of the source header files change. Additionally,
# since many targets will depend on some or all of these headers, we need to
# tell ninja that these files are produced by this build step so it knows those
# steps are dirty when this step runs.
action("assemble_sysroot") {
script = "assemble_sysroot.py"
sysroot_stamp = "$target_gen_dir/assemble_sysroot.stamp"
sysroot = rebase_path("$root_build_dir/sysroot")
if (host_os == "linux") {
toolchain_stamp_file = "//buildtools/linux64/toolchain.stamp"
} else if (host_os == "mac") {
toolchain_stamp_file = "//buildtools/mac/toolchain.stamp"
} else {
assert(false, "Host OS not supported")
}
toolchain_sysroot_contents = exec_script("list_sysroot_contents.py",
[
rebase_path(sysroot, "//"),
toolchain_sysroot,
],
"trim scope",
[ toolchain_stamp_file ])
magenta_sysroot_list_contents = read_file(magenta_sysroot_list, "list lines")
magenta_sysroot_inputs = []
magenta_sysroot_outputs = []
foreach(entry, magenta_sysroot_list_contents) {
magenta_sysroot_inputs += [ "$magenta_build_dir/sysroot/$entry" ]
magenta_sysroot_outputs += [ "$root_build_dir/sysroot/$entry" ]
}
inputs = toolchain_sysroot_contents.inputs + magenta_sysroot_inputs
outputs = [ sysroot_stamp ] + toolchain_sysroot_contents.outputs +
magenta_sysroot_outputs
args = [
"--toolchain_sysroot=$toolchain_sysroot",
"--magenta_sysroot=$magenta_build_dir/sysroot",
"--sysroot=$sysroot",
"--sysroot_stamp=" + rebase_path(sysroot_stamp),
]
}