OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
Mark Mentovai
2015/11/24 14:33:33
Optional, do it if you like it to prevent direct #
brettw
2015/11/24 23:36:01
I think directly including this file is both usele
| |
5 #ifndef BUILD_BUILD_HEADER_H_ | |
6 #define BUILD_BUILD_HEADER_H_ | |
7 | |
8 // These macros un-mangle the names of the build flags in a way that looks | |
9 // natural, and gives errors if the flag is not defined. Normally in the | |
10 // preprocessor it's easy to make mistakes that interpret "you haven't done | |
11 // the setup to know what the flag is" as "flag is off". Normally you would | |
12 // include the generated header rather than include this file directly. | |
13 // | |
14 // This is for use with generated headers. See build/build_header.gni. | |
15 | |
16 // This dance of two macros does a concatenation of two preprocessor args using | |
17 // ## doubly indirectly because using ## directly prevents macros in that | |
18 // parameter from being expanded. | |
19 #define BUILDFLAG_CAT_INDIRECT(a, b) a ## b | |
20 #define BUILDFLAG_CAT(a, b) BUILDFLAG_CAT_INDIRECT(a, b) | |
21 | |
22 // Accessor for build flags. | |
Mark Mentovai
2015/11/24 14:33:33
Since the former BUILDVAR is now covered by this,
| |
23 // | |
24 // To test for a value, if the build file specifies: | |
25 // | |
26 // ENABLE_FOO=true | |
27 // | |
28 // Then you would check at build-time in source code with: | |
29 // | |
30 // #include "foo_flags.h" // The header the build file specified. | |
31 // | |
32 // #if BUILDFLAG(ENABLE_FOO) | |
33 // ... | |
34 // #endif | |
35 // | |
36 // There will no #define called ENABLE_FOO so if you accidentally test for | |
37 // whether that is defined, it will always be negative. | |
38 // | |
39 // Because the flag is accessed as a preprocessor macro with (), an error | |
40 // will be thrown if the proper header defining the internal flag value has | |
41 // not been included. | |
42 #define BUILDFLAG(flag) (BUILDFLAG_CAT(BUILDFLAG_INTERNAL_, flag)()) | |
Mark Mentovai
2015/11/24 14:33:33
I think that this can be buildflag.h now that the
brettw
2015/11/24 23:36:01
Done. I renamed the build scripts buildflag_header
| |
43 | |
44 #endif // BUILD_BUILD_HEADER_H_ | |
OLD | NEW |