blob: c2566d233fe90fd7b4c3d9dde64abdbf3e09f421 [file] [log] [blame]
Alexei Frolov1a82c142019-10-31 17:37:12 -07001# 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 Mohr49de4922019-12-10 20:10:41 -080015import("$dir_pw_docgen/docs.gni")
16
Alexei Frolov844ff0f2020-05-06 12:15:29 -070017config("colorize_output") {
18 cflags = [
19 # Colorize output. Ninja's Clang invocation disables color by default.
20 "-fdiagnostics-color",
Wyatt Heplerb9db09f2020-01-27 17:40:08 -080021 ]
Alexei Frolov844ff0f2020-05-06 12:15:29 -070022 ldflags = cflags
Wyatt Heplerb9db09f2020-01-27 17:40:08 -080023}
24
25config("debugging") {
26 # Enable debug symbol generation. This has no effect on final code size.
27 cflags = [ "-g" ]
28}
29
Alexei Frolov844ff0f2020-05-06 12:15:29 -070030config("extra_debugging") {
31 # Include things like macro expansion in debug info.
32 cflags = [ "-g3" ]
33}
34
35# Optimization levels
36config("optimize_debugging") {
37 cflags = [ "-Og" ]
38 ldflags = cflags
39}
40
41config("optimize_speed") {
42 cflags = [ "-O2" ]
43 ldflags = cflags
44}
45
46config("optimize_more_speed") {
47 cflags = [ "-O3" ]
48 ldflags = cflags
49}
50
51config("optimize_size") {
52 cflags = [ "-Os" ]
53 ldflags = cflags
54}
55
Alexei Frolov1a82c142019-10-31 17:37:12 -070056# Standard compiler flags to reduce output binary size.
57config("reduced_size") {
58 cflags = [
59 "-fno-common",
60 "-fno-exceptions",
61 "-ffunction-sections",
62 "-fdata-sections",
63 ]
64 cflags_cc = [ "-fno-rtti" ]
65}
66
67config("strict_warnings") {
68 cflags = [
69 "-Wall",
70 "-Wextra",
Keir Mierle243e32a2019-11-05 10:29:26 -080071
Wyatt Hepler979890d2019-11-06 17:17:45 -080072 # 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 Frolov1a82c142019-10-31 17:37:12 -070076 ]
Wyatt Hepler1919c642019-12-06 10:06:13 -080077 cflags_cc = [ "-Wnon-virtual-dtor" ]
Alexei Frolov1a82c142019-10-31 17:37:12 -070078}
79
Armando Montanez888370d2020-05-01 18:29:22 -070080# This config contains warnings that we don't necessarily recommend projects
81# enable, but are enabled for upstream Pigweed for maximum project
82# compatibility.
83config("extra_strict_warnings") {
84 cflags = [ "-Wshadow" ]
85}
86
Wyatt Hepler818e3312020-01-16 14:19:21 -080087config("cpp11") {
88 cflags_cc = [ "-std=c++11" ]
89}
90
91config("cpp14") {
92 cflags_cc = [ "-std=c++14" ]
93}
94
Alexei Frolov1a82c142019-10-31 17:37:12 -070095config("cpp17") {
Wyatt Hepler979890d2019-11-06 17:17:45 -080096 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 Frolov1a82c142019-10-31 17:37:12 -0700102}
103
Rob Mohr49de4922019-12-10 20:10:41 -0800104pw_doc_group("docs") {
Rob Mohra0ba54f2020-02-27 11:43:49 -0800105 sources = [ "docs.rst" ]
Rob Mohr49de4922019-12-10 20:10:41 -0800106}
Alexei Frolovc15a9882019-12-23 14:29:02 -0800107
108# Pool to limit a single thread to download external Go packages at a time.
109pool("go_download_pool") {
110 depth = 1
111}