Adam Lesinski | efeb7af | 2017-08-02 14:57:43 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include "test/Builders.h" |
| 18 | |
Jeremy Meyer | 56f36e8 | 2022-05-20 20:35:42 +0000 | [diff] [blame] | 19 | #include "Diagnostics.h" |
Adam Lesinski | efeb7af | 2017-08-02 14:57:43 -0700 | [diff] [blame] | 20 | #include "android-base/logging.h" |
| 21 | #include "androidfw/StringPiece.h" |
Adam Lesinski | 0045116 | 2017-10-03 07:44:08 -0700 | [diff] [blame] | 22 | #include "io/StringStream.h" |
Adam Lesinski | efeb7af | 2017-08-02 14:57:43 -0700 | [diff] [blame] | 23 | #include "test/Common.h" |
| 24 | #include "util/Util.h" |
| 25 | |
Shane Farmer | efe4539 | 2017-08-21 14:39:28 -0700 | [diff] [blame] | 26 | using ::aapt::configuration::Abi; |
| 27 | using ::aapt::configuration::AndroidSdk; |
Shane Farmer | cb6c3f9 | 2017-11-27 13:19:36 -0800 | [diff] [blame] | 28 | using ::aapt::configuration::ConfiguredArtifact; |
Shane Farmer | 78c43d7 | 2017-12-04 09:08:38 -0800 | [diff] [blame] | 29 | using ::aapt::configuration::GetOrCreateGroup; |
Adam Lesinski | efeb7af | 2017-08-02 14:57:43 -0700 | [diff] [blame] | 30 | using ::aapt::io::StringInputStream; |
MÃ¥rten Kongstad | 24c9aa6 | 2018-06-20 08:46:41 +0200 | [diff] [blame] | 31 | using ::android::ConfigDescription; |
Adam Lesinski | efeb7af | 2017-08-02 14:57:43 -0700 | [diff] [blame] | 32 | using ::android::StringPiece; |
| 33 | |
| 34 | namespace aapt { |
| 35 | namespace test { |
| 36 | |
Yurii Zubrytskyi | a577514 | 2022-11-02 17:49:49 -0700 | [diff] [blame] | 37 | ResourceTableBuilder& ResourceTableBuilder::AddSimple(StringPiece name, const ResourceId& id) { |
Adam Lesinski | efeb7af | 2017-08-02 14:57:43 -0700 | [diff] [blame] | 38 | return AddValue(name, id, util::make_unique<Id>()); |
| 39 | } |
| 40 | |
Yurii Zubrytskyi | a577514 | 2022-11-02 17:49:49 -0700 | [diff] [blame] | 41 | ResourceTableBuilder& ResourceTableBuilder::AddSimple(StringPiece name, |
Adam Lesinski | efeb7af | 2017-08-02 14:57:43 -0700 | [diff] [blame] | 42 | const ConfigDescription& config, |
| 43 | const ResourceId& id) { |
| 44 | return AddValue(name, config, id, util::make_unique<Id>()); |
| 45 | } |
| 46 | |
Yurii Zubrytskyi | a577514 | 2022-11-02 17:49:49 -0700 | [diff] [blame] | 47 | ResourceTableBuilder& ResourceTableBuilder::AddReference(StringPiece name, StringPiece ref) { |
Adam Lesinski | efeb7af | 2017-08-02 14:57:43 -0700 | [diff] [blame] | 48 | return AddReference(name, {}, ref); |
| 49 | } |
| 50 | |
Yurii Zubrytskyi | a577514 | 2022-11-02 17:49:49 -0700 | [diff] [blame] | 51 | ResourceTableBuilder& ResourceTableBuilder::AddReference(StringPiece name, const ResourceId& id, |
| 52 | StringPiece ref) { |
Adam Lesinski | efeb7af | 2017-08-02 14:57:43 -0700 | [diff] [blame] | 53 | return AddValue(name, id, util::make_unique<Reference>(ParseNameOrDie(ref))); |
| 54 | } |
| 55 | |
Yurii Zubrytskyi | a577514 | 2022-11-02 17:49:49 -0700 | [diff] [blame] | 56 | ResourceTableBuilder& ResourceTableBuilder::AddString(StringPiece name, StringPiece str) { |
Adam Lesinski | efeb7af | 2017-08-02 14:57:43 -0700 | [diff] [blame] | 57 | return AddString(name, {}, str); |
| 58 | } |
| 59 | |
Yurii Zubrytskyi | a577514 | 2022-11-02 17:49:49 -0700 | [diff] [blame] | 60 | ResourceTableBuilder& ResourceTableBuilder::AddString(StringPiece name, const ResourceId& id, |
| 61 | StringPiece str) { |
Adam Lesinski | efeb7af | 2017-08-02 14:57:43 -0700 | [diff] [blame] | 62 | return AddValue(name, id, util::make_unique<String>(table_->string_pool.MakeRef(str))); |
| 63 | } |
| 64 | |
Yurii Zubrytskyi | a577514 | 2022-11-02 17:49:49 -0700 | [diff] [blame] | 65 | ResourceTableBuilder& ResourceTableBuilder::AddString(StringPiece name, const ResourceId& id, |
Adam Lesinski | efeb7af | 2017-08-02 14:57:43 -0700 | [diff] [blame] | 66 | const ConfigDescription& config, |
Yurii Zubrytskyi | a577514 | 2022-11-02 17:49:49 -0700 | [diff] [blame] | 67 | StringPiece str) { |
Adam Lesinski | efeb7af | 2017-08-02 14:57:43 -0700 | [diff] [blame] | 68 | return AddValue(name, config, id, util::make_unique<String>(table_->string_pool.MakeRef(str))); |
| 69 | } |
| 70 | |
Yurii Zubrytskyi | a577514 | 2022-11-02 17:49:49 -0700 | [diff] [blame] | 71 | ResourceTableBuilder& ResourceTableBuilder::AddFileReference(StringPiece name, StringPiece path, |
Adam Lesinski | 8780eb6 | 2017-10-31 17:44:39 -0700 | [diff] [blame] | 72 | io::IFile* file) { |
| 73 | return AddFileReference(name, {}, path, file); |
Adam Lesinski | efeb7af | 2017-08-02 14:57:43 -0700 | [diff] [blame] | 74 | } |
| 75 | |
Yurii Zubrytskyi | a577514 | 2022-11-02 17:49:49 -0700 | [diff] [blame] | 76 | ResourceTableBuilder& ResourceTableBuilder::AddFileReference(StringPiece name, const ResourceId& id, |
| 77 | StringPiece path, io::IFile* file) { |
Adam Lesinski | 8780eb6 | 2017-10-31 17:44:39 -0700 | [diff] [blame] | 78 | auto file_ref = util::make_unique<FileReference>(table_->string_pool.MakeRef(path)); |
| 79 | file_ref->file = file; |
| 80 | return AddValue(name, id, std::move(file_ref)); |
Adam Lesinski | efeb7af | 2017-08-02 14:57:43 -0700 | [diff] [blame] | 81 | } |
| 82 | |
Yurii Zubrytskyi | a577514 | 2022-11-02 17:49:49 -0700 | [diff] [blame] | 83 | ResourceTableBuilder& ResourceTableBuilder::AddFileReference(StringPiece name, StringPiece path, |
Adam Lesinski | 8780eb6 | 2017-10-31 17:44:39 -0700 | [diff] [blame] | 84 | const ConfigDescription& config, |
| 85 | io::IFile* file) { |
| 86 | auto file_ref = util::make_unique<FileReference>(table_->string_pool.MakeRef(path)); |
| 87 | file_ref->file = file; |
| 88 | return AddValue(name, config, {}, std::move(file_ref)); |
Adam Lesinski | efeb7af | 2017-08-02 14:57:43 -0700 | [diff] [blame] | 89 | } |
| 90 | |
Yurii Zubrytskyi | a577514 | 2022-11-02 17:49:49 -0700 | [diff] [blame] | 91 | ResourceTableBuilder& ResourceTableBuilder::AddValue(StringPiece name, |
Adam Lesinski | efeb7af | 2017-08-02 14:57:43 -0700 | [diff] [blame] | 92 | std::unique_ptr<Value> value) { |
| 93 | return AddValue(name, {}, std::move(value)); |
| 94 | } |
| 95 | |
Yurii Zubrytskyi | a577514 | 2022-11-02 17:49:49 -0700 | [diff] [blame] | 96 | ResourceTableBuilder& ResourceTableBuilder::AddValue(StringPiece name, const ResourceId& id, |
Adam Lesinski | efeb7af | 2017-08-02 14:57:43 -0700 | [diff] [blame] | 97 | std::unique_ptr<Value> value) { |
| 98 | return AddValue(name, {}, id, std::move(value)); |
| 99 | } |
| 100 | |
Yurii Zubrytskyi | a577514 | 2022-11-02 17:49:49 -0700 | [diff] [blame] | 101 | ResourceTableBuilder& ResourceTableBuilder::AddValue(StringPiece name, |
Adam Lesinski | efeb7af | 2017-08-02 14:57:43 -0700 | [diff] [blame] | 102 | const ConfigDescription& config, |
| 103 | const ResourceId& id, |
| 104 | std::unique_ptr<Value> value) { |
| 105 | ResourceName res_name = ParseNameOrDie(name); |
Ryan Mitchell | 1d008d1 | 2021-03-19 14:54:17 -0700 | [diff] [blame] | 106 | NewResourceBuilder builder(res_name); |
| 107 | builder.SetValue(std::move(value), config).SetAllowMangled(true); |
| 108 | if (id.id != 0U) { |
| 109 | builder.SetId(id); |
| 110 | } |
| 111 | |
| 112 | CHECK(table_->AddResource(builder.Build(), GetDiagnostics())); |
Adam Lesinski | efeb7af | 2017-08-02 14:57:43 -0700 | [diff] [blame] | 113 | return *this; |
| 114 | } |
| 115 | |
Yurii Zubrytskyi | a577514 | 2022-11-02 17:49:49 -0700 | [diff] [blame] | 116 | ResourceTableBuilder& ResourceTableBuilder::SetSymbolState(StringPiece name, const ResourceId& id, |
Adam Lesinski | 71be705 | 2017-12-12 16:48:07 -0800 | [diff] [blame] | 117 | Visibility::Level level, |
Adam Lesinski | efeb7af | 2017-08-02 14:57:43 -0700 | [diff] [blame] | 118 | bool allow_new) { |
| 119 | ResourceName res_name = ParseNameOrDie(name); |
Ryan Mitchell | 1d008d1 | 2021-03-19 14:54:17 -0700 | [diff] [blame] | 120 | NewResourceBuilder builder(res_name); |
| 121 | builder.SetVisibility({level}).SetAllowNew({}).SetAllowMangled(true); |
| 122 | if (id.id != 0U) { |
| 123 | builder.SetId(id); |
| 124 | } |
| 125 | |
| 126 | CHECK(table_->AddResource(builder.Build(), GetDiagnostics())); |
Adam Lesinski | efeb7af | 2017-08-02 14:57:43 -0700 | [diff] [blame] | 127 | return *this; |
| 128 | } |
| 129 | |
Yurii Zubrytskyi | a577514 | 2022-11-02 17:49:49 -0700 | [diff] [blame] | 130 | ResourceTableBuilder& ResourceTableBuilder::SetOverlayable(StringPiece name, |
Ryan Mitchell | 54237ff | 2018-12-13 15:44:29 -0800 | [diff] [blame] | 131 | const OverlayableItem& overlayable) { |
Ryan Mitchell | e4e989c | 2018-10-29 02:21:50 -0700 | [diff] [blame] | 132 | ResourceName res_name = ParseNameOrDie(name); |
Ryan Mitchell | 1d008d1 | 2021-03-19 14:54:17 -0700 | [diff] [blame] | 133 | CHECK(table_->AddResource( |
| 134 | NewResourceBuilder(res_name).SetOverlayable(overlayable).SetAllowMangled(true).Build(), |
| 135 | GetDiagnostics())); |
| 136 | return *this; |
| 137 | } |
| 138 | |
| 139 | ResourceTableBuilder& ResourceTableBuilder::Add(NewResource&& res) { |
| 140 | CHECK(table_->AddResource(std::move(res), GetDiagnostics())); |
Ryan Mitchell | e4e989c | 2018-10-29 02:21:50 -0700 | [diff] [blame] | 141 | return *this; |
| 142 | } |
| 143 | |
Jeremy Meyer | 56f36e8 | 2022-05-20 20:35:42 +0000 | [diff] [blame] | 144 | android::StringPool* ResourceTableBuilder::string_pool() { |
Adam Lesinski | efeb7af | 2017-08-02 14:57:43 -0700 | [diff] [blame] | 145 | return &table_->string_pool; |
| 146 | } |
| 147 | |
| 148 | std::unique_ptr<ResourceTable> ResourceTableBuilder::Build() { |
| 149 | return std::move(table_); |
| 150 | } |
| 151 | |
Yurii Zubrytskyi | a577514 | 2022-11-02 17:49:49 -0700 | [diff] [blame] | 152 | std::unique_ptr<Reference> BuildReference(StringPiece ref, const std::optional<ResourceId>& id) { |
Adam Lesinski | efeb7af | 2017-08-02 14:57:43 -0700 | [diff] [blame] | 153 | std::unique_ptr<Reference> reference = util::make_unique<Reference>(ParseNameOrDie(ref)); |
| 154 | reference->id = id; |
| 155 | return reference; |
| 156 | } |
| 157 | |
| 158 | std::unique_ptr<BinaryPrimitive> BuildPrimitive(uint8_t type, uint32_t data) { |
| 159 | android::Res_value value = {}; |
| 160 | value.size = sizeof(value); |
| 161 | value.dataType = type; |
| 162 | value.data = data; |
| 163 | return util::make_unique<BinaryPrimitive>(value); |
| 164 | } |
| 165 | |
Adam Lesinski | 73bff1e | 2017-12-08 16:06:10 -0800 | [diff] [blame] | 166 | AttributeBuilder::AttributeBuilder() |
| 167 | : attr_(util::make_unique<Attribute>(android::ResTable_map::TYPE_ANY)) { |
Adam Lesinski | efeb7af | 2017-08-02 14:57:43 -0700 | [diff] [blame] | 168 | } |
| 169 | |
| 170 | AttributeBuilder& AttributeBuilder::SetTypeMask(uint32_t typeMask) { |
| 171 | attr_->type_mask = typeMask; |
| 172 | return *this; |
| 173 | } |
| 174 | |
Adam Lesinski | 73bff1e | 2017-12-08 16:06:10 -0800 | [diff] [blame] | 175 | AttributeBuilder& AttributeBuilder::SetWeak(bool weak) { |
| 176 | attr_->SetWeak(weak); |
| 177 | return *this; |
| 178 | } |
| 179 | |
Mark Punzalan | 5596a61 | 2024-01-19 00:06:38 -0800 | [diff] [blame] | 180 | AttributeBuilder& AttributeBuilder::SetComment(StringPiece comment) { |
| 181 | attr_->SetComment(comment); |
| 182 | return *this; |
| 183 | } |
| 184 | |
Yurii Zubrytskyi | a577514 | 2022-11-02 17:49:49 -0700 | [diff] [blame] | 185 | AttributeBuilder& AttributeBuilder::AddItem(StringPiece name, uint32_t value) { |
Adam Lesinski | efeb7af | 2017-08-02 14:57:43 -0700 | [diff] [blame] | 186 | attr_->symbols.push_back( |
| 187 | Attribute::Symbol{Reference(ResourceName({}, ResourceType::kId, name)), value}); |
| 188 | return *this; |
| 189 | } |
| 190 | |
Mark Punzalan | 5596a61 | 2024-01-19 00:06:38 -0800 | [diff] [blame] | 191 | AttributeBuilder& AttributeBuilder::AddItemWithComment(StringPiece name, uint32_t value, |
| 192 | StringPiece comment) { |
| 193 | Reference ref(ResourceName({}, ResourceType::kId, name)); |
| 194 | ref.SetComment(comment); |
| 195 | attr_->symbols.push_back(Attribute::Symbol{ref, value}); |
| 196 | return *this; |
| 197 | } |
| 198 | |
Adam Lesinski | efeb7af | 2017-08-02 14:57:43 -0700 | [diff] [blame] | 199 | std::unique_ptr<Attribute> AttributeBuilder::Build() { |
| 200 | return std::move(attr_); |
| 201 | } |
| 202 | |
Yurii Zubrytskyi | a577514 | 2022-11-02 17:49:49 -0700 | [diff] [blame] | 203 | StyleBuilder& StyleBuilder::SetParent(StringPiece str) { |
Adam Lesinski | efeb7af | 2017-08-02 14:57:43 -0700 | [diff] [blame] | 204 | style_->parent = Reference(ParseNameOrDie(str)); |
| 205 | return *this; |
| 206 | } |
| 207 | |
Yurii Zubrytskyi | a577514 | 2022-11-02 17:49:49 -0700 | [diff] [blame] | 208 | StyleBuilder& StyleBuilder::AddItem(StringPiece str, std::unique_ptr<Item> value) { |
Adam Lesinski | efeb7af | 2017-08-02 14:57:43 -0700 | [diff] [blame] | 209 | style_->entries.push_back(Style::Entry{Reference(ParseNameOrDie(str)), std::move(value)}); |
| 210 | return *this; |
| 211 | } |
| 212 | |
Yurii Zubrytskyi | a577514 | 2022-11-02 17:49:49 -0700 | [diff] [blame] | 213 | StyleBuilder& StyleBuilder::AddItem(StringPiece str, const ResourceId& id, |
Adam Lesinski | efeb7af | 2017-08-02 14:57:43 -0700 | [diff] [blame] | 214 | std::unique_ptr<Item> value) { |
| 215 | AddItem(str, std::move(value)); |
| 216 | style_->entries.back().key.id = id; |
| 217 | return *this; |
| 218 | } |
| 219 | |
| 220 | std::unique_ptr<Style> StyleBuilder::Build() { |
| 221 | return std::move(style_); |
| 222 | } |
| 223 | |
Yurii Zubrytskyi | a577514 | 2022-11-02 17:49:49 -0700 | [diff] [blame] | 224 | StyleableBuilder& StyleableBuilder::AddItem(StringPiece str, const std::optional<ResourceId>& id) { |
Adam Lesinski | efeb7af | 2017-08-02 14:57:43 -0700 | [diff] [blame] | 225 | styleable_->entries.push_back(Reference(ParseNameOrDie(str))); |
| 226 | styleable_->entries.back().id = id; |
| 227 | return *this; |
| 228 | } |
| 229 | |
| 230 | std::unique_ptr<Styleable> StyleableBuilder::Build() { |
| 231 | return std::move(styleable_); |
| 232 | } |
| 233 | |
Yurii Zubrytskyi | a577514 | 2022-11-02 17:49:49 -0700 | [diff] [blame] | 234 | std::unique_ptr<xml::XmlResource> BuildXmlDom(StringPiece str) { |
Adam Lesinski | efeb7af | 2017-08-02 14:57:43 -0700 | [diff] [blame] | 235 | std::string input = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; |
| 236 | input.append(str.data(), str.size()); |
| 237 | StringInputStream in(input); |
| 238 | StdErrDiagnostics diag; |
Jeremy Meyer | 56f36e8 | 2022-05-20 20:35:42 +0000 | [diff] [blame] | 239 | std::unique_ptr<xml::XmlResource> doc = xml::Inflate(&in, &diag, android::Source("test.xml")); |
Adam Lesinski | 6b37299 | 2017-08-09 10:54:23 -0700 | [diff] [blame] | 240 | CHECK(doc != nullptr && doc->root != nullptr) << "failed to parse inline XML string"; |
Adam Lesinski | efeb7af | 2017-08-02 14:57:43 -0700 | [diff] [blame] | 241 | return doc; |
| 242 | } |
| 243 | |
| 244 | std::unique_ptr<xml::XmlResource> BuildXmlDomForPackageName(IAaptContext* context, |
Yurii Zubrytskyi | a577514 | 2022-11-02 17:49:49 -0700 | [diff] [blame] | 245 | StringPiece str) { |
Adam Lesinski | efeb7af | 2017-08-02 14:57:43 -0700 | [diff] [blame] | 246 | std::unique_ptr<xml::XmlResource> doc = BuildXmlDom(str); |
| 247 | doc->file.name.package = context->GetCompilationPackage(); |
| 248 | return doc; |
| 249 | } |
| 250 | |
Shane Farmer | 0a5b201 | 2017-06-22 12:24:12 -0700 | [diff] [blame] | 251 | ArtifactBuilder& ArtifactBuilder::SetName(const std::string& name) { |
Shane Farmer | cb6c3f9 | 2017-11-27 13:19:36 -0800 | [diff] [blame] | 252 | artifact_.name = name; |
Shane Farmer | 0a5b201 | 2017-06-22 12:24:12 -0700 | [diff] [blame] | 253 | return *this; |
| 254 | } |
| 255 | |
Shane Farmer | 78c43d7 | 2017-12-04 09:08:38 -0800 | [diff] [blame] | 256 | ArtifactBuilder& ArtifactBuilder::SetVersion(int version) { |
| 257 | artifact_.version = version; |
| 258 | return *this; |
| 259 | } |
| 260 | |
Shane Farmer | cb6c3f9 | 2017-11-27 13:19:36 -0800 | [diff] [blame] | 261 | ArtifactBuilder& ArtifactBuilder::AddAbi(configuration::Abi abi) { |
| 262 | artifact_.abis.push_back(abi); |
Shane Farmer | 0a5b201 | 2017-06-22 12:24:12 -0700 | [diff] [blame] | 263 | return *this; |
| 264 | } |
| 265 | |
Shane Farmer | cb6c3f9 | 2017-11-27 13:19:36 -0800 | [diff] [blame] | 266 | ArtifactBuilder& ArtifactBuilder::AddDensity(const ConfigDescription& density) { |
| 267 | artifact_.screen_densities.push_back(density); |
Shane Farmer | 0a5b201 | 2017-06-22 12:24:12 -0700 | [diff] [blame] | 268 | return *this; |
| 269 | } |
| 270 | |
Shane Farmer | cb6c3f9 | 2017-11-27 13:19:36 -0800 | [diff] [blame] | 271 | ArtifactBuilder& ArtifactBuilder::AddLocale(const ConfigDescription& locale) { |
| 272 | artifact_.locales.push_back(locale); |
Shane Farmer | 0a5b201 | 2017-06-22 12:24:12 -0700 | [diff] [blame] | 273 | return *this; |
| 274 | } |
| 275 | |
Shane Farmer | cb6c3f9 | 2017-11-27 13:19:36 -0800 | [diff] [blame] | 276 | ArtifactBuilder& ArtifactBuilder::SetAndroidSdk(int min_sdk) { |
| 277 | artifact_.android_sdk = {AndroidSdk::ForMinSdk(min_sdk)}; |
Shane Farmer | efe4539 | 2017-08-21 14:39:28 -0700 | [diff] [blame] | 278 | return *this; |
| 279 | } |
| 280 | |
Shane Farmer | cb6c3f9 | 2017-11-27 13:19:36 -0800 | [diff] [blame] | 281 | configuration::OutputArtifact ArtifactBuilder::Build() { |
Shane Farmer | 0a5b201 | 2017-06-22 12:24:12 -0700 | [diff] [blame] | 282 | return artifact_; |
| 283 | } |
| 284 | |
Shane Farmer | 78c43d7 | 2017-12-04 09:08:38 -0800 | [diff] [blame] | 285 | PostProcessingConfigurationBuilder& PostProcessingConfigurationBuilder::AddAbiGroup( |
| 286 | const std::string& label, std::vector<configuration::Abi> abis) { |
| 287 | return AddGroup(label, &config_.abi_groups, std::move(abis)); |
| 288 | } |
| 289 | |
| 290 | PostProcessingConfigurationBuilder& PostProcessingConfigurationBuilder::AddDensityGroup( |
| 291 | const std::string& label, std::vector<std::string> densities) { |
| 292 | std::vector<ConfigDescription> configs; |
| 293 | for (const auto& density : densities) { |
| 294 | configs.push_back(test::ParseConfigOrDie(density)); |
| 295 | } |
| 296 | return AddGroup(label, &config_.screen_density_groups, configs); |
| 297 | } |
| 298 | |
| 299 | PostProcessingConfigurationBuilder& PostProcessingConfigurationBuilder::AddLocaleGroup( |
| 300 | const std::string& label, std::vector<std::string> locales) { |
| 301 | std::vector<ConfigDescription> configs; |
| 302 | for (const auto& locale : locales) { |
| 303 | configs.push_back(test::ParseConfigOrDie(locale)); |
| 304 | } |
| 305 | return AddGroup(label, &config_.locale_groups, configs); |
| 306 | } |
| 307 | |
| 308 | PostProcessingConfigurationBuilder& PostProcessingConfigurationBuilder::AddDeviceFeatureGroup( |
| 309 | const std::string& label) { |
| 310 | return AddGroup(label, &config_.device_feature_groups); |
| 311 | } |
| 312 | |
| 313 | PostProcessingConfigurationBuilder& PostProcessingConfigurationBuilder::AddGlTextureGroup( |
| 314 | const std::string& label) { |
| 315 | return AddGroup(label, &config_.gl_texture_groups); |
| 316 | } |
| 317 | |
| 318 | PostProcessingConfigurationBuilder& PostProcessingConfigurationBuilder::AddAndroidSdk( |
| 319 | std::string label, int min_sdk) { |
| 320 | config_.android_sdks[label] = AndroidSdk::ForMinSdk(min_sdk); |
| 321 | return *this; |
| 322 | } |
| 323 | |
| 324 | PostProcessingConfigurationBuilder& PostProcessingConfigurationBuilder::AddArtifact( |
| 325 | configuration::ConfiguredArtifact artifact) { |
| 326 | config_.artifacts.push_back(std::move(artifact)); |
| 327 | return *this; |
| 328 | } |
| 329 | |
| 330 | configuration::PostProcessingConfiguration PostProcessingConfigurationBuilder::Build() { |
| 331 | return config_; |
| 332 | } |
| 333 | |
Adam Lesinski | efeb7af | 2017-08-02 14:57:43 -0700 | [diff] [blame] | 334 | } // namespace test |
| 335 | } // namespace aapt |