Change in android Java build rules for Mojo Java content handler

See https://codereview.chromium.org/898853006 for motivation

Review URL: https://codereview.chromium.org/910143003

Cr-Original-Commit-Position: refs/heads/master@{#315959}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 32a8a141c605f608f158801ea863784683e4dd2f
This commit is contained in:
etiennej 2015-02-12 03:29:31 -08:00 коммит произвёл Commit bot
Родитель 53844cf3ce
Коммит ffc31fc61e
3 изменённых файлов: 30 добавлений и 4 удалений

Просмотреть файл

@ -106,7 +106,8 @@ def DoJavac(
_MAX_MANIFEST_LINE_LEN = 72
def CreateManifest(manifest_path, classpath, main_class=None):
def CreateManifest(manifest_path, classpath, main_class=None,
manifest_entries=None):
"""Creates a manifest file with the given parameters.
This generates a manifest file that compiles with the spec found at
@ -117,11 +118,16 @@ def CreateManifest(manifest_path, classpath, main_class=None):
classpath: The JAR files that should be listed on the manifest file's
classpath.
main_class: If present, the class containing the main() function.
manifest_entries: If present, a list of (key, value) pairs to add to
the manifest.
"""
output = ['Manifest-Version: 1.0']
if main_class:
output.append('Main-Class: %s' % main_class)
if manifest_entries:
for k, v in manifest_entries:
output.append('%s: %s' % (k, v))
if classpath:
sanitized_paths = []
for path in classpath:
@ -183,6 +189,10 @@ def main(argv):
parser.add_option(
'--main-class',
help='The class containing the main method.')
parser.add_option(
'--manifest-entry',
action='append',
help='Key:value pairs to add to the .jar manifest.')
parser.add_option('--stamp', help='Path to touch on success.')
@ -232,10 +242,13 @@ def main(argv):
java_files)
if options.jar_path:
if options.main_class:
if options.main_class or options.manifest_entry:
if options.manifest_entry:
entries = map(lambda e: e.split(":"), options.manifest_entry)
else:
entries = []
manifest_file = os.path.join(temp_dir, 'manifest')
CreateManifest(manifest_file, classpath,
options.main_class)
CreateManifest(manifest_file, classpath, options.main_class, entries)
else:
manifest_file = None
jar.JarDirectory(classes_dir,

Просмотреть файл

@ -665,6 +665,10 @@ template("compile_java") {
if (defined(invoker.chromium_code)) {
_chromium_code = invoker.chromium_code
}
_manifest_entries = []
if (defined(invoker.manifest_entries)) {
_manifest_entries = invoker.manifest_entries
}
_srcjar_deps = []
if (defined(invoker.srcjar_deps)) {
@ -718,6 +722,9 @@ template("compile_java") {
"--java-srcjars=@FileArg($_rebased_build_config:javac:srcjars)",
"--jar-excluded-classes=$_jar_excluded_patterns",
]
foreach(e, _manifest_entries) {
args += [ "--manifest-entry=" + e ]
}
if (_chromium_code) {
args += [ "--chromium-code=1" ]
}
@ -861,6 +868,9 @@ template("java_library_impl") {
if (defined(invoker.dist_jar_path)) {
dist_jar_path = invoker.dist_jar_path
}
if (defined(invoker.manifest_entries)) {
manifest_entries = invoker.manifest_entries
}
}
if (defined(invoker.main_class)) {

Просмотреть файл

@ -998,6 +998,9 @@ template("android_library") {
if (defined(invoker.dex_path)) {
dex_path = invoker.dex_path
}
if (defined(invoker.manifest_entries)) {
manifest_entries = invoker.manifest_entries
}
supports_android = true
requires_android = true