blob: 3f4d20430137a9a64cf31ca29994da33c870767a [file] [log] [blame]
# Copyright 2019 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.
import("//build/config/clang/clang.gni")
import("//build/sdk/config.gni")
# Verifies the list of public symbols from a prebuilt library to be added to
# the SDK against a golden file.
# Additionally, checks that none of the symbols is a C++ symbol.
#
# Parameters
#
# * current
# - Required: Location of ifs file generated by a shared_library() target.
# - Type: path
#
# * reference
# - Required: Location of checked in reference ifs file.
# - Type: path
#
# * library_name
# - Required: A human-readable library name for debugging purposes.
# - Type: string
#
# * ifs_args
# - Optional: list of args to pass to llvm-ifs.
# - Type: list of string
#
# * testonly, visibility
# - Optional: As for action().
#
# When adding a new library to be tracked by `verify_public_symbols`, you can
# create an empty file, traditionally this would be named ${library_name}.ifs,
# run the build, it will fail, and give a cp command to run.
template("verify_public_symbols") {
assert(defined(invoker.current), "current must be provided")
assert(defined(invoker.reference), "reference must be provided")
assert(defined(invoker.library_name), "library_name must be provided")
abi_file = "$target_gen_dir/$target_name.abi.ifs"
stamp_file = "$target_gen_dir/$target_name.public_symbols.verified.stamp"
main_target = target_name
action("$target_name.abi.ifs") {
visibility = [ ":$main_target" ]
forward_variables_from(invoker, [ "testonly" ])
script = "$clang_prefix/llvm-ifs"
forward_variables_from(invoker, [ "deps" ])
inputs = [ invoker.current ]
outputs = [ abi_file ]
args = [
"--strip-undefined",
"--strip-ifs-target",
"--strip-needed",
"--strip-size",
rebase_path(invoker.current, root_build_dir),
"--output-ifs",
rebase_path(abi_file, root_build_dir),
]
if (defined(invoker.ifs_args)) {
args += invoker.ifs_args
}
# Libraries linked with gnu linkers get these symbols implicitly. They aren't
# part of the abi that is worth tracking, nor do we want to exporting them in shared
# object stubs.
if (select_variant + [ "gcc" ] - [ "gcc" ] != select_variant) {
args += [
"--exclude=__bss_start",
"--exclude=_edata",
"--exclude=_end",
]
}
}
action(main_target) {
forward_variables_from(invoker,
[
"visibility",
"testonly",
])
script = "//build/cpp/verify_public_symbols.sh"
deps = [ ":$target_name.abi.ifs" ]
inputs = [
abi_file,
invoker.reference,
]
outputs = [ stamp_file ]
args = [
invoker.library_name,
rebase_path(abi_file, root_build_dir),
rebase_path(invoker.reference, root_build_dir),
rebase_path(stamp_file, root_build_dir),
]
if (warn_on_sdk_changes) {
args += [ "--warn" ]
}
}
}