| # Copyright 2020 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. |
| |
| # IMPORTANT: This file is used to build the Fuchsia SDK sysroot for the |
| # current target architecture only, i.e. the set of files that will be exported |
| # to the SDK's sysroot atom. This does not setup the platform sysroot. |
| # See //zircon/public/sysroot/BUILD.gn for details on the latter. |
| # |
| # Note however that both files parse the same inputs collected from |
| # sysroot_entries.gni files. See below for details. |
| import("//build/config/fuchsia/target_api_level.gni") |
| import("//build/sdk/sdk_atom.gni") |
| |
| # Collect the metadata for the SDK. |
| file_base = "${sdk_prebuilt_base_for_target_api_level}/sysroot" |
| sdk_files = [] |
| sdk_api_contents = [] |
| |
| version_content = { |
| root = file_base |
| |
| include_dir = "$file_base/include" |
| dist_dir = "" |
| headers = [] |
| link_libs = [] |
| dist_libs = [] |
| debug_libs = [] |
| } |
| |
| import("//sdk/lib/c/sysroot_entries.gni") |
| import("//src/zircon/lib/zircon/sysroot_entries.gni") |
| |
| # Turn the information from Zircon into a set of copy() rules for the |
| # sysroot while filling in $version_content. |
| # |
| # sysroot_entries will be a list of GN scopes, whose schema is documented |
| # in //zircon/public/sysroot/BUILD.gn. |
| # |
| sysroot_entries = sysroot_uninstrumented_libc_entries + |
| sysroot_instrumented_libc_entries + sysroot_vdso_entries |
| |
| sysroot_sdk_deps = [] |
| foreach(entry, sysroot_entries) { |
| if (defined(entry.sdk)) { |
| sdk = { |
| } |
| sdk = entry.sdk |
| if (defined(sdk.headers)) { |
| # This has to generate a separate copy() target for each file. |
| dir = rebase_path(sdk.include_dir, "", root_build_dir) |
| foreach(file, sdk.headers) { |
| no_export = defined(sdk.no_export) && sdk.no_export |
| if (!no_export) { |
| version_content.headers += [ "$file_base/include/$file" ] |
| sdk_files += [ |
| { |
| source = "$dir/$file" |
| dest = "$file_base/include/$file" |
| }, |
| ] |
| sdk_api_contents += [ |
| { |
| source = "$dir/$file" |
| dest = "include/$file" |
| }, |
| ] |
| } |
| } |
| } else if (defined(sdk.debug)) { |
| sdk_files += [ |
| { |
| source = rebase_path(sdk.source, "", root_build_dir) |
| dest = "$file_base/${sdk.debug}" |
| }, |
| ] |
| version_content.debug_libs += [ "$file_base/${sdk.debug}" ] |
| } else { |
| # This is just a single copy() target. |
| if (defined(sdk.link)) { |
| version_content.link_libs += [ "$file_base/${sdk.link}" ] |
| sdk_files += [ |
| { |
| source = rebase_path(sdk.source, "", root_build_dir) |
| dest = "$file_base/${sdk.link}" |
| }, |
| ] |
| } else if (defined(sdk.dist)) { |
| version_content.dist_libs += [ "$file_base/${sdk.dist}" ] |
| version_content.dist_dir = file_base |
| sdk_files += [ |
| { |
| source = rebase_path(sdk.source, "", root_build_dir) |
| dest = "$file_base/${sdk.dist}" |
| }, |
| ] |
| } else { |
| assert(false, "confused by $sdk") |
| } |
| } |
| if (defined(sdk.deps)) { |
| sysroot_sdk_deps += sdk.deps |
| } |
| } |
| } |
| |
| sdk_files += [ |
| { |
| source = "//sdk/lib/c/libc.ifs" |
| dest = "pkg/sysroot/libc.ifs" |
| }, |
| { |
| source = "//src/zircon/lib/zircon/zircon.ifs" |
| dest = "pkg/sysroot/zircon.ifs" |
| }, |
| ] |
| |
| _sysroot_meta = { |
| type = "sysroot" |
| name = "sysroot" |
| ifs_files = [ |
| "pkg/sysroot/libc.ifs", |
| "pkg/sysroot/zircon.ifs", |
| ] |
| if (current_build_target_api_level == "PLATFORM") { |
| versions = { |
| if (target_cpu == "arm64") { |
| arm64 = version_content |
| } else if (target_cpu == "x64") { |
| x64 = version_content |
| } else if (target_cpu == "riscv64") { |
| riscv64 = version_content |
| } else { |
| assert(false, "Unknown CPU type: $target_cpu") |
| } |
| } |
| } else { |
| variants = [ |
| { |
| constraints = { |
| api_level = "$current_build_target_api_level" |
| arch = target_cpu |
| } |
| values = { |
| root = file_base |
| |
| include_dir = "$file_base/include" |
| sysroot_dir = version_content.dist_dir |
| headers = version_content.headers |
| link_libs = version_content.link_libs |
| dist_libs = version_content.dist_libs |
| debug_libs = version_content.debug_libs |
| } |
| }, |
| ] |
| } |
| } |
| |
| sdk_atom("sysroot_sdk") { |
| id = "sdk://pkg/sysroot" |
| category = "partner" |
| api = "sysroot.api" |
| api_contents = sdk_api_contents |
| |
| non_sdk_deps = [ "//zircon/vdso:sysroot_sdk" ] + sysroot_sdk_deps |
| |
| meta = { |
| dest = "pkg/sysroot/meta.json" |
| type = "sysroot" |
| value = _sysroot_meta |
| |
| # `source_prebuild_info` is unnecessary because `value` is provided. |
| } |
| |
| files = sdk_files |
| } |