forked from google/pigweed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBUILD.gn
121 lines (109 loc) · 3.21 KB
/
BUILD.gn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# Copyright 2021 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
import("//build_overrides/pigweed.gni")
import("$dir_pw_build/target_types.gni")
import("$dir_pw_docgen/docs.gni")
import("$dir_pw_unit_test/test.gni")
config("linker_script") {
inputs = [ "build_id_linker_snippet.ld" ]
# Automatically add the gnu build ID linker sections when building for Linux.
# macOS and Windows executables are not supported, and embedded targets must
# manually add the snippet to their linker script in a read-only section.
if (current_os == "linux") {
# When building for Linux, the linker provides a default linker script.
# The add_build_id_to_default_script.ld wrapper includes the
# build_id_linker_snippet.ld script in a way that appends to the default
# linker script instead of overriding it.
ldflags = [
"-T",
rebase_path("add_build_id_to_default_linker_script.ld", root_build_dir),
]
lib_dirs = [ "." ]
inputs += [ "add_build_id_to_default_linker_script.ld" ]
}
visibility = [ ":*" ]
}
config("gnu_build_id") {
ldflags = [ "-Wl,--build-id=sha1" ]
}
config("public_include_path") {
include_dirs = [ "public" ]
visibility = [ ":*" ]
}
# GNU build IDs aren't supported by Windows and macOS.
if (current_os == "mac" || current_os == "win") {
# noop version of the package that allows build_id users to still be built
# for unsupported platforms and avoids amplifying downstream complexity. It
# provides a noop version of pw::build_info::BuildId() which just returns an
# empty span.
pw_source_set("build_id_or_noop") {
public_configs = [ ":public_include_path" ]
public = [
"public/pw_build_info/build_id.h",
"public/pw_build_info/util.h",
]
sources = [
"build_id_noop.cc",
"util.cc",
]
deps = [
dir_pw_log,
dir_pw_span,
dir_pw_string,
]
}
} else {
pw_source_set("build_id") {
all_dependent_configs = [
":gnu_build_id",
":linker_script",
]
public_configs = [ ":public_include_path" ]
public = [
"public/pw_build_info/build_id.h",
"public/pw_build_info/util.h",
]
sources = [
"build_id.cc",
"util.cc",
]
deps = [
dir_pw_log,
dir_pw_preprocessor,
dir_pw_span,
dir_pw_string,
]
}
pw_source_set("build_id_or_noop") {
public_deps = [ ":build_id" ]
}
}
pw_doc_group("docs") {
sources = [ "docs.rst" ]
inputs = [
"add_build_id_to_default_linker_script.ld",
"build_id_linker_snippet.ld",
]
}
pw_test_group("tests") {
tests = [ ":build_id_test" ]
}
pw_test("build_id_test") {
enable_if = current_os == "linux"
deps = [
":build_id",
"$dir_pw_span",
]
sources = [ "build_id_test.cc" ]
}