| Index: tools/gn/value_extractors.cc
|
| diff --git a/tools/gn/value_extractors.cc b/tools/gn/value_extractors.cc
|
| index 9e6a37edc95c6c27478b0434ddc7f49d6ad9d645..37ee767aeca8ab03755e4f1799fd23da02f75bbb 100644
|
| --- a/tools/gn/value_extractors.cc
|
| +++ b/tools/gn/value_extractors.cc
|
| @@ -58,8 +58,6 @@ bool ListValueUniqueExtractor(const Value& value,
|
| return true;
|
| }
|
|
|
| -// This extractor rejects files with system-absolute file paths. If we need
|
| -// that in the future, we'll have to add some flag to control this.
|
| struct RelativeFileConverter {
|
| RelativeFileConverter(const BuildSettings* build_settings_in,
|
| const SourceDir& current_dir_in)
|
| @@ -70,14 +68,7 @@ struct RelativeFileConverter {
|
| if (!v.VerifyTypeIs(Value::STRING, err))
|
| return false;
|
| *out = current_dir.ResolveRelativeFile(v.string_value(),
|
| - build_settings->root_path_utf8());
|
| - if (out->is_system_absolute()) {
|
| - *err = Err(v, "System-absolute file path.",
|
| - "You can't list a system-absolute file path here. Please include "
|
| - "only files in\nthe source tree. Maybe you meant to begin with two "
|
| - "slashes to indicate an\nabsolute path in the source tree?");
|
| - return false;
|
| - }
|
| + build_settings->root_path());
|
| return true;
|
| }
|
| const BuildSettings* build_settings;
|
| @@ -94,7 +85,7 @@ struct RelativeDirConverter {
|
| if (!v.VerifyTypeIs(Value::STRING, err))
|
| return false;
|
| *out = current_dir.ResolveRelativeDir(v.string_value(),
|
| - build_settings->root_path_utf8());
|
| + build_settings->root_path());
|
| return true;
|
| }
|
| const BuildSettings* build_settings;
|
| @@ -104,34 +95,41 @@ struct RelativeDirConverter {
|
| // Fills in a label.
|
| template<typename T> struct LabelResolver {
|
| LabelResolver(const SourceDir& current_dir_in,
|
| - const Label& current_toolchain_in)
|
| + const Label& current_toolchain_in,
|
| + const base::FilePath& source_root_in)
|
| : current_dir(current_dir_in),
|
| - current_toolchain(current_toolchain_in) {}
|
| + current_toolchain(current_toolchain_in),
|
| + source_root(source_root_in) {}
|
| bool operator()(const Value& v, Label* out, Err* err) const {
|
| if (!v.VerifyTypeIs(Value::STRING, err))
|
| return false;
|
| - *out = Label::Resolve(current_dir, current_toolchain, v, err);
|
| + *out = Label::Resolve(current_dir, current_toolchain, v, source_root, err);
|
| return !err->has_error();
|
| }
|
| const SourceDir& current_dir;
|
| const Label& current_toolchain;
|
| + const base::FilePath& source_root;
|
| };
|
|
|
| // Fills the label part of a LabelPtrPair, leaving the pointer null.
|
| template<typename T> struct LabelPtrResolver {
|
| LabelPtrResolver(const SourceDir& current_dir_in,
|
| - const Label& current_toolchain_in)
|
| + const Label& current_toolchain_in,
|
| + const base::FilePath& source_root_in)
|
| : current_dir(current_dir_in),
|
| - current_toolchain(current_toolchain_in) {}
|
| + current_toolchain(current_toolchain_in),
|
| + source_root(source_root_in) {}
|
| bool operator()(const Value& v, LabelPtrPair<T>* out, Err* err) const {
|
| if (!v.VerifyTypeIs(Value::STRING, err))
|
| return false;
|
| - out->label = Label::Resolve(current_dir, current_toolchain, v, err);
|
| + out->label = Label::Resolve(current_dir, current_toolchain, v, source_root,
|
| + err);
|
| out->origin = v.origin();
|
| return !err->has_error();
|
| }
|
| const SourceDir& current_dir;
|
| const Label& current_toolchain;
|
| + const base::FilePath& source_root;
|
| };
|
|
|
| } // namespace
|
| @@ -169,44 +167,52 @@ bool ExtractListOfRelativeDirs(const BuildSettings* build_settings,
|
| RelativeDirConverter(build_settings, current_dir));
|
| }
|
|
|
| -bool ExtractListOfLabels(const Value& value,
|
| +bool ExtractListOfLabels(const BuildSettings* build_settings,
|
| + const Value& value,
|
| const SourceDir& current_dir,
|
| const Label& current_toolchain,
|
| LabelTargetVector* dest,
|
| Err* err) {
|
| return ListValueExtractor(value, dest, err,
|
| - LabelPtrResolver<Target>(current_dir,
|
| - current_toolchain));
|
| + LabelPtrResolver<Target>(
|
| + current_dir, current_toolchain,
|
| + build_settings->root_path()));
|
| }
|
|
|
| -bool ExtractListOfUniqueLabels(const Value& value,
|
| +bool ExtractListOfUniqueLabels(const BuildSettings* build_settings,
|
| + const Value& value,
|
| const SourceDir& current_dir,
|
| const Label& current_toolchain,
|
| UniqueVector<Label>* dest,
|
| Err* err) {
|
| return ListValueUniqueExtractor(value, dest, err,
|
| - LabelResolver<Config>(current_dir,
|
| - current_toolchain));
|
| + LabelResolver<Config>(
|
| + current_dir, current_toolchain,
|
| + build_settings->root_path()));
|
| }
|
|
|
| -bool ExtractListOfUniqueLabels(const Value& value,
|
| +bool ExtractListOfUniqueLabels(const BuildSettings* build_settings,
|
| + const Value& value,
|
| const SourceDir& current_dir,
|
| const Label& current_toolchain,
|
| UniqueVector<LabelConfigPair>* dest,
|
| Err* err) {
|
| return ListValueUniqueExtractor(value, dest, err,
|
| - LabelPtrResolver<Config>(current_dir,
|
| - current_toolchain));
|
| + LabelPtrResolver<Config>(
|
| + current_dir, current_toolchain,
|
| + build_settings->root_path()));
|
| }
|
|
|
| -bool ExtractListOfUniqueLabels(const Value& value,
|
| +bool ExtractListOfUniqueLabels(const BuildSettings* build_settings,
|
| + const Value& value,
|
| const SourceDir& current_dir,
|
| const Label& current_toolchain,
|
| UniqueVector<LabelTargetPair>* dest,
|
| Err* err) {
|
| return ListValueUniqueExtractor(value, dest, err,
|
| - LabelPtrResolver<Target>(current_dir,
|
| - current_toolchain));
|
| + LabelPtrResolver<Target>(
|
| + current_dir, current_toolchain,
|
| + build_settings->root_path()));
|
| }
|
|
|
| bool ExtractRelativeFile(const BuildSettings* build_settings,
|
|
|