blob: 7e9ec5442600b052fd2dbcb6b37433b2afe01ddc [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 -070015# gn-format disable
16import("//build_overrides/pigweed.gni")
Rob Mohr49de4922019-12-10 20:10:41 -080017
Armando Montanezfb3d3fb2020-06-09 18:12:12 -070018import("$dir_pigweed/legacy_target.gni")
19import("$dir_pw_docgen/docs.gni")
Alexei Frolov844ff0f2020-05-06 12:15:29 -070020config("colorize_output") {
21 cflags = [
22 # Colorize output. Ninja's Clang invocation disables color by default.
23 "-fdiagnostics-color",
Wyatt Heplerb9db09f2020-01-27 17:40:08 -080024 ]
Alexei Frolov844ff0f2020-05-06 12:15:29 -070025 ldflags = cflags
Wyatt Heplerb9db09f2020-01-27 17:40:08 -080026}
27
28config("debugging") {
29 # Enable debug symbol generation. This has no effect on final code size.
30 cflags = [ "-g" ]
31}
32
Alexei Frolov844ff0f2020-05-06 12:15:29 -070033config("extra_debugging") {
34 # Include things like macro expansion in debug info.
35 cflags = [ "-g3" ]
36}
37
38# Optimization levels
39config("optimize_debugging") {
40 cflags = [ "-Og" ]
41 ldflags = cflags
42}
43
44config("optimize_speed") {
45 cflags = [ "-O2" ]
46 ldflags = cflags
47}
48
49config("optimize_more_speed") {
50 cflags = [ "-O3" ]
51 ldflags = cflags
52}
53
54config("optimize_size") {
55 cflags = [ "-Os" ]
56 ldflags = cflags
57}
58
Alexei Frolov1a82c142019-10-31 17:37:12 -070059# Standard compiler flags to reduce output binary size.
60config("reduced_size") {
61 cflags = [
62 "-fno-common",
63 "-fno-exceptions",
64 "-ffunction-sections",
65 "-fdata-sections",
66 ]
67 cflags_cc = [ "-fno-rtti" ]
68}
69
70config("strict_warnings") {
71 cflags = [
72 "-Wall",
73 "-Wextra",
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") {
87 cflags = [ "-Wshadow" ]
88}
89
Wyatt Hepler818e3312020-01-16 14:19:21 -080090config("cpp11") {
91 cflags_cc = [ "-std=c++11" ]
92}
93
94config("cpp14") {
95 cflags_cc = [ "-std=c++14" ]
96}
97
Alexei Frolov1a82c142019-10-31 17:37:12 -070098config("cpp17") {
Wyatt Hepler979890d2019-11-06 17:17:45 -080099 cflags_cc = [
100 "-std=c++17",
101
102 # Allow uses of the register keyword, which may appear in C headers.
103 "-Wno-register",
104 ]
Alexei Frolov1a82c142019-10-31 17:37:12 -0700105}
106
Rob Mohr49de4922019-12-10 20:10:41 -0800107pw_doc_group("docs") {
Rob Mohra0ba54f2020-02-27 11:43:49 -0800108 sources = [ "docs.rst" ]
Rob Mohr49de4922019-12-10 20:10:41 -0800109}
Alexei Frolovc15a9882019-12-23 14:29:02 -0800110
111# Pool to limit a single thread to download external Go packages at a time.
112pool("go_download_pool") {
113 depth = 1
114}