Armando Montanez | 6954a8d | 2021-07-19 21:11:28 -0700 | [diff] [blame] | 1 | # Copyright 2021 The Pigweed Authors |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| 4 | # use this file except in compliance with the License. You may obtain a copy of |
| 5 | # the License at |
| 6 | # |
| 7 | # https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 | # License for the specific language governing permissions and limitations under |
| 13 | # the License. |
| 14 | |
| 15 | import("//build_overrides/pigweed.gni") |
| 16 | |
| 17 | import("$dir_pw_build/target_types.gni") |
| 18 | import("$dir_pw_docgen/docs.gni") |
| 19 | |
| 20 | config("linker_script") { |
| 21 | inputs = [ "build_id_linker_snippet.ld" ] |
| 22 | |
| 23 | # Automatically add the gnu build ID linker sections when building for Linux. |
| 24 | # macOS and Windows executables are not supported, and embedded targets must |
| 25 | # manually add the snippet to their linker script in a read-only section. |
| 26 | if (current_os == "linux") { |
| 27 | # When building for Linux, the linker provides a default linker script. |
| 28 | # The add_build_id_to_default_script.ld wrapper includes the |
| 29 | # build_id_linker_snippet.ld script in a way that appends to the the |
| 30 | # default linker script instead of overriding it. |
| 31 | ldflags = [ |
| 32 | "-T", |
| 33 | rebase_path("add_build_id_to_default_script.ld", root_build_dir), |
| 34 | ] |
| 35 | lib_dirs = [ "." ] |
| 36 | |
| 37 | inputs += [ "add_build_id_to_default_script.ld" ] |
| 38 | } |
| 39 | visibility = [ ":*" ] |
| 40 | } |
| 41 | |
| 42 | config("gnu_build_id") { |
| 43 | ldflags = [ "-Wl,--build-id=sha1" ] |
| 44 | } |
| 45 | |
| 46 | config("public_include_path") { |
| 47 | include_dirs = [ "public" ] |
| 48 | visibility = [ ":*" ] |
| 49 | } |
| 50 | |
| 51 | # GNU build IDs aren't supported by Windows and macOS. |
| 52 | if (current_os != "mac" && current_os != "win") { |
| 53 | pw_source_set("build_id") { |
| 54 | all_dependent_configs = [ |
| 55 | ":gnu_build_id", |
| 56 | ":linker_script", |
| 57 | ] |
| 58 | public_configs = [ ":public_include_path" ] |
| 59 | cflags = [ |
| 60 | "-Wno-array-bounds", |
| 61 | "-Wno-stringop-overflow", |
| 62 | ] |
| 63 | public = [ "public/pw_build_info/build_id.h" ] |
| 64 | sources = [ "build_id.cc" ] |
| 65 | deps = [ dir_pw_preprocessor ] |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | pw_doc_group("docs") { |
| 70 | sources = [ "docs.rst" ] |
| 71 | inputs = [ "build_id_linker_snippet.ld" ] |
| 72 | } |