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