| # Copyright 2018 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/profile/config.gni") |
| import("//build/toolchain/variant.gni") |
| |
| if (profile_source_files != []) { |
| # This can't use a generated_file() target because there's no way to |
| # express the deps to make GN accept the file in the inputs list if it's |
| # the output of some target. |
| _profile_source_files_file = "$root_out_dir/profile-source-files.list" |
| _profile_source_files_lines = [] |
| foreach(file, profile_source_files) { |
| _profile_source_files_lines += |
| [ "src:" + rebase_path(file, root_build_dir) ] |
| } |
| write_file(_profile_source_files_file, |
| _profile_source_files_lines, |
| "list lines") |
| profile_source_files_list_files += [ _profile_source_files_file ] |
| } |
| |
| variant("profile") { |
| common_flags = [ |
| "-fprofile-instr-generate", |
| "-fcoverage-mapping", |
| ] |
| |
| inputs = profile_source_files_list_files |
| foreach(file, profile_source_files_list_files) { |
| common_flags += [ "-fprofile-list=" + rebase_path(file, root_build_dir) ] |
| } |
| |
| if (!is_kernel && is_fuchsia) { |
| # The statically-linked profiling runtime depends on libzircon. |
| # TODO(fxbug.dev/61522): Ensure this works with shared_library() instances too! |
| deps = [ "//src/zircon/lib/zircon" ] |
| |
| dynamic_linker_flags = "-dynamic-linker=profile/ld.so.1" |
| ldflags = [ "-Wl,$dynamic_linker_flags" ] |
| rustflags = [ "-Clink-arg=$dynamic_linker_flags" ] |
| } |
| } |