blob: 777ef224e0bf712ecacb0d44fcd3fef38b5f1927 [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
Wyatt Heplera2970c52021-02-02 14:47:22 -080017import("$dir_pw_build/python.gni")
Armando Montanezfb3d3fb2020-06-09 18:12:12 -070018import("$dir_pw_docgen/docs.gni")
Wyatt Heplerd49f8fe2020-10-15 10:13:47 -070019
Wyatt Hepler0a6f7632020-10-29 09:08:19 -070020# IMPORTANT: The compilation flags in this file must be kept in sync with
21# the CMake flags pw_build/CMakeLists.txt.
22
Alexei Frolov844ff0f2020-05-06 12:15:29 -070023config("colorize_output") {
24 cflags = [
25 # Colorize output. Ninja's Clang invocation disables color by default.
26 "-fdiagnostics-color",
Wyatt Heplerb9db09f2020-01-27 17:40:08 -080027 ]
Alexei Frolov844ff0f2020-05-06 12:15:29 -070028 ldflags = cflags
Wyatt Heplerb9db09f2020-01-27 17:40:08 -080029}
30
31config("debugging") {
32 # Enable debug symbol generation. This has no effect on final code size.
33 cflags = [ "-g" ]
34}
35
Alexei Frolov844ff0f2020-05-06 12:15:29 -070036config("extra_debugging") {
37 # Include things like macro expansion in debug info.
38 cflags = [ "-g3" ]
39}
40
41# Optimization levels
42config("optimize_debugging") {
43 cflags = [ "-Og" ]
44 ldflags = cflags
45}
46
47config("optimize_speed") {
48 cflags = [ "-O2" ]
49 ldflags = cflags
50}
51
52config("optimize_more_speed") {
53 cflags = [ "-O3" ]
54 ldflags = cflags
55}
56
57config("optimize_size") {
58 cflags = [ "-Os" ]
59 ldflags = cflags
60}
61
Alexei Frolov1a82c142019-10-31 17:37:12 -070062# Standard compiler flags to reduce output binary size.
63config("reduced_size") {
64 cflags = [
65 "-fno-common",
66 "-fno-exceptions",
67 "-ffunction-sections",
68 "-fdata-sections",
69 ]
70 cflags_cc = [ "-fno-rtti" ]
71}
72
73config("strict_warnings") {
74 cflags = [
75 "-Wall",
76 "-Wextra",
Ewout van Bekkumb4f95982020-10-15 11:10:51 -070077 "-Wimplicit-fallthrough",
Ewout van Bekkum7a436e02020-10-16 11:49:32 -070078 "-Wcast-qual",
Ewout van Bekkume4d7b692020-10-15 13:12:30 -070079 "-Wundef",
Ewout van Bekkumc9759dc2020-10-15 21:22:08 -070080 "-Wpointer-arith",
Keir Mierle243e32a2019-11-05 10:29:26 -080081
Wyatt Hepler979890d2019-11-06 17:17:45 -080082 # Make all warnings errors, except for the exemptions below.
83 "-Werror",
84 "-Wno-error=cpp", # preprocessor #warning statement
85 "-Wno-error=deprecated-declarations", # [[deprecated]] attribute
Alexei Frolov1a82c142019-10-31 17:37:12 -070086 ]
Wyatt Hepler1919c642019-12-06 10:06:13 -080087 cflags_cc = [ "-Wnon-virtual-dtor" ]
Alexei Frolov1a82c142019-10-31 17:37:12 -070088}
89
Armando Montanez888370d2020-05-01 18:29:22 -070090# This config contains warnings that we don't necessarily recommend projects
91# enable, but are enabled for upstream Pigweed for maximum project
92# compatibility.
93config("extra_strict_warnings") {
Ewout van Bekkum2c622832020-10-16 13:49:57 -070094 cflags = [
95 "-Wshadow",
96 "-Wredundant-decls",
97 ]
Wyatt Hepler5a14a662021-03-08 11:22:02 -080098 cflags_c = [ "-Wstrict-prototypes" ]
Armando Montanez888370d2020-05-01 18:29:22 -070099}
100
Wyatt Hepler818e3312020-01-16 14:19:21 -0800101config("cpp11") {
102 cflags_cc = [ "-std=c++11" ]
103}
104
105config("cpp14") {
106 cflags_cc = [ "-std=c++14" ]
107}
108
Alexei Frolov1a82c142019-10-31 17:37:12 -0700109config("cpp17") {
Wyatt Hepler979890d2019-11-06 17:17:45 -0800110 cflags_cc = [
111 "-std=c++17",
112
113 # Allow uses of the register keyword, which may appear in C headers.
114 "-Wno-register",
115 ]
Alexei Frolov1a82c142019-10-31 17:37:12 -0700116}
117
Wyatt Heplerae222dc2020-10-14 10:46:27 -0700118# This empty target is used as the default value for module configurations.
119# Projects may set pw_build_DEFAULT_MODULE_CONFIG to a different GN target that
120# overrides modules' configuration options via macro definitions or a header
121# forcibly included with `-include`.
122group("empty") {
123}
124
Wyatt Heplerd7dc6552020-10-21 16:16:21 -0700125pool("pip_pool") {
126 depth = 1
127}
128
Rob Mohr0cf27cb2021-03-08 12:13:54 -0800129pool("copy_from_cipd_pool") {
130 depth = 1
131}
132
Wyatt Heplera2970c52021-02-02 14:47:22 -0800133# Requirements for the pw_python_package lint targets.
134pw_python_requirements("python_lint") {
135 requirements = [
Wyatt Hepleraf853ea2021-03-09 19:09:54 -0800136 "build",
Wyatt Heplera2970c52021-02-02 14:47:22 -0800137 "mypy==0.800",
138 "pylint==2.6.0",
139 ]
140}
141
Rob Mohr49de4922019-12-10 20:10:41 -0800142pw_doc_group("docs") {
Wyatt Heplerb3ea9802021-02-23 09:46:09 -0800143 sources = [
144 "docs.rst",
145 "python.rst",
146 ]
Rob Mohr49de4922019-12-10 20:10:41 -0800147}
Alexei Frolovc15a9882019-12-23 14:29:02 -0800148
149# Pool to limit a single thread to download external Go packages at a time.
150pool("go_download_pool") {
151 depth = 1
152}