diff options
author | laszlocsomor <laszlocsomor@google.com> | 2017-08-04 12:56:42 +0200 |
---|---|---|
committer | Dmitry Lomov <dslomov@google.com> | 2017-08-04 17:19:09 +0200 |
commit | 025a7b0a33680c53d872d241fdb49f3ab578afd6 (patch) | |
tree | cfcca497c74f25361537a038a4c898b26a7af39e /src/tools/android/java/com/google/devtools/build/android/RClassGeneratorAction.java | |
parent | 8879b48fa1f8f5bdc39321e31b02323b9f9dd86a (diff) |
Android BusyBox: deprecate --libraries flag
Deprecate the --libraries flag of the
GENERATE_BINARY_R tool in favour of --library.
The new flag is multi-value and uses "," as the
pair-separator instead of ":".
The value converter still supports ":"-separated
pairs as well, but looks for "," first.
Old format:
--libraries=key1:value1,key2:value2,...
New format:
--library=key1,value1 --library=key2,value2
Motivation:
- the ":"-separator prevents using absolute paths
on Windows
The old flag is still supported, but will be
removed after 2018-02-28 (about 6 months from
now).
Also in this commit:
- add a new method to CustomCommandLine.Builder
to lazily construct the command line for the
--library flag
See https://github.com/bazelbuild/bazel/issues/3264
RELNOTES: none
PiperOrigin-RevId: 164246506
Diffstat (limited to 'src/tools/android/java/com/google/devtools/build/android/RClassGeneratorAction.java')
-rw-r--r-- | src/tools/android/java/com/google/devtools/build/android/RClassGeneratorAction.java | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/src/tools/android/java/com/google/devtools/build/android/RClassGeneratorAction.java b/src/tools/android/java/com/google/devtools/build/android/RClassGeneratorAction.java index ee64b76934..daab1f4b3b 100644 --- a/src/tools/android/java/com/google/devtools/build/android/RClassGeneratorAction.java +++ b/src/tools/android/java/com/google/devtools/build/android/RClassGeneratorAction.java @@ -20,18 +20,19 @@ 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 java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; -import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeUnit; import java.util.logging.Logger; @@ -40,15 +41,15 @@ import java.util.logging.Logger; * Provides an entry point for the compiling resource classes using a custom compiler (simply parse * R.txt and make a jar, which is simpler than parsing R.java and running errorprone, etc.). * - * For now, we assume this is only worthwhile for android_binary and not libraries. + * <p>For now, we assume this is only worthwhile for android_binary and not libraries. * * <pre> * Example Usage: * java/com/google/build/android/RClassGeneratorAction\ * --primaryRTxt path/to/R.txt\ * --primaryManifest path/to/AndroidManifest.xml\ - * --libraries p/t/1/AndroidManifest.txt:p/t/1/R.txt,\ - * p/t/2/AndroidManifest.txt:p/t/2/R.txt\ + * --library p/t/1/AndroidManifest.txt,p/t/1/R.txt\ + * --library p/t/2/AndroidManifest.txt,p/t/2/R.txt\ * --classJarOutput path/to/write/archive_resources.jar * </pre> */ @@ -97,9 +98,10 @@ public class RClassGeneratorAction { public String packageForR; @Option( - name = "libraries", + name = "library", + allowMultiple = true, defaultValue = "", - converter = DependencySymbolFileProviderListConverter.class, + converter = DependencySymbolFileProviderConverter.class, category = "input", documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, effectTags = {OptionEffectTag.UNKNOWN}, @@ -109,6 +111,24 @@ public class RClassGeneratorAction { ) 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", @@ -135,10 +155,8 @@ public class RClassGeneratorAction { Path classOutPath = tmp.resolve("compiled_classes"); logger.fine(String.format("Setup finished at %sms", timer.elapsed(TimeUnit.MILLISECONDS))); - List<SymbolFileProvider> libraries = new ArrayList<>(); - for (DependencySymbolFileProvider library : options.libraries) { - libraries.add(library); - } + 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) { |