| # 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") |
| import("//build/testing/golden_files.gni") |
| import("//build/toolchain/zircon/gcc.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" |
| |
| 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 |
| } |
| |
| args += ifs_extra_switches |
| } |
| |
| golden_files(main_target) { |
| forward_variables_from(invoker, |
| [ |
| "visibility", |
| "testonly", |
| ]) |
| |
| deps = [ ":$target_name.abi.ifs" ] |
| |
| comparisons = [ |
| { |
| candidate = abi_file |
| golden = invoker.reference |
| }, |
| ] |
| |
| message = "ABI has changed! In library ${invoker.library_name}" |
| } |
| } |