| # 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 |
| # Location of ifs file generated by the shared_library() target. |
| # |
| # reference |
| # Location of checked in reference ifs file. |
| # |
| # library_name |
| # A human-readable library name for debugging purposes. |
| |
| 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" |
| |
| action("$target_name.abi.ifs") { |
| script = "$clang_prefix/llvm-ifs" |
| |
| forward_variables_from(invoker, [ "deps" ]) |
| |
| inputs = [ invoker.current ] |
| outputs = [ abi_file ] |
| |
| args = [ |
| "--strip-undefined", |
| "--strip-ifs-target", |
| "--strip-needed", |
| rebase_path(invoker.current, root_build_dir), |
| "--output-ifs", |
| rebase_path(abi_file, root_build_dir), |
| ] |
| |
| # TODO(fxbug.dev/99723): This will not be necessary when libraries end |
| # up linking against libc's ifs generated stub. |
| if (select_variant + [ "gcc" ] - [ "gcc" ] != select_variant) { |
| args += [ |
| "--exclude=__bss_start", |
| "--exclude=_edata", |
| "--exclude=_end", |
| ] |
| } |
| } |
| |
| action(target_name) { |
| 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" ] |
| } |
| } |
| } |