
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}
Chromium
Chromium is an open-source browser project that aims to build a safer, faster, and more stable way for all users to experience the web.
The project's web site is https://www.chromium.org.
To check out the source code locally, don't use git clone
! Instead,
follow the instructions on how to get the code.
Documentation in the source is rooted in docs/README.md.
Learn how to Get Around the Chromium Source Code Directory Structure.
For historical reasons, there are some small top level directories. Now the guidance is that new top level directories are for product (e.g. Chrome, Android WebView, Ash). Even if these products have multiple executables, the code should be in subdirectories of the product.
If you found a bug, please file it at https://crbug.com/new.