Skip to content

Commit

Permalink
Remove some deprecated resources flags.
Browse files Browse the repository at this point in the history
RELNOTES: None
PiperOrigin-RevId: 191624839
  • Loading branch information
aj-michael authored and Copybara-Service committed Apr 4, 2018
1 parent eb0671b commit c498715
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 119 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ public static void main(String[] args) throws Exception {
optionsParser.parseAndExitUponError(args);
Aapt2ConfigOptions aapt2ConfigOptions = optionsParser.getOptions(Aapt2ConfigOptions.class);
Options options = optionsParser.getOptions(Options.class);
options.dependencyManifests =
Converters.concatLists(options.dependencyManifests, options.deprecatedDependencyManifests);
profiler.recordEndOf("flags").startTask("setup");

final ListeningExecutorService executorService = ExecutorServiceCloser.createDefaultService();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ static Path processDataBindings(
}

public ResourceSymbols loadResourceSymbolTable(
Iterable<SymbolFileProvider> libraries,
Iterable<? extends SymbolFileProvider> libraries,
String appPackageName,
Path primaryRTxt,
Multimap<String, ResourceSymbols> libMap)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableList.Builder;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import com.google.devtools.build.android.aapt2.CompiledResources;
import com.google.devtools.build.android.aapt2.StaticLibrary;
import com.google.devtools.common.options.Converter;
Expand All @@ -40,7 +39,6 @@
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.annotation.Nullable;

/**
* Some convenient converters used by android actions. Note: These are specific to android actions.
Expand Down Expand Up @@ -205,42 +203,6 @@ public String getTypeDescription() {
}
}

/**
* Converter for a list of {@link DependencySymbolFileProvider}. Relies on {@code
* DependencySymbolFileProvider#valueOf(String)} to perform conversion and validation.
*
* @deprecated use multi-value flags and {@link DependencySymbolFileProviderConverter} instead.
*/
@Deprecated
public static class DependencySymbolFileProviderListConverter
implements Converter<List<DependencySymbolFileProvider>> {

@Override
public List<DependencySymbolFileProvider> convert(String input) throws OptionsParsingException {
if (input.isEmpty()) {
return ImmutableList.<DependencySymbolFileProvider>of();
}
try {
ImmutableList.Builder<DependencySymbolFileProvider> builder = ImmutableList.builder();
for (String item : input.split(",")) {
builder.add(DependencySymbolFileProvider.valueOf(item));
}
return builder.build();
} catch (IllegalArgumentException e) {
throw new OptionsParsingException(
String.format("invalid DependencyAndroidData: %s", e.getMessage()), e);
}
}

@Override
public String getTypeDescription() {
return String.format(
"a list of dependency android data in the format: %s[%s]",
DependencySymbolFileProvider.commandlineFormat("1"),
DependencySymbolFileProvider.commandlineFormat("2"));
}
}

/**
* Converter for {@link Revision}. Relies on {@code Revision#parseRevision(String)} to perform
* conversion and validation.
Expand Down Expand Up @@ -319,18 +281,6 @@ public MergeTypeConverter() {
}
}

public static <T> List<T> concatLists(
@Nullable List<? extends T> a, @Nullable List<? extends T> b) {
@SuppressWarnings("unchecked")
List<T> la = (List<T>) a;
@SuppressWarnings("unchecked")
List<T> lb = (List<T>) b;
if (la == null || la.isEmpty()) {
return (lb == null || lb.isEmpty()) ? ImmutableList.of() : lb;
}
return (lb == null || lb.isEmpty()) ? la : ImmutableList.copyOf(Iterables.concat(la, lb));
}

/**
* Validating converter for a list of Paths. A Path is considered valid if it resolves to a file.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@
import com.google.devtools.build.android.AndroidResourceMerger.MergingException;
import com.google.devtools.build.android.AndroidResourceProcessor.AaptConfigOptions;
import com.google.devtools.build.android.Converters.PathConverter;
import com.google.devtools.build.android.Converters.PathListConverter;
import com.google.devtools.common.options.Option;
import com.google.devtools.common.options.OptionDocumentationCategory;
import com.google.devtools.common.options.OptionEffectTag;
import com.google.devtools.common.options.OptionMetadataTag;
import com.google.devtools.common.options.OptionsBase;
import com.google.devtools.common.options.OptionsParser;
import com.google.devtools.common.options.ShellQuotedParamsFilePreProcessor;
Expand Down Expand Up @@ -81,22 +79,6 @@ public static final class Options extends OptionsBase {
)
public List<Path> symbols;

// TODO(laszlocsomor): remove this flag after 2018-01-31 (about 6 months from now). Everyone
// should have updated to newer Bazel versions by then.
@Deprecated
@Option(
name = "symbols",
defaultValue = "",
converter = PathListConverter.class,
deprecationWarning = "Deprecated in favour of \"--symbol\"",
documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
effectTags = {OptionEffectTag.UNKNOWN},
category = "config",
help = "Parsed symbol binaries to write as R classes.",
metadataTags = {OptionMetadataTag.DEPRECATED}
)
public List<Path> deprecatedSymbols;

@Option(
name = "targetLabel",
defaultValue = "null",
Expand Down Expand Up @@ -127,7 +109,6 @@ public static void main(String[] args) throws Exception {
optionsParser.parseAndExitUponError(args);
AaptConfigOptions aaptConfigOptions = optionsParser.getOptions(AaptConfigOptions.class);
Options options = optionsParser.getOptions(Options.class);
options.symbols = Converters.concatLists(options.symbols, options.deprecatedSymbols);
logger.fine(
String.format("Option parsing finished at %sms", timer.elapsed(TimeUnit.MILLISECONDS)));
try (ScopedTemporaryDirectory scopedTmp =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,17 @@
package com.google.devtools.build.android;

import com.android.builder.core.VariantConfiguration;
import com.android.builder.dependency.SymbolFileProvider;
import com.android.utils.StdLogger;
import com.google.common.base.Preconditions;
import com.google.common.base.Stopwatch;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import com.google.devtools.build.android.Converters.DependencySymbolFileProviderConverter;
import com.google.devtools.build.android.Converters.DependencySymbolFileProviderListConverter;
import com.google.devtools.build.android.Converters.PathConverter;
import com.google.devtools.build.android.resources.ResourceSymbols;
import com.google.devtools.common.options.Option;
import com.google.devtools.common.options.OptionDocumentationCategory;
import com.google.devtools.common.options.OptionEffectTag;
import com.google.devtools.common.options.OptionMetadataTag;
import com.google.devtools.common.options.OptionsBase;
import com.google.devtools.common.options.OptionsParser;
import com.google.devtools.common.options.ShellQuotedParamsFilePreProcessor;
Expand Down Expand Up @@ -109,24 +106,6 @@ public static final class Options extends OptionsBase {
)
public List<DependencySymbolFileProvider> libraries;

// TODO(laszlocsomor): remove this flag after 2018-02-28 (about 6 months from now). Everyone
// should have updated to newer Bazel versions by then.
@Deprecated
@Option(
name = "libraries",
defaultValue = "",
deprecationWarning = "Deprecated in favour of \"--library\"",
converter = DependencySymbolFileProviderListConverter.class,
category = "input",
documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
effectTags = {OptionEffectTag.UNKNOWN},
help =
"R.txt and manifests for the libraries in this binary's deps. We will write "
+ "class files for the libraries as well. Expected format: lib1/R.txt[:lib2/R.txt]",
metadataTags = {OptionMetadataTag.DEPRECATED}
)
public List<DependencySymbolFileProvider> deprecatedLibraries;

@Option(
name = "classJarOutput",
defaultValue = "null",
Expand Down Expand Up @@ -174,8 +153,6 @@ public static void main(String[] args) throws Exception {
Path classOutPath = tmp.resolve("compiled_classes");

logger.fine(String.format("Setup finished at %sms", timer.elapsed(TimeUnit.MILLISECONDS)));
List<SymbolFileProvider> libraries =
Converters.concatLists(options.libraries, options.deprecatedLibraries);
// Note that we need to write the R class for the main binary (so proceed even if there
// are no libraries).
if (options.primaryRTxt != null) {
Expand All @@ -187,18 +164,18 @@ public static void main(String[] args) throws Exception {
Multimap<String, ResourceSymbols> libSymbolMap = ArrayListMultimap.create();
ResourceSymbols fullSymbolValues =
resourceProcessor.loadResourceSymbolTable(
libraries, appPackageName, options.primaryRTxt, libSymbolMap);
options.libraries, appPackageName, options.primaryRTxt, libSymbolMap);
logger.fine(
String.format("Load symbols finished at %sms", timer.elapsed(TimeUnit.MILLISECONDS)));
// For now, assuming not used for libraries and setting final access for fields.
fullSymbolValues.writeClassesTo(
libSymbolMap, appPackageName, classOutPath, true /* finalFields */);
logger.fine(
String.format("Finished R.class at %sms", timer.elapsed(TimeUnit.MILLISECONDS)));
} else if (!libraries.isEmpty()) {
} else if (!options.libraries.isEmpty()) {
Multimap<String, ResourceSymbols> libSymbolMap = ArrayListMultimap.create();
ResourceSymbols fullSymbolValues =
resourceProcessor.loadResourceSymbolTable(libraries, null, null, libSymbolMap);
resourceProcessor.loadResourceSymbolTable(options.libraries, null, null, libSymbolMap);
logger.fine(
String.format("Load symbols finished at %sms", timer.elapsed(TimeUnit.MILLISECONDS)));
// For now, assuming not used for libraries and setting final access for fields.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@
import com.google.devtools.build.android.AndroidResourceProcessor.FlagAaptOptions;
import com.google.devtools.build.android.Converters.ExistingPathConverter;
import com.google.devtools.build.android.Converters.PathConverter;
import com.google.devtools.build.android.Converters.PathListConverter;
import com.google.devtools.build.android.Converters.VariantTypeConverter;
import com.google.devtools.common.options.Converters.CommaSeparatedOptionListConverter;
import com.google.devtools.common.options.Option;
import com.google.devtools.common.options.OptionDocumentationCategory;
import com.google.devtools.common.options.OptionEffectTag;
import com.google.devtools.common.options.OptionMetadataTag;
import com.google.devtools.common.options.OptionsBase;
import com.google.devtools.common.options.OptionsParser;
import com.google.devtools.common.options.ShellQuotedParamsFilePreProcessor;
Expand Down Expand Up @@ -143,22 +141,6 @@ public static final class Options extends OptionsBase {
)
public List<Path> dependencyManifests;

// TODO(laszlocsomor): remove this flag after 2018-01-31 (about 6 months from now). Everyone
// should have updated to newer Bazel versions by then.
@Deprecated
@Option(
name = "dependencyManifests",
defaultValue = "",
category = "input",
converter = PathListConverter.class,
deprecationWarning = "Deprecated in favour of \"--dependencyManifest\"",
documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
effectTags = {OptionEffectTag.UNKNOWN},
help = "A list of paths to the manifests of the dependencies.",
metadataTags = {OptionMetadataTag.DEPRECATED}
)
public List<Path> deprecatedDependencyManifests;

@Option(
name = "resourcePackages",
defaultValue = "",
Expand Down Expand Up @@ -257,8 +239,6 @@ public static void main(String[] args) throws Exception {
optionsParser.parseAndExitUponError(args);
aaptConfigOptions = optionsParser.getOptions(AaptConfigOptions.class);
options = optionsParser.getOptions(Options.class);
options.dependencyManifests =
Converters.concatLists(options.dependencyManifests, options.deprecatedDependencyManifests);

AndroidResourceProcessor resourceProcessor = new AndroidResourceProcessor(stdLogger);
// Setup temporary working directories.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public String call() throws Exception {
* @throws InterruptedException when there is an error loading the symbols.
*/
public static Multimap<String, ListenableFuture<ResourceSymbols>> loadFrom(
Iterable<SymbolFileProvider> dependencies,
Iterable<? extends SymbolFileProvider> dependencies,
ListeningExecutorService executor,
@Nullable String packageToExclude)
throws InterruptedException, ExecutionException {
Expand Down

0 comments on commit c498715

Please sign in to comment.