mirror of
https://github.com/aphrody-labs/gn.git
synced 2026-10-14 05:09:21 +00:00
Add new experimental_collect_validations_metadata .gn variable
And associated --experimental-collect-validations-metadata switch. This is not connected to anything right now. Bug: 566346002 Change-Id: Id374c42d29cca4d6cd62367596dc81f14fa5198e Reviewed-on: https://gn-review.googlesource.com/c/gn/+/27084 Reviewed-by: Takuto Ikuta <tikuta@google.com> Commit-Queue: David Turner <digit@google.com>
This commit is contained in:
1 parent
31dd2c2b8e
commit
0c19d708df
5 files changed
+64
No files matched your search
@@ -7828,6 +7828,14 @@
|
||||
A boolean flag that can be set to generate Ninja files that use phony
|
||||
rules instead of stamp files whenever possible. This results in smaller
|
||||
Ninja build plans, but requires at least Ninja 1.11.
|
||||
|
||||
experimental_collect_validations_metadata [optional]
|
||||
NOTE: This flag is experimental and will be removed in the future.
|
||||
|
||||
A boolean flag that determines whether generated_file() metadata walks
|
||||
should include validations targets's metadata. This is false by default
|
||||
but may be required temporarily by the Fuchsia build. See
|
||||
https://gn.g-issues.chromium.org/issues/566346002 for details.
|
||||
```
|
||||
|
||||
#### **Example .gn file contents**
|
||||
@@ -8880,6 +8888,7 @@
|
||||
* --dotfile: Override the name of the ".gn" file.
|
||||
* --enumerate-files-with-git: Use git to list files.
|
||||
* --error-limit: Limit the number of errors or warnings to print.
|
||||
* --experimental-collect-validations-metadata: Collect metadata from validations.
|
||||
* --fail-on-unused-args: Treat unused build args as fatal errors.
|
||||
* --format-width: Set the formatting width (default is 80)
|
||||
* --markdown: Write help output in the Markdown format.
|
||||
|
||||
@@ -165,6 +165,15 @@ class BuildSettings {
|
||||
allow_circular_includes_from_allowlist_ = std::move(list);
|
||||
}
|
||||
|
||||
// If true, all generated_file() metadata walks include metadata from
|
||||
// validations targets.
|
||||
bool experimental_collect_validations_metadata() const {
|
||||
return experimental_collect_validations_metadata_;
|
||||
}
|
||||
void set_experimental_collect_validations_metadata(bool value) {
|
||||
experimental_collect_validations_metadata_ = value;
|
||||
}
|
||||
|
||||
private:
|
||||
Label root_target_label_;
|
||||
std::vector<LabelPattern> root_patterns_;
|
||||
@@ -178,6 +187,7 @@ class BuildSettings {
|
||||
// See 40045b9 for the reason behind using 1.7.2 as the default version.
|
||||
Version ninja_required_version_{1, 7, 2};
|
||||
bool no_stamp_files_ = true;
|
||||
bool experimental_collect_validations_metadata_ = false;
|
||||
|
||||
SourceFile build_config_file_;
|
||||
SourceFile arg_file_template_path_;
|
||||
|
||||
@@ -260,6 +260,14 @@ Variables
|
||||
rules instead of stamp files whenever possible. This results in smaller
|
||||
Ninja build plans, but requires at least Ninja 1.11.
|
||||
|
||||
experimental_collect_validations_metadata [optional]
|
||||
NOTE: This flag is experimental and will be removed in the future.
|
||||
|
||||
A boolean flag that determines whether generated_file() metadata walks
|
||||
should include validations targets's metadata. This is false by default
|
||||
but may be required temporarily by the Fuchsia build. See
|
||||
https://gn.g-issues.chromium.org/issues/566346002 for details.
|
||||
|
||||
Example .gn file contents
|
||||
|
||||
buildconfig = "//build/config/BUILDCONFIG.gn"
|
||||
@@ -1302,5 +1310,23 @@ bool Setup::FillOtherConfig(const base::CommandLine& cmdline, Err* err) {
|
||||
export_compile_commands_.push_back(std::move(pat));
|
||||
}
|
||||
|
||||
// Collect validations metadata during generate_file() walks.
|
||||
// See https://gn.g-issues.chromium.org/issues/566346002
|
||||
if (cmdline.HasSwitch(switches::kExperimentalCollectValidationsMetadata)) {
|
||||
build_settings_.set_experimental_collect_validations_metadata(true);
|
||||
} else {
|
||||
const Value* experimental_collect_validations_metadata_value =
|
||||
dotfile_scope_.GetValue("experimental_collect_validations_metadata",
|
||||
true);
|
||||
if (experimental_collect_validations_metadata_value) {
|
||||
if (!experimental_collect_validations_metadata_value->VerifyTypeIs(
|
||||
Value::BOOLEAN, err)) {
|
||||
return false;
|
||||
}
|
||||
build_settings_.set_experimental_collect_validations_metadata(
|
||||
experimental_collect_validations_metadata_value->boolean_value());
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -88,6 +88,20 @@ const char kErrorLimit_Help[] =
|
||||
and warnings without any limit.
|
||||
)";
|
||||
|
||||
const char kExperimentalCollectValidationsMetadata[] =
|
||||
"experimental-collect-validations-metadata";
|
||||
const char kExperimentalCollectValidationsMetadata_HelpShort[] =
|
||||
"--experimental-collect-validations-metadata: Collect metadata from "
|
||||
"validations.";
|
||||
const char kExperimentalCollectValidationsMetadata_Help[] =
|
||||
R"(--experimental-collect-validations-metadata: Collect metadata from validations.
|
||||
|
||||
Sets the default value of generated_file() collect_validations_metadata
|
||||
argument to true (default is false).
|
||||
|
||||
This switch is experimental and will be removed in the future.
|
||||
See https://issuetracker.google.com/566346002.
|
||||
)";
|
||||
const char kFailOnUnusedArgs[] = "fail-on-unused-args";
|
||||
const char kFailOnUnusedArgs_HelpShort[] =
|
||||
"--fail-on-unused-args: Treat unused build args as fatal errors.";
|
||||
@@ -373,6 +387,7 @@ const SwitchInfoMap& GetSwitches() {
|
||||
INSERT_VARIABLE(Dotfile)
|
||||
INSERT_VARIABLE(EnumerateFilesWithGit)
|
||||
INSERT_VARIABLE(ErrorLimit)
|
||||
INSERT_VARIABLE(ExperimentalCollectValidationsMetadata)
|
||||
INSERT_VARIABLE(FailOnUnusedArgs)
|
||||
INSERT_VARIABLE(FormatWidth)
|
||||
INSERT_VARIABLE(Markdown)
|
||||
|
||||
@@ -46,6 +46,10 @@ extern const char kErrorLimit[];
|
||||
extern const char kErrorLimit_HelpShort[];
|
||||
extern const char kErrorLimit_Help[];
|
||||
|
||||
extern const char kExperimentalCollectValidationsMetadata[];
|
||||
extern const char kExperimentalCollectValidationsMetadata_HelpShort[];
|
||||
extern const char kExperimentalCollectValidationsMetadata_Help[];
|
||||
|
||||
extern const char kFailOnUnusedArgs[];
|
||||
extern const char kFailOnUnusedArgs_HelpShort[];
|
||||
extern const char kFailOnUnusedArgs_Help[];
|
||||
|
||||
Reference in new issue
Block a user