forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make the build control what library(/ies) to load
At build time, we know what native libraries an apk needs to load. Instead of requiring those .apks to specify this again in code, instead generate a .java file containing a list of the libraries to load. This is done using a pattern similar to resources, content_java is built with a placeholder NativeLibraries.java (i.e. without an actual value for its libraries list). The corresponding .class file is not included in content_java.jar. Then, when building an apk we generate the "real" NativeLibraries.java (with the real String[]) and include that in the .apk. This is designed to also support the component build, where, we will have to calculate the list of libraries at build time, and sort them in dependency order (because Android's linker, for some reason, doesn't do that itself). BUG=158821 TBR=brettw@chromium.org Review URL: https://chromiumcodereview.appspot.com/12939021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@191695 0039d316-1c4b-4281-b951-d872f2087c98
- Loading branch information
cjhopman@chromium.org
committed
Apr 1, 2013
1 parent
043e417
commit b50a8b5
Showing
18 changed files
with
317 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
android_webview/java/generated_src/org/chromium/content/app/NativeLibraries.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright 2013 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
package org.chromium.content.app; | ||
|
||
public class NativeLibraries { | ||
// This is the list of native libraries to load. In the normal chromium build, this would be | ||
// automatically generated. | ||
// TODO(torne, cjhopman): Use a generated file for this. | ||
static String[] libraries = { "webviewchromium" }; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env python | ||
# | ||
# Copyright 2013 The Chromium Authors. All rights reserved. | ||
# Use of this source code is governed by a BSD-style license that can be | ||
# found in the LICENSE file. | ||
|
||
"""Writes .h file for NativeLibraries.template | ||
This header should contain the list of native libraries to load in the form: | ||
= { "lib1", "lib2" } | ||
""" | ||
|
||
import json | ||
import optparse | ||
import os | ||
import sys | ||
|
||
from pylib import build_utils | ||
|
||
|
||
def main(argv): | ||
parser = optparse.OptionParser() | ||
|
||
parser.add_option('--output', help='Path to generated .java file') | ||
parser.add_option('--ordered-libraries', | ||
help='Path to json file containing list of ordered libraries') | ||
parser.add_option('--stamp', help='Path to touch on success') | ||
|
||
# args should be the list of libraries in dependency order. | ||
options, _ = parser.parse_args() | ||
|
||
build_utils.MakeDirectory(os.path.dirname(options.output)) | ||
|
||
with open(options.ordered_libraries, 'r') as libfile: | ||
libraries = json.load(libfile) | ||
# Generates string of the form '= { "base", "net", | ||
# "content_shell_content_view" }' from a list of the form ["libbase.so", | ||
# libnet.so", "libcontent_shell_content_view.so"] | ||
libraries = ['"' + lib[3:-3] + '"' for lib in libraries] | ||
array = '= { ' + ', '.join(libraries) + '}'; | ||
|
||
with open(options.output, 'w') as header: | ||
header.write(array) | ||
|
||
if options.stamp: | ||
build_utils.Touch(options.stamp) | ||
|
||
|
||
if __name__ == '__main__': | ||
sys.exit(main(sys.argv)) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env python | ||
# | ||
# Copyright 2013 The Chromium Authors. All rights reserved. | ||
# Use of this source code is governed by a BSD-style license that can be | ||
# found in the LICENSE file. | ||
|
||
import optparse | ||
import os | ||
import subprocess | ||
import sys | ||
|
||
from pylib import build_utils | ||
|
||
def DoGcc(options): | ||
build_utils.MakeDirectory(os.path.dirname(options.output)) | ||
|
||
gcc_cmd = [ | ||
'gcc', # invoke host gcc. | ||
'-E', # stop after preprocessing. | ||
'-D', 'ANDROID', # Specify ANDROID define for pre-processor. | ||
'-x', 'c-header', # treat sources as C header files | ||
'-P', # disable line markers, i.e. '#line 309' | ||
'-I', options.include_path, | ||
'-o', options.output, | ||
options.template | ||
] | ||
|
||
build_utils.CheckCallDie(gcc_cmd) | ||
|
||
|
||
def main(argv): | ||
parser = optparse.OptionParser() | ||
parser.add_option('--include-path', help='Include path for gcc.') | ||
parser.add_option('--template', help='Path to template.') | ||
parser.add_option('--output', help='Path for generated file.') | ||
parser.add_option('--stamp', help='Path to touch on success.') | ||
|
||
# TODO(newt): remove this once http://crbug.com/177552 is fixed in ninja. | ||
parser.add_option('--ignore', help='Ignored.') | ||
|
||
options, _ = parser.parse_args() | ||
|
||
DoGcc(options) | ||
|
||
if options.stamp: | ||
build_utils.Touch(options.stamp) | ||
|
||
|
||
if __name__ == '__main__': | ||
sys.exit(main(sys.argv)) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env python | ||
# | ||
# Copyright 2013 The Chromium Authors. All rights reserved. | ||
# Use of this source code is governed by a BSD-style license that can be | ||
# found in the LICENSE file. | ||
|
||
"""Writes dependency ordered list of native libraries. | ||
This list of libraries is used for several steps of building an APK. | ||
""" | ||
|
||
import json | ||
import optparse | ||
import os | ||
import sys | ||
|
||
from pylib import build_utils | ||
|
||
|
||
def main(argv): | ||
parser = optparse.OptionParser() | ||
|
||
parser.add_option('--input-libraries', | ||
help='A list of top-level input libraries') | ||
parser.add_option('--output', help='Path to the generated .json file') | ||
parser.add_option('--stamp', help='Path to touch on success') | ||
|
||
options, _ = parser.parse_args() | ||
|
||
libraries = build_utils.ParseGypList(options.input_libraries) | ||
libraries = [os.path.basename(lib) for lib in libraries] | ||
|
||
with open(options.output, 'w') as outfile: | ||
json.dump(libraries, outfile) | ||
|
||
if options.stamp: | ||
build_utils.Touch(options.stamp) | ||
|
||
|
||
if __name__ == '__main__': | ||
sys.exit(main(sys.argv)) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.