Skip to content

Commit

Permalink
Change in android Java build rules for Mojo Java content handler
Browse files Browse the repository at this point in the history
See https://codereview.chromium.org/898853006 for motivation

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

Cr-Commit-Position: refs/heads/master@{#315959}
  • Loading branch information
emembrives authored and Commit bot committed Feb 12, 2015
1 parent c91bd8a commit 32a8a14
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
21 changes: 17 additions & 4 deletions build/android/gyp/javac.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ def Compile():
_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
Expand All @@ -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:
Expand Down Expand Up @@ -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.')

Expand Down Expand Up @@ -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,
Expand Down
10 changes: 10 additions & 0 deletions build/config/android/internal_rules.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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" ]
}
Expand Down Expand Up @@ -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)) {
Expand Down
3 changes: 3 additions & 0 deletions build/config/android/rules.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 32a8a14

Please sign in to comment.