use of com.android.tools.build.bundletool.model.targeting.TargetedDirectory in project bundletool by google.
the class SuffixStripper method removeTargetingFromEntry.
/**
* Removes the specified dimension from the path represented by the module entry.
*/
private ModuleEntry removeTargetingFromEntry(ModuleEntry moduleEntry) {
// Quickly discard path that don't exhibit targeting for the specified dimension.
if (!TargetedDirectorySegment.pathMayContain(moduleEntry.getPath().toString(), targetingDimension)) {
return moduleEntry;
}
// Rewrite the path with the targeting for the specified dimension removed.
TargetedDirectory targetedDirectory = TargetedDirectory.parse(moduleEntry.getPath());
TargetedDirectory newTargetedDirectory = targetedDirectory.removeTargeting(targetingDimension);
if (!newTargetedDirectory.equals(targetedDirectory)) {
return moduleEntry.toBuilder().setPath(newTargetedDirectory.toZipPath()).build();
}
// Return the unmodified, immutable original object if no changes were applied.
return moduleEntry;
}
use of com.android.tools.build.bundletool.model.targeting.TargetedDirectory in project bundletool by google.
the class SuffixStripper method removeAssetsTargetingFromDirectory.
/**
* Updates the directory path and targeting to remove the specified dimension.
*/
private TargetedAssetsDirectory removeAssetsTargetingFromDirectory(TargetedAssetsDirectory directory) {
if (!dimensionHandler.hasTargetingDimension(directory.getTargeting())) {
// Return the unmodified, immutable original object if no changes were applied.
return directory;
}
TargetedDirectory targetedDirectory = TargetedDirectory.parse(ZipPath.create(directory.getPath()));
TargetedDirectory newTargetedDirectory = targetedDirectory.removeTargeting(targetingDimension);
// and update the targeting to remove the dimension.
return directory.toBuilder().setPath(newTargetedDirectory.toZipPath().toString()).setTargeting(dimensionHandler.clearTargetingDimension(directory.getTargeting())).build();
}
use of com.android.tools.build.bundletool.model.targeting.TargetedDirectory in project bundletool by google.
the class TextureCompressionFormatParityValidator method getSupportedTextureCompressionFormats.
private static SupportedTextureCompressionFormats getSupportedTextureCompressionFormats(BundleModule module) {
// Extract targeted directories from entries (like done when generating assets targeting)
ImmutableSet<TargetedDirectory> targetedDirectories = extractAssetsTargetedDirectories(module);
// Inspect the targetings to extract texture compression formats.
ImmutableSet<TextureCompressionFormatAlias> formats = extractTextureCompressionFormats(targetedDirectories);
// Check if one or more targeted directories have "fallback" sibling directories.
boolean hasFallback = targetedDirectories.stream().anyMatch(directory -> {
Optional<AssetsDirectoryTargeting> targeting = directory.getTargeting(TargetingDimension.TEXTURE_COMPRESSION_FORMAT);
if (targeting.isPresent()) {
// Check if a sibling folder without texture targeting exists. If yes, this is
// called a "fallback".
TargetedDirectory siblingFallbackDirectory = directory.removeTargeting(TargetingDimension.TEXTURE_COMPRESSION_FORMAT);
return module.findEntriesUnderPath(siblingFallbackDirectory.toZipPath()).findAny().isPresent();
}
return false;
});
return SupportedTextureCompressionFormats.create(formats, hasFallback);
}
Aggregations