Skip to content

Commit

Permalink
Convert native strip from rule to action
Browse files Browse the repository at this point in the history
First, this allows us to correctly have the output of the copy/strip
action be an input to the apk package action.

Second, this step now uses the list of libraries created by ordered
libraries step. This is required to support the component build where
we can not manually list the required libraries.

BUG=158821


Review URL: https://chromiumcodereview.appspot.com/13058003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@191754 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
cjhopman@chromium.org committed Apr 2, 2013
1 parent 3069f0c commit 714038e
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 32 deletions.
22 changes: 18 additions & 4 deletions build/android/strip_library_for_apk.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import json
import optparse
import os
import sys
Expand All @@ -25,19 +26,32 @@ def main(argv):
help='Path to the toolchain\'s strip binary')
parser.add_option('--android-strip-arg', action='append',
help='Argument to be passed to strip')
parser.add_option('--libraries-dir',
help='Directory for un-stripped libraries')
parser.add_option('--stripped-libraries-dir',
help='Directory for stripped libraries')
parser.add_option('--libraries-file',
help='Path to json file containing list of libraries')
parser.add_option('--stamp', help='Path to touch on success')

options, paths = parser.parse_args()

options, _ = parser.parse_args()

with open(options.libraries_file, 'r') as libfile:
libraries = json.load(libfile)

build_utils.MakeDirectory(options.stripped_libraries_dir)

for library_path in paths:
stripped_library_path = os.path.join(options.stripped_libraries_dir,
os.path.basename(library_path))
for library in libraries:
library_path = os.path.join(options.libraries_dir, library)
stripped_library_path = os.path.join(
options.stripped_libraries_dir, library)
StripLibrary(options.android_strip, options.android_strip_arg, library_path,
stripped_library_path)

if options.stamp:
build_utils.Touch(options.stamp)


if __name__ == '__main__':
sys.exit(main(sys.argv))
56 changes: 28 additions & 28 deletions build/java_apk.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
'asset_location%': '<(intermediate_dir)/assets',
'codegen_stamp': '<(intermediate_dir)/codegen.stamp',
'compile_input_paths': [ ],
'package_input_paths': [ ],
'ordered_libraries_file': '<(intermediate_dir)/native_libraries.json',
# TODO(cjhopman): build/ shouldn't refer to content/. The libraryloader and
# nativelibraries template should be moved out of content/ (to base/?).
Expand All @@ -88,6 +89,7 @@
'compile_stamp': '<(intermediate_dir)/compile.stamp',
'jar_stamp': '<(intermediate_dir)/jar.stamp',
'obfuscate_stamp': '<(intermediate_dir)/obfuscate.stamp',
'strip_stamp': '<(intermediate_dir)/strip.stamp',
'classes_dir': '<(intermediate_dir)/classes',
'javac_includes': [],
'jar_excluded_classes': [],
Expand All @@ -97,9 +99,6 @@
'android_manifest': '<(java_in_dir)/AndroidManifest.xml',
'codegen_input_paths': [],
},
'sources': [
'<@(native_libs_paths)',
],
# Pass the jar path to the apk's "fake" jar target. This would be better as
# direct_dependent_settings, but a variable set by a direct_dependent_settings
# cannot be lifted in a dependent to all_dependent_settings.
Expand All @@ -108,29 +107,6 @@
'apk_output_jar_path': '<(PRODUCT_DIR)/lib.java/<(jar_name)',
},
},
'rules': [
{
'rule_name': 'copy_and_strip_native_libraries',
'extension': 'so',
'variables': {
'apk_libraries_dir': '<(intermediate_dir)/libs/<(android_app_abi)',
'stripped_library_path': '<(apk_libraries_dir)/<(RULE_INPUT_ROOT).so',
},
'inputs': [
'<(DEPTH)/build/android/strip_library_for_apk.py',
],
'outputs': [
'<(stripped_library_path)',
],
'action': [
'python', '<(DEPTH)/build/android/strip_library_for_apk.py',
'--android-strip=<(android_strip)',
'--android-strip-arg=--strip-unneeded',
'--stripped-libraries-dir=<(apk_libraries_dir)',
'<(RULE_INPUT_PATH)',
],
},
],
'conditions': [
['resource_dir!=""', {
'variables': {
Expand All @@ -150,6 +126,7 @@
'variables': {
'compile_input_paths': [ '<(native_libraries_java_stamp)' ],
'generated_src_dirs': [ '<(native_libraries_java_dir)' ],
'package_input_paths': [ '<(strip_stamp)' ],
},
'actions': [
{
Expand Down Expand Up @@ -207,6 +184,30 @@
'--stamp=<(native_libraries_java_stamp)',
],
},
{
'action_name': 'strip_native_libraries',
'message': 'Stripping libraries for <(_target_name)',
'variables': {
'apk_libraries_dir': '<(intermediate_dir)/libs/<(android_app_abi)',
},
'inputs': [
'<(DEPTH)/build/android/pylib/build_utils.py',
'<(DEPTH)/build/android/strip_library_for_apk.py',
'<(ordered_libraries_file)'
],
'outputs': [
'<(strip_stamp)',
],
'action': [
'python', '<(DEPTH)/build/android/strip_library_for_apk.py',
'--android-strip=<(android_strip)',
'--android-strip-arg=--strip-unneeded',
'--stripped-libraries-dir=<(apk_libraries_dir)',
'--libraries-dir=<(SHARED_LIB_DIR)',
'--libraries-file=<(ordered_libraries_file)',
'--stamp=<(strip_stamp)',
],
},
],
}], # native_libs_paths != []
['java_strings_grd != ""', {
Expand Down Expand Up @@ -424,11 +425,10 @@
'message': 'Packaging <(_target_name).',
'inputs': [
'<(DEPTH)/build/android/ant/apk-package.xml',
#TODO(cjhopman): this should be the stripped library paths.
'>@(native_libs_paths)',
'<(dex_path)',
'<(codegen_stamp)',
'<(obfuscate_stamp)',
'>@(package_input_paths)',
],
'conditions': [
['is_test_apk == 1', {
Expand Down

0 comments on commit 714038e

Please sign in to comment.