Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Side by Side Diff: build/build_header.h

Issue 1458653002: New build flag system, convert Google Now flag (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | build/build_header.gni » ('j') | build/build_header.gni » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
Mark Mentovai 2015/11/19 21:52:55 If this defines BUILDFLAG() as the primary macro,
Mark Mentovai 2015/11/19 21:53:26 In the CL description, capitalize Google Now, beca
brettw 2015/11/20 00:02:37 It defines BUILDFLAG and BUILDVAR, and I was gener
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef BASE_BUILD_HEADER_H_
Mark Mentovai 2015/11/19 21:52:55 BUILD_BUILD_HEADER_H_ here and in two other places
6 #define BASE_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".
12 //
13 // This is for use with headers generated by write_build_header.py.
14
15 #define BUILDFLAG_CAT(a, b) a ## b
16 #define BUILDFLAG_CAT2(a, b) BUILDFLAG_CAT(a, b)
Mark Mentovai 2015/11/19 21:52:55 I recognize this pattern (although I doubt most de
brettw 2015/11/20 00:02:37 This stuff is all removed now. Yay!
17
18 // These allow the code below to have an expression evaluate to 1 if the value
19 // is 0 or 1, and 0 if it's undefined or a different value.
20 #define BUILDFLAG_DEFINE_CHECK_0 1
21 #define BUILDFLAG_DEFINE_CHECK_1 1
22
23 // Accessor for boolean values. Throws an error if undefined. Since the
Mark Mentovai 2015/11/19 21:52:55 “if flag is undefined”
24 // invocation of a #define can't normally throw an error, emulate that by
Mark Mentovai 2015/11/19 21:52:55 of a macro
25 // forcing a divide-by-0 in the preprocessor.
26 #define BUILDFLAG(flag) (BUILDFLAG_CAT2(BUILDFLAG_FLAG_VALUE_, flag) / BUILDFLAG _CAT2(BUILDFLAG_DEFINE_CHECK_, BUILDFLAG_CAT2(BUILDFLAG_FLAG_VALUE_, flag))) // If you see a division by 0 it means your flag is undefined and you're missing t he header.
Mark Mentovai 2015/11/19 21:52:55 I believe that this can be simplified by using def
Mark Mentovai 2015/11/19 21:52:55 Can we name this CR_BUILDFLAG to provide some semb
brettw 2015/11/20 00:02:37 I thought about CR_* and decided against it. I can
brettw 2015/11/20 00:02:37 This works. I like your way.
brettw 2015/11/20 04:10:39 Scratch that, Visual Studio doesn't like this. I s
spang 2015/11/20 19:00:24 Was #if BUILDFLAG_ENABLE_FOO() considered? It's
27
28 // For flags where you need to know the value.
29 #define BUILDVAR(var) (BUILDFLAG_VAR_VALUE_##var)
Mark Mentovai 2015/11/19 21:52:55 Having both BUILDFLAG_FLAG_VALUE_* and BUILDFLAG_V
30
31 #endif // BASE_BUILD_HEADER_H_
Mark Mentovai 2015/11/19 21:52:55 After I read this file, I saw that you had more do
OLDNEW
« no previous file with comments | « no previous file | build/build_header.gni » ('j') | build/build_header.gni » ('J')

Powered by Google App Engine
This is Rietveld 408576698