aboutsummaryrefslogtreecommitdiff
path: root/pw_toolchain/host_clang/BUILD.gn
diff options
context:
space:
mode:
Diffstat (limited to 'pw_toolchain/host_clang/BUILD.gn')
-rw-r--r--pw_toolchain/host_clang/BUILD.gn42
1 files changed, 32 insertions, 10 deletions
diff --git a/pw_toolchain/host_clang/BUILD.gn b/pw_toolchain/host_clang/BUILD.gn
index eeebe1231..abcaf6863 100644
--- a/pw_toolchain/host_clang/BUILD.gn
+++ b/pw_toolchain/host_clang/BUILD.gn
@@ -15,12 +15,42 @@
import("//build_overrides/pigweed.gni")
import("//build_overrides/pigweed_environment.gni")
+import("toolchains.gni")
+
+config("coverage") {
+ cflags = [
+ "-fprofile-instr-generate",
+ "-fcoverage-mapping",
+ ]
+
+ if (pw_toolchain_PROFILE_SOURCE_FILES != []) {
+ _profile_source_files = []
+ foreach(file, pw_toolchain_PROFILE_SOURCE_FILES) {
+ file = rebase_path(file, root_build_dir)
+ file = string_replace(file, "/", "\/")
+ file = string_replace(file, ".", "\.")
+ _profile_source_files += [ "src:$file" ]
+ }
+
+ _profile_file = "$root_build_dir/profile-source-files.list"
+ write_file(_profile_file, _profile_source_files)
+ cflags += [ "-fprofile-list=" + rebase_path(_profile_file, root_build_dir) ]
+ }
+
+ ldflags = cflags
+}
+
# See https://github.com/google/sanitizers
config("sanitize_address") {
cflags = [ "-fsanitize=address" ]
ldflags = cflags
}
+# This is a deprecated config, use "coverage" config instead.
+config("sanitize_coverage") {
+ configs = [ ":coverage" ]
+}
+
config("sanitize_memory") {
cflags = [
"-fsanitize=memory",
@@ -83,14 +113,6 @@ config("sanitize_thread") {
ldflags = cflags
}
-config("sanitize_coverage") {
- cflags = [
- "-fprofile-instr-generate",
- "-fcoverage-mapping",
- ]
- ldflags = cflags
-}
-
# Locate XCode's sysroot for Clang.
config("xcode_sysroot") {
if (current_os == "mac") {
@@ -107,7 +129,7 @@ config("xcode_sysroot") {
}
config("linux_sysroot") {
- if (current_os == "linux") {
+ if (current_os == "linux" && defined(pw_env_setup_CIPD_PIGWEED)) {
cflags = [ "--sysroot=" +
rebase_path(pw_env_setup_CIPD_PIGWEED, root_build_dir) +
"/clang_sysroot/" ]
@@ -122,7 +144,7 @@ config("linux_sysroot") {
#
# Pull the appropriate paths from our Pigweed env setup.
config("no_system_libcpp") {
- if (current_os == "mac") {
+ if (current_os == "mac" && defined(pw_env_setup_CIPD_PIGWEED)) {
install_dir = pw_env_setup_CIPD_PIGWEED
assert(install_dir != "",
"You forgot to activate the Pigweed environment; " +