blob: dfaad82da5430dd27c385080bc1f539da0686688 [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
Armando Montanezfb3d3fb2020-06-09 18:12:12 -070015import("//build_overrides/pigweed.gni")
Rob Mohr49de4922019-12-10 20:10:41 -080016
Armando Montanezfb3d3fb2020-06-09 18:12:12 -070017import("$dir_pw_docgen/docs.gni")
Wyatt Heplerd49f8fe2020-10-15 10:13:47 -070018
Alexei Frolov844ff0f2020-05-06 12:15:29 -070019config("colorize_output") {
20 cflags = [
21 # Colorize output. Ninja's Clang invocation disables color by default.
22 "-fdiagnostics-color",
Wyatt Heplerb9db09f2020-01-27 17:40:08 -080023 ]
Alexei Frolov844ff0f2020-05-06 12:15:29 -070024 ldflags = cflags
Wyatt Heplerb9db09f2020-01-27 17:40:08 -080025}
26
27config("debugging") {
28 # Enable debug symbol generation. This has no effect on final code size.
29 cflags = [ "-g" ]
30}
31
Alexei Frolov844ff0f2020-05-06 12:15:29 -070032config("extra_debugging") {
33 # Include things like macro expansion in debug info.
34 cflags = [ "-g3" ]
35}
36
37# Optimization levels
38config("optimize_debugging") {
39 cflags = [ "-Og" ]
40 ldflags = cflags
41}
42
43config("optimize_speed") {
44 cflags = [ "-O2" ]
45 ldflags = cflags
46}
47
48config("optimize_more_speed") {
49 cflags = [ "-O3" ]
50 ldflags = cflags
51}
52
53config("optimize_size") {
54 cflags = [ "-Os" ]
55 ldflags = cflags
56}
57
Alexei Frolov1a82c142019-10-31 17:37:12 -070058# Standard compiler flags to reduce output binary size.
59config("reduced_size") {
60 cflags = [
61 "-fno-common",
62 "-fno-exceptions",
63 "-ffunction-sections",
64 "-fdata-sections",
65 ]
66 cflags_cc = [ "-fno-rtti" ]
67}
68
69config("strict_warnings") {
70 cflags = [
71 "-Wall",
72 "-Wextra",
Ewout van Bekkumb4f95982020-10-15 11:10:51 -070073 "-Wimplicit-fallthrough",
Keir Mierle243e32a2019-11-05 10:29:26 -080074
Wyatt Hepler979890d2019-11-06 17:17:45 -080075 # 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 Frolov1a82c142019-10-31 17:37:12 -070079 ]
Wyatt Hepler1919c642019-12-06 10:06:13 -080080 cflags_cc = [ "-Wnon-virtual-dtor" ]
Alexei Frolov1a82c142019-10-31 17:37:12 -070081}
82
Armando Montanez888370d2020-05-01 18:29:22 -070083# This config contains warnings that we don't necessarily recommend projects
84# enable, but are enabled for upstream Pigweed for maximum project
85# compatibility.
86config("extra_strict_warnings") {
Ewout van Bekkum2f20c132020-10-15 11:06:15 -070087 cflags = [
88 "-Wshadow",
89
90 # Migrate the warning(s) below to strict_warnings once customers support it.
91 "-Wcast-qual",
92 ]
Armando Montanez888370d2020-05-01 18:29:22 -070093}
94
Wyatt Hepler818e3312020-01-16 14:19:21 -080095config("cpp11") {
96 cflags_cc = [ "-std=c++11" ]
97}
98
99config("cpp14") {
100 cflags_cc = [ "-std=c++14" ]
101}
102
Alexei Frolov1a82c142019-10-31 17:37:12 -0700103config("cpp17") {
Wyatt Hepler979890d2019-11-06 17:17:45 -0800104 cflags_cc = [
105 "-std=c++17",
106
107 # Allow uses of the register keyword, which may appear in C headers.
108 "-Wno-register",
109 ]
Alexei Frolov1a82c142019-10-31 17:37:12 -0700110}
111
Rob Mohr49de4922019-12-10 20:10:41 -0800112pw_doc_group("docs") {
Rob Mohra0ba54f2020-02-27 11:43:49 -0800113 sources = [ "docs.rst" ]
Rob Mohr49de4922019-12-10 20:10:41 -0800114}
Alexei Frolovc15a9882019-12-23 14:29:02 -0800115
116# Pool to limit a single thread to download external Go packages at a time.
117pool("go_download_pool") {
118 depth = 1
119}