Alexei Frolov | 1a82c14 | 2019-10-31 17:37:12 -0700 | [diff] [blame] | 1 | # Copyright 2019 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 | |
Armando Montanez | fb3d3fb | 2020-06-09 18:12:12 -0700 | [diff] [blame^] | 15 | # gn-format disable |
| 16 | import("//build_overrides/pigweed.gni") |
Rob Mohr | 49de492 | 2019-12-10 20:10:41 -0800 | [diff] [blame] | 17 | |
Armando Montanez | fb3d3fb | 2020-06-09 18:12:12 -0700 | [diff] [blame^] | 18 | import("$dir_pigweed/legacy_target.gni") |
| 19 | import("$dir_pw_docgen/docs.gni") |
Alexei Frolov | 844ff0f | 2020-05-06 12:15:29 -0700 | [diff] [blame] | 20 | config("colorize_output") { |
| 21 | cflags = [ |
| 22 | # Colorize output. Ninja's Clang invocation disables color by default. |
| 23 | "-fdiagnostics-color", |
Wyatt Hepler | b9db09f | 2020-01-27 17:40:08 -0800 | [diff] [blame] | 24 | ] |
Alexei Frolov | 844ff0f | 2020-05-06 12:15:29 -0700 | [diff] [blame] | 25 | ldflags = cflags |
Wyatt Hepler | b9db09f | 2020-01-27 17:40:08 -0800 | [diff] [blame] | 26 | } |
| 27 | |
| 28 | config("debugging") { |
| 29 | # Enable debug symbol generation. This has no effect on final code size. |
| 30 | cflags = [ "-g" ] |
| 31 | } |
| 32 | |
Alexei Frolov | 844ff0f | 2020-05-06 12:15:29 -0700 | [diff] [blame] | 33 | config("extra_debugging") { |
| 34 | # Include things like macro expansion in debug info. |
| 35 | cflags = [ "-g3" ] |
| 36 | } |
| 37 | |
| 38 | # Optimization levels |
| 39 | config("optimize_debugging") { |
| 40 | cflags = [ "-Og" ] |
| 41 | ldflags = cflags |
| 42 | } |
| 43 | |
| 44 | config("optimize_speed") { |
| 45 | cflags = [ "-O2" ] |
| 46 | ldflags = cflags |
| 47 | } |
| 48 | |
| 49 | config("optimize_more_speed") { |
| 50 | cflags = [ "-O3" ] |
| 51 | ldflags = cflags |
| 52 | } |
| 53 | |
| 54 | config("optimize_size") { |
| 55 | cflags = [ "-Os" ] |
| 56 | ldflags = cflags |
| 57 | } |
| 58 | |
Alexei Frolov | 1a82c14 | 2019-10-31 17:37:12 -0700 | [diff] [blame] | 59 | # Standard compiler flags to reduce output binary size. |
| 60 | config("reduced_size") { |
| 61 | cflags = [ |
| 62 | "-fno-common", |
| 63 | "-fno-exceptions", |
| 64 | "-ffunction-sections", |
| 65 | "-fdata-sections", |
| 66 | ] |
| 67 | cflags_cc = [ "-fno-rtti" ] |
| 68 | } |
| 69 | |
| 70 | config("strict_warnings") { |
| 71 | cflags = [ |
| 72 | "-Wall", |
| 73 | "-Wextra", |
Keir Mierle | 243e32a | 2019-11-05 10:29:26 -0800 | [diff] [blame] | 74 | |
Wyatt Hepler | 979890d | 2019-11-06 17:17:45 -0800 | [diff] [blame] | 75 | # Make all warnings errors, except for the exemptions below. |
| 76 | "-Werror", |
| 77 | "-Wno-error=cpp", # preprocessor #warning statement |
| 78 | "-Wno-error=deprecated-declarations", # [[deprecated]] attribute |
Alexei Frolov | 1a82c14 | 2019-10-31 17:37:12 -0700 | [diff] [blame] | 79 | ] |
Wyatt Hepler | 1919c64 | 2019-12-06 10:06:13 -0800 | [diff] [blame] | 80 | cflags_cc = [ "-Wnon-virtual-dtor" ] |
Alexei Frolov | 1a82c14 | 2019-10-31 17:37:12 -0700 | [diff] [blame] | 81 | } |
| 82 | |
Armando Montanez | 888370d | 2020-05-01 18:29:22 -0700 | [diff] [blame] | 83 | # This config contains warnings that we don't necessarily recommend projects |
| 84 | # enable, but are enabled for upstream Pigweed for maximum project |
| 85 | # compatibility. |
| 86 | config("extra_strict_warnings") { |
| 87 | cflags = [ "-Wshadow" ] |
| 88 | } |
| 89 | |
Wyatt Hepler | 818e331 | 2020-01-16 14:19:21 -0800 | [diff] [blame] | 90 | config("cpp11") { |
| 91 | cflags_cc = [ "-std=c++11" ] |
| 92 | } |
| 93 | |
| 94 | config("cpp14") { |
| 95 | cflags_cc = [ "-std=c++14" ] |
| 96 | } |
| 97 | |
Alexei Frolov | 1a82c14 | 2019-10-31 17:37:12 -0700 | [diff] [blame] | 98 | config("cpp17") { |
Wyatt Hepler | 979890d | 2019-11-06 17:17:45 -0800 | [diff] [blame] | 99 | cflags_cc = [ |
| 100 | "-std=c++17", |
| 101 | |
| 102 | # Allow uses of the register keyword, which may appear in C headers. |
| 103 | "-Wno-register", |
| 104 | ] |
Alexei Frolov | 1a82c14 | 2019-10-31 17:37:12 -0700 | [diff] [blame] | 105 | } |
| 106 | |
Rob Mohr | 49de492 | 2019-12-10 20:10:41 -0800 | [diff] [blame] | 107 | pw_doc_group("docs") { |
Rob Mohr | a0ba54f | 2020-02-27 11:43:49 -0800 | [diff] [blame] | 108 | sources = [ "docs.rst" ] |
Rob Mohr | 49de492 | 2019-12-10 20:10:41 -0800 | [diff] [blame] | 109 | } |
Alexei Frolov | c15a988 | 2019-12-23 14:29:02 -0800 | [diff] [blame] | 110 | |
| 111 | # Pool to limit a single thread to download external Go packages at a time. |
| 112 | pool("go_download_pool") { |
| 113 | depth = 1 |
| 114 | } |