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