summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--BUILD.gn8
-rwxr-xr-xbuild/android/gyp/proguard.py20
-rw-r--r--build/config/android/internal_rules.gni174
-rw-r--r--build/config/android/rules.gni74
-rw-r--r--build/secondary/third_party/android_tools/BUILD.gn46
-rw-r--r--third_party/guava/BUILD.gn3
6 files changed, 263 insertions, 62 deletions
diff --git a/BUILD.gn b/BUILD.gn
index 15084b1..2aac18a 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -158,7 +158,13 @@ group("root") {
if (is_android) {
deps += [
- "//ui/android:ui_java"
+ "//ui/android:ui_java",
+ "//third_party/guava:guava_javalib",
+ "//third_party/android_tools:android_gcm_java",
+ "//third_party/android_tools:uiautomator_java",
+ "//third_party/android_tools:android_support_v13_java",
+ "//third_party/android_tools:android_support_v7_appcompat_java",
+ "//third_party/android_tools:android_support_v7_mediarouter_java",
]
deps -= [
diff --git a/build/android/gyp/proguard.py b/build/android/gyp/proguard.py
index b27365b..ca58770 100755
--- a/build/android/gyp/proguard.py
+++ b/build/android/gyp/proguard.py
@@ -13,7 +13,9 @@ from util import build_utils
def DoProguard(options):
injars = options.input_path
outjars = options.output_path
- classpath = build_utils.ParseGypList(options.classpath)
+ classpath = []
+ for arg in options.classpath:
+ classpath += build_utils.ParseGypList(arg)
classpath = list(set(classpath))
libraryjars = ':'.join(classpath)
# proguard does its own dependency checking, which can be avoided by deleting
@@ -29,8 +31,10 @@ def DoProguard(options):
build_utils.CheckOutput(proguard_cmd, print_stdout=True)
-def main():
+def main(args):
+ args = build_utils.ExpandFileArgs(args)
parser = optparse.OptionParser()
+ build_utils.AddDepfileOption(parser)
parser.add_option('--proguard-path',
help='Path to the proguard executable.')
parser.add_option('--input-path',
@@ -38,16 +42,22 @@ def main():
parser.add_option('--output-path', help='Path to the generated .jar file.')
parser.add_option('--proguard-config',
help='Path to the proguard configuration file.')
- parser.add_option('--classpath', help="Classpath for proguard.")
+ parser.add_option('--classpath', action='append',
+ help="Classpath for proguard.")
parser.add_option('--stamp', help='Path to touch on success.')
- options, _ = parser.parse_args()
+ options, _ = parser.parse_args(args)
DoProguard(options)
+ if options.depfile:
+ build_utils.WriteDepfile(
+ options.depfile,
+ build_utils.GetPythonDependencies())
+
if options.stamp:
build_utils.Touch(options.stamp)
if __name__ == '__main__':
- sys.exit(main())
+ sys.exit(main(sys.argv[1:]))
diff --git a/build/config/android/internal_rules.gni b/build/config/android/internal_rules.gni
index 1820ff8..376b4fa0 100644
--- a/build/config/android/internal_rules.gni
+++ b/build/config/android/internal_rules.gni
@@ -11,6 +11,9 @@ rebased_android_sdk = rebase_path(android_sdk, root_build_dir)
rebased_android_sdk_root = rebase_path(android_sdk_root, root_build_dir)
rebased_android_sdk_build_tools = rebase_path(android_sdk_build_tools, root_build_dir)
+android_sdk_jar = "$android_sdk/android.jar"
+rebased_android_sdk_jar = rebase_path(android_sdk_jar, root_build_dir)
+
template("android_lint") {
jar_path = invoker.jar_path
android_manifest = invoker.android_manifest
@@ -332,6 +335,72 @@ template("create_apk") {
}
}
+template("java_prebuilt") {
+ _input_jar_path = invoker.input_jar_path
+ _output_jar_path = invoker.output_jar_path
+ _jar_toc_path = _output_jar_path + ".TOC"
+
+ assert(invoker.build_config != "")
+
+ if (defined(invoker.proguard_preprocess) && invoker.proguard_preprocess) {
+ _proguard_jar_path = "$android_sdk_root/tools/proguard/lib/proguard.jar"
+ _proguard_config_path = invoker.proguard_config
+ _build_config = invoker.build_config
+ _rebased_build_config = rebase_path(_build_config, root_build_dir)
+ action("${target_name}__proguard_process") {
+ script = "//build/android/gyp/proguard.py"
+ inputs = [
+ android_sdk_jar,
+ _proguard_jar_path,
+ _build_config,
+ _input_jar_path,
+ _proguard_config_path,
+ ]
+ depfile = "${target_gen_dir}/${target_name}.d"
+ outputs = [
+ depfile,
+ _output_jar_path,
+ ]
+ args = [
+ "--depfile", rebase_path(depfile, root_build_dir),
+ "--proguard-path", rebase_path(_proguard_jar_path, root_build_dir),
+ "--input-path", rebase_path(_input_jar_path, root_build_dir),
+ "--output-path", rebase_path(_output_jar_path, root_build_dir),
+ "--proguard-config", rebase_path(_proguard_config_path, root_build_dir),
+ "--classpath", rebased_android_sdk_jar,
+ "--classpath=@FileArg($_rebased_build_config:javac:classpath)",
+ ]
+ }
+ } else {
+ copy("${target_name}__copy_jar") {
+ sources = [_input_jar_path]
+ outputs = [_output_jar_path]
+ }
+ }
+
+ action("${target_name}__jar_toc") {
+ script = "//build/android/gyp/jar_toc.py"
+ depfile = "$target_gen_dir/$target_name.d"
+ outputs = [
+ depfile,
+ _jar_toc_path,
+ _jar_toc_path + ".md5.stamp"
+ ]
+ inputs = [ _output_jar_path ]
+ args = [
+ "--depfile", rebase_path(depfile, root_build_dir),
+ "--jar-path", rebase_path(_output_jar_path, root_build_dir),
+ "--toc-path", rebase_path(_jar_toc_path, root_build_dir),
+ ]
+ }
+
+ group(target_name) {
+ deps = [
+ ":${target_name}__jar_toc"
+ ]
+ }
+}
+
# Compiles and jars a set of java files.
#
# Outputs:
@@ -352,93 +421,83 @@ template("java_library") {
assert(defined(invoker.build_config))
assert(defined(invoker.jar_path))
- java_files = invoker.java_files
- jar_path = invoker.jar_path
- jar_toc_path = jar_path + ".TOC"
+ _java_files = invoker.java_files
+ _final_jar_path = invoker.jar_path
+ _intermediate_jar_path = "$target_gen_dir/$target_name.initial.jar"
- build_config = invoker.build_config
+ _build_config = invoker.build_config
- jar_excluded_patterns = []
+ _jar_excluded_patterns = []
if (defined(invoker.jar_excluded_patterns)) {
- jar_excluded_patterns += invoker.jar_excluded_patterns
+ _jar_excluded_patterns += invoker.jar_excluded_patterns
}
- chromium_code = false
+ _chromium_code = false
if (defined(invoker.chromium_code)) {
- chromium_code = chromium_code || invoker.chromium_code
+ _chromium_code = invoker.chromium_code
}
- srcjar_deps = []
+ _srcjar_deps = []
if (defined(invoker.srcjar_deps)) {
- srcjar_deps += invoker.srcjar_deps
+ _srcjar_deps += invoker.srcjar_deps
}
- java_srcjars = []
- foreach(dep, srcjar_deps) {
- dep_gen_dir = get_label_info(dep, "target_gen_dir")
- dep_name = get_label_info(dep, "name")
- java_srcjars += [ "$dep_gen_dir/$dep_name.srcjar" ]
+ _java_srcjars = []
+ foreach(dep, _srcjar_deps) {
+ _dep_gen_dir = get_label_info(dep, "target_gen_dir")
+ _dep_name = get_label_info(dep, "name")
+ _java_srcjars += [ "$_dep_gen_dir/$_dep_name.srcjar" ]
}
# Mark srcjar_deps as used.
- assert(srcjar_deps == [] || srcjar_deps != [])
+ assert(_srcjar_deps == [] || true)
- rebase_jar_path = rebase_path(jar_path, root_build_dir)
-
- system_jars = [ "${android_sdk}/android.jar" ]
+ _system_jars = [ android_sdk_jar ]
action("${target_name}__javac") {
script = "//build/android/gyp/javac.py"
depfile = "$target_gen_dir/$target_name.d"
outputs = [
depfile,
- jar_path,
- jar_path + ".md5.stamp"
+ _intermediate_jar_path,
+ _intermediate_jar_path + ".md5.stamp"
]
- sources = java_files + java_srcjars
- inputs = system_jars + [ build_config ]
-
- rebase_system_jars = rebase_path(system_jars, root_build_dir)
- rebase_java_srcjars = rebase_path(java_srcjars, root_build_dir)
- rebase_build_config = rebase_path(build_config, root_build_dir)
- rebase_depfile = rebase_path(depfile, root_build_dir)
+ sources = _java_files + _java_srcjars
+ inputs = _system_jars + [ _build_config ]
+
+ _rebased_system_jars = rebase_path(_system_jars, root_build_dir)
+ _rebased_java_srcjars = rebase_path(_java_srcjars, root_build_dir)
+ _rebased_build_config = rebase_path(_build_config, root_build_dir)
+ _rebased_depfile = rebase_path(depfile, root_build_dir)
+ _rebased_jar_path = rebase_path(_intermediate_jar_path, root_build_dir)
args = [
- "--depfile=$rebase_depfile",
- "--classpath=$rebase_system_jars",
- "--classpath=@FileArg($rebase_build_config:javac:classpath)",
- "--jar-path=$rebase_jar_path",
- "--java-srcjars=$rebase_java_srcjars",
- "--java-srcjars=@FileArg($rebase_build_config:javac:srcjars)",
- "--jar-excluded-classes=$jar_excluded_patterns",
+ "--depfile=$_rebased_depfile",
+ "--classpath=$_rebased_system_jars",
+ "--classpath=@FileArg($_rebased_build_config:javac:classpath)",
+ "--jar-path=$_rebased_jar_path",
+ "--java-srcjars=$_rebased_java_srcjars",
+ "--java-srcjars=@FileArg($_rebased_build_config:javac:srcjars)",
+ "--jar-excluded-classes=$_jar_excluded_patterns",
]
- if (chromium_code) {
+ if (_chromium_code) {
args += [ "--chromium-code" ]
}
- args += rebase_path(java_files, root_build_dir)
+ args += rebase_path(_java_files, root_build_dir)
}
- # TODO(cjhopman): proguard
-
- rebase_jar_toc_path = rebase_path(jar_toc_path, root_build_dir)
- action("${target_name}__jar_toc") {
- script = "//build/android/gyp/jar_toc.py"
- depfile = "$target_gen_dir/$target_name.d"
- outputs = [
- depfile,
- jar_toc_path,
- jar_toc_path + ".md5.stamp"
- ]
- inputs = [ jar_path ]
- args = [
- "--depfile", rebase_path(depfile, root_build_dir),
- "--jar-path=${rebase_jar_path}",
- "--toc-path=${rebase_jar_toc_path}",
- ]
+ java_prebuilt("${target_name}__finish") {
+ build_config = _build_config
+ input_jar_path = _intermediate_jar_path
+ output_jar_path = _final_jar_path
+ if (defined(invoker.proguard_preprocess) && invoker.proguard_preprocess) {
+ proguard_preprocess = invoker.proguard_preprocess
+ proguard_config = invoker.proguard_config
+ }
}
group(target_name) {
deps = [
":${target_name}__javac",
- ":${target_name}__jar_toc",
+ ":${target_name}__finish",
]
}
}
@@ -476,6 +535,10 @@ template("android_java_library") {
if (defined(invoker.srcjar_deps)) {
srcjar_deps = invoker.srcjar_deps
}
+ if (defined(invoker.proguard_preprocess) && invoker.proguard_preprocess) {
+ proguard_preprocess = invoker.proguard_preprocess
+ proguard_config = invoker.proguard_config
+ }
}
if (defined(invoker.chromium_code) && invoker.chromium_code) {
@@ -500,7 +563,6 @@ template("android_java_library") {
}
}
-
# Runs process_resources.py
template("process_resources") {
zip_path = invoker.zip_path
diff --git a/build/config/android/rules.gni b/build/config/android/rules.gni
index d4c4ec7..43d79d0 100644
--- a/build/config/android/rules.gni
+++ b/build/config/android/rules.gni
@@ -408,6 +408,9 @@ template("java_strings_grd") {
# chromium_code: If true, extra static analysis warning/errors will be enabled.
# jar_excluded_patterns: List of patterns of .class files to exclude from the
# final jar.
+# proguard_preprocess: If true, proguard preprocessing will be run. This can
+# be used to remove unwanted parts of the library.
+# proguard_config: Path to the proguard config for preprocessing.
#
# Example
# android_library("foo_java") {
@@ -454,6 +457,11 @@ template("android_library") {
java_files = invoker.java_files
build_config = build_config
+ if (defined(invoker.proguard_preprocess) && invoker.proguard_preprocess) {
+ proguard_preprocess = true
+ proguard_config = invoker.proguard_config
+ }
+
if (defined(invoker.jar_excluded_patterns)) {
jar_excluded_patterns = invoker.jar_excluded_patterns
}
@@ -465,6 +473,72 @@ template("android_library") {
}
+# Declare an Android library target for a prebuilt jar
+#
+# This target creates an Android library containing java code and Android
+# resources.
+#
+# Variables
+# deps: Specifies the dependencies of this target. Java targets in this list
+# will be added to the javac classpath. Android resources in dependencies
+# will be used when building this library.
+# jar_path: Path to the prebuilt jar.
+# proguard_preprocess: If true, proguard preprocessing will be run. This can
+# be used to remove unwanted parts of the library.
+# proguard_config: Path to the proguard config for preprocessing.
+#
+# Example
+# android_java_prebuilt("foo_java") {
+# jar_path = "foo.jar"
+# deps = [
+# ":foo_resources",
+# ":bar_java"
+# ]
+# }
+template("android_java_prebuilt") {
+ assert(defined(invoker.jar_path))
+ _base_path = "${target_gen_dir}/$target_name"
+ _jar_path = _base_path + ".jar"
+ _dex_path = _base_path + ".dex.jar"
+ _build_config = _base_path + ".build_config"
+
+ write_build_config("${target_name}__build_config") {
+ type = "android_library"
+
+ deps = []
+ if (defined(invoker.deps)) {
+ deps += invoker.deps
+ }
+ build_config = _build_config
+ jar_path = _jar_path
+ dex_path = _dex_path
+ }
+
+ java_prebuilt("${target_name}__process_jar") {
+ if (defined(invoker.proguard_preprocess) && invoker.proguard_preprocess) {
+ proguard_preprocess = true
+ proguard_config = invoker.proguard_config
+ }
+
+ build_config = _build_config
+ input_jar_path = invoker.jar_path
+ output_jar_path = _jar_path
+ }
+
+ dex("${target_name}__dex") {
+ sources = [_jar_path]
+ output = _dex_path
+ }
+
+ group(target_name) {
+ deps = [
+ ":${target_name}__dex",
+ ]
+ }
+}
+
+
+
# Declare an Android apk target
#
# This target creates an Android APK containing java code, resources, assets,
diff --git a/build/secondary/third_party/android_tools/BUILD.gn b/build/secondary/third_party/android_tools/BUILD.gn
index 44a10d9..1a54e15 100644
--- a/build/secondary/third_party/android_tools/BUILD.gn
+++ b/build/secondary/third_party/android_tools/BUILD.gn
@@ -2,6 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import("//build/config/android/rules.gni")
+
config("cpu_features_include") {
include_dirs = [ "ndk/sources/android/cpufeatures" ]
}
@@ -15,3 +17,47 @@ source_set("cpu_features") {
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
}
+
+android_java_prebuilt("android_gcm_java") {
+ jar_path = "$android_sdk_root/extras/google/gcm/gcm-client/dist/gcm.jar"
+}
+
+android_java_prebuilt("uiautomator_java") {
+ jar_path = "$android_sdk/uiautomator.jar"
+}
+
+android_java_prebuilt("android_support_v13_java") {
+ jar_path = "$android_sdk_root/extras/android/support/v13/android-support-v13.jar"
+}
+
+android_resources("android_support_v7_appcompat_resources") {
+ v14_verify_only = true
+ resource_dirs = [
+ "$android_sdk_root/extras/android/support/v7/appcompat/res"
+ ]
+ custom_package = "android.support.v7.appcompat"
+}
+
+android_java_prebuilt("android_support_v7_appcompat_java") {
+ deps = [ ":android_support_v7_appcompat_resources" ]
+ jar_path = "$android_sdk_root/extras/android/support/v7/appcompat/libs/android-support-v7-appcompat.jar"
+}
+
+android_resources("android_support_v7_mediarouter_resources") {
+ v14_verify_only = true
+ resource_dirs = [
+ "$android_sdk_root/extras/android/support/v7/mediarouter/res"
+ ]
+ deps = [
+ ":android_support_v7_appcompat_resources",
+ ]
+ custom_package = "android.support.v7.mediarouter"
+}
+
+android_java_prebuilt("android_support_v7_mediarouter_java") {
+ deps = [
+ ":android_support_v7_mediarouter_resources",
+ ":android_support_v7_appcompat_java",
+ ]
+ jar_path = "$android_sdk_root/extras/android/support/v7/mediarouter/libs/android-support-v7-mediarouter.jar"
+}
diff --git a/third_party/guava/BUILD.gn b/third_party/guava/BUILD.gn
index 2713ac3..9e4567f 100644
--- a/third_party/guava/BUILD.gn
+++ b/third_party/guava/BUILD.gn
@@ -400,4 +400,7 @@ android_library("guava_javalib") {
"src/guava/src/com/google/common/eventbus/EventBus.java",
"src/guava/src/com/google/common/eventbus/AsyncEventBus.java",
]
+
+ proguard_preprocess = true
+ proguard_config = "proguard.flags"
}