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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | build/build_header.gni » ('j') | build/build_header.gni » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/build_header.h
diff --git a/build/build_header.h b/build/build_header.h
new file mode 100644
index 0000000000000000000000000000000000000000..3f99c912e31626d61a3c3d5e89ef224c232b0b07
--- /dev/null
+++ b/build/build_header.h
@@ -0,0 +1,31 @@
+// 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
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef BASE_BUILD_HEADER_H_
Mark Mentovai 2015/11/19 21:52:55 BUILD_BUILD_HEADER_H_ here and in two other places
+#define BASE_BUILD_HEADER_H_
+
+// These macros un-mangle the names of the build flags in a way that looks
+// natural, and gives errors if the flag is not defined. Normally in the
+// preprocessor it's easy to make mistakes that interpret "you haven't done
+// the setup to know what the flag is" as "flag is off".
+//
+// This is for use with headers generated by write_build_header.py.
+
+#define BUILDFLAG_CAT(a, b) a ## b
+#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!
+
+// These allow the code below to have an expression evaluate to 1 if the value
+// is 0 or 1, and 0 if it's undefined or a different value.
+#define BUILDFLAG_DEFINE_CHECK_0 1
+#define BUILDFLAG_DEFINE_CHECK_1 1
+
+// Accessor for boolean values. Throws an error if undefined. Since the
Mark Mentovai 2015/11/19 21:52:55 “if flag is undefined”
+// invocation of a #define can't normally throw an error, emulate that by
Mark Mentovai 2015/11/19 21:52:55 of a macro
+// forcing a divide-by-0 in the preprocessor.
+#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 the 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
+
+// For flags where you need to know the value.
+#define BUILDVAR(var) (BUILDFLAG_VAR_VALUE_##var)
Mark Mentovai 2015/11/19 21:52:55 Having both BUILDFLAG_FLAG_VALUE_* and BUILDFLAG_V
+
+#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
« 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