blob: d30bbc982f7fb5e745f53e31432fd5cd445804df [file] [log] [blame]
Wyatt Heplerae222dc2020-10-14 10:46:27 -07001# Copyright 2020 The Pigweed Authors
Alexei Frolov1a82c142019-10-31 17:37:12 -07002#
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
Wyatt Hepler0a6f7632020-10-29 09:08:19 -070019# IMPORTANT: The compilation flags in this file must be kept in sync with
20# the CMake flags pw_build/CMakeLists.txt.
21
Alexei Frolov844ff0f2020-05-06 12:15:29 -070022config("colorize_output") {
23 cflags = [
24 # Colorize output. Ninja's Clang invocation disables color by default.
25 "-fdiagnostics-color",
Wyatt Heplerb9db09f2020-01-27 17:40:08 -080026 ]
Alexei Frolov844ff0f2020-05-06 12:15:29 -070027 ldflags = cflags
Wyatt Heplerb9db09f2020-01-27 17:40:08 -080028}
29
30config("debugging") {
31 # Enable debug symbol generation. This has no effect on final code size.
32 cflags = [ "-g" ]
33}
34
Alexei Frolov844ff0f2020-05-06 12:15:29 -070035config("extra_debugging") {
36 # Include things like macro expansion in debug info.
37 cflags = [ "-g3" ]
38}
39
40# Optimization levels
41config("optimize_debugging") {
42 cflags = [ "-Og" ]
43 ldflags = cflags
44}
45
46config("optimize_speed") {
47 cflags = [ "-O2" ]
48 ldflags = cflags
49}
50
51config("optimize_more_speed") {
52 cflags = [ "-O3" ]
53 ldflags = cflags
54}
55
56config("optimize_size") {
57 cflags = [ "-Os" ]
58 ldflags = cflags
59}
60
Alexei Frolov1a82c142019-10-31 17:37:12 -070061# Standard compiler flags to reduce output binary size.
62config("reduced_size") {
63 cflags = [
64 "-fno-common",
65 "-fno-exceptions",
66 "-ffunction-sections",
67 "-fdata-sections",
68 ]
69 cflags_cc = [ "-fno-rtti" ]
70}
71
72config("strict_warnings") {
73 cflags = [
74 "-Wall",
75 "-Wextra",
Ewout van Bekkumb4f95982020-10-15 11:10:51 -070076 "-Wimplicit-fallthrough",
Ewout van Bekkum7a436e02020-10-16 11:49:32 -070077 "-Wcast-qual",
Ewout van Bekkume4d7b692020-10-15 13:12:30 -070078 "-Wundef",
Ewout van Bekkumc9759dc2020-10-15 21:22:08 -070079 "-Wpointer-arith",
Keir Mierle243e32a2019-11-05 10:29:26 -080080
Wyatt Hepler979890d2019-11-06 17:17:45 -080081 # Make all warnings errors, except for the exemptions below.
82 "-Werror",
83 "-Wno-error=cpp", # preprocessor #warning statement
84 "-Wno-error=deprecated-declarations", # [[deprecated]] attribute
Alexei Frolov1a82c142019-10-31 17:37:12 -070085 ]
Wyatt Hepler1919c642019-12-06 10:06:13 -080086 cflags_cc = [ "-Wnon-virtual-dtor" ]
Alexei Frolov1a82c142019-10-31 17:37:12 -070087}
88
Armando Montanez888370d2020-05-01 18:29:22 -070089# This config contains warnings that we don't necessarily recommend projects
90# enable, but are enabled for upstream Pigweed for maximum project
91# compatibility.
92config("extra_strict_warnings") {
Ewout van Bekkum2c622832020-10-16 13:49:57 -070093 cflags = [
94 "-Wshadow",
95 "-Wredundant-decls",
96 ]
Armando Montanez888370d2020-05-01 18:29:22 -070097}
98
Wyatt Hepler818e3312020-01-16 14:19:21 -080099config("cpp11") {
100 cflags_cc = [ "-std=c++11" ]
101}
102
103config("cpp14") {
104 cflags_cc = [ "-std=c++14" ]
105}
106
Alexei Frolov1a82c142019-10-31 17:37:12 -0700107config("cpp17") {
Wyatt Hepler979890d2019-11-06 17:17:45 -0800108 cflags_cc = [
109 "-std=c++17",
110
111 # Allow uses of the register keyword, which may appear in C headers.
112 "-Wno-register",
113 ]
Alexei Frolov1a82c142019-10-31 17:37:12 -0700114}
115
Wyatt Heplerae222dc2020-10-14 10:46:27 -0700116# This empty target is used as the default value for module configurations.
117# Projects may set pw_build_DEFAULT_MODULE_CONFIG to a different GN target that
118# overrides modules' configuration options via macro definitions or a header
119# forcibly included with `-include`.
120group("empty") {
121}
122
Wyatt Heplerd7dc6552020-10-21 16:16:21 -0700123pool("pip_pool") {
124 depth = 1
125}
126
Rob Mohr49de4922019-12-10 20:10:41 -0800127pw_doc_group("docs") {
Rob Mohra0ba54f2020-02-27 11:43:49 -0800128 sources = [ "docs.rst" ]
Rob Mohr49de4922019-12-10 20:10:41 -0800129}
Alexei Frolovc15a9882019-12-23 14:29:02 -0800130
131# Pool to limit a single thread to download external Go packages at a time.
132pool("go_download_pool") {
133 depth = 1
134}