This is a reland of commit 8f7e0bcec0,
except for the actual change to build/write_buildflag_header.py
Original change's description:
> build: Be stricter about buildflag values
>
> We don't want buildflag headers to contain arbitrary expressions
>
> A recent change had used
>
> "ENABLE_FOO=$enable_foo_1 || $enable_foo_2",
>
> which `gn` turned into `true || false`, which write_buildflag_header.py
> wrote to a generated header verbatim. Checking
>
> #if BUILDFLAG(ENABLE_FOO)
>
> would then expand to
>
> #if true || false
>
> but `true` and `false` are only valid in C++, not C.
>
> (...and buildflag headers get included in resource scripts, and
> rc.exe preprocesses using C semantics, not C++ semantics, and hence
> silently does the wrong thing.)
>
> So only allow `true` and `false` (which buildflag_headers.py maps
> to 1 and 0 in its output), and string literals, for things like
> ALTERNATE_CDM_STORAGE_ID_KEY. We could also consider (re)allowing
> int literals, but those silently evaluate to truthy or falsy values
> in preprocessor expressions -- several places were checking
> `#if BUILDFLAG(CHROME_PGO)` when they morally mean
> `#if BUILDFLAG(CHROME_PGO) == 1`. Since we currently have no use
> cases for arbitrary int values in buildflags, disallow them.
> String literals don't have this problem.
>
> The main motivation is to block things like `true && false` and
> `false || true`.
>
> (Convert all `=1` / `=0` to `=true` / `=false` to make this work.
> We must support `true` and `false` for the very common
> `FOO=$foo` use case.)
>
> The CHROME_PGO issue above is fine since we also checked
> BUILDFLAG(CLANG_PROFILING_INSIDE_SANDBOX) at the same time, and
> that's only set in the profiling phase, but it's still confusing.
> So use two boolean build flags for CHROME_PGO instead. (No behavior
> change.)
>
> Bug: 403123830
> Change-Id: I7a6cedf063824b280f1fe03a07586cf77f649b29
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6371822
> Commit-Queue: Nico Weber <thakis@chromium.org>
> Owners-Override: Nico Weber <thakis@chromium.org>
> Reviewed-by: Hans Wennborg <hans@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1435044}
Bug: 403123830
Change-Id: I2dcea00d45405783848d089ce37d52b0294a7189
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6372328
Reviewed-by: Hans Wennborg <hans@chromium.org>
Owners-Override: Nico Weber <thakis@chromium.org>
Commit-Queue: Nico Weber <thakis@chromium.org>
Auto-Submit: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1435395}