summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build/all_android.gyp4
-rw-r--r--build/android/empty/src/.keep6
-rw-r--r--build/java.gypi2
-rw-r--r--build/protoc.gypi3
-rw-r--r--build/protoc_java.gypi79
-rwxr-xr-xbuild/protoc_java.py56
-rw-r--r--third_party/cacheinvalidation/cacheinvalidation.gyp83
-rw-r--r--third_party/protobuf/README.chromium2
-rw-r--r--third_party/protobuf/protobuf.gyp2
9 files changed, 226 insertions, 11 deletions
diff --git a/build/all_android.gyp b/build/all_android.gyp
index 75c4a37..2d58e50 100644
--- a/build/all_android.gyp
+++ b/build/all_android.gyp
@@ -22,6 +22,10 @@
'android_builder_tests',
'../android_webview/android_webview.gyp:android_webview_apk',
'../chrome/chrome.gyp:chromium_testshell',
+ # TODO(nyquist) This should instead by a target for sync when all of
+ # the sync-related code for Android has been upstreamed.
+ # See http://crbug.com/159203
+ '../third_party/cacheinvalidation/cacheinvalidation.gyp:cacheinvalidation_javalib',
],
}, # target_name: All
{
diff --git a/build/android/empty/src/.keep b/build/android/empty/src/.keep
new file mode 100644
index 0000000..0f710b6
--- /dev/null
+++ b/build/android/empty/src/.keep
@@ -0,0 +1,6 @@
+This is a file that needs to live here until http://crbug.com/158155 has
+been fixed.
+
+The ant build system requires that a src folder is always present, and for
+some of our targets that is not the case. Giving it an empty src-folder works
+nicely though.
diff --git a/build/java.gypi b/build/java.gypi
index 0f180b2..e434206 100644
--- a/build/java.gypi
+++ b/build/java.gypi
@@ -34,7 +34,7 @@
# included in the 'inputs' list (unlike additional_src_dirs).
# input_jars_paths - The path to jars to be included in the classpath. This
# should be filled automatically by depending on the appropriate targets.
-# include_files - A list of specific files to include. This is by default
+# javac_includes - A list of specific files to include. This is by default
# empty, which leads to inclusion of all files specified. May include
# wildcard, and supports '**/' for recursive path wildcards, ie.:
# '**/MyFileRegardlessOfDirectory.java', '**/IncludedPrefix*.java'.
diff --git a/build/protoc.gypi b/build/protoc.gypi
index e956718..a20dce0 100644
--- a/build/protoc.gypi
+++ b/build/protoc.gypi
@@ -3,7 +3,8 @@
# found in the LICENSE file.
# This file is meant to be included into a target to provide a rule
-# to invoke protoc in a consistent manner.
+# to invoke protoc in a consistent manner. For Java-targets, see
+# protoc_java.gypi.
#
# To use this, create a gyp target with the following form:
# {
diff --git a/build/protoc_java.gypi b/build/protoc_java.gypi
new file mode 100644
index 0000000..1d2d697
--- /dev/null
+++ b/build/protoc_java.gypi
@@ -0,0 +1,79 @@
+# Copyright (c) 2012 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.
+
+# This file is meant to be included into a target to provide a rule
+# to invoke protoc in a consistent manner. This is only to be included
+# for Java targets. When including this file, a .jar-file will be generated.
+# For other targets, see protoc.gypi.
+#
+# To use this, create a gyp target with the following form:
+# {
+# 'target_name': 'my_proto_lib',
+# 'sources': [
+# 'foo.proto',
+# 'bar.proto',
+# ],
+# 'variables': {
+# 'proto_in_dir': '.'
+# },
+# 'includes': ['path/to/this/gypi/file'],
+# }
+#
+# The 'proto_in_dir' variable must be the relative path to the
+# directory containing the .proto files. If left out, it defaults to '.'.
+#
+# The 'output_java_files' variable specifies a list of output files that will
+# be generated. It is based on the package and java_outer_classname fields in
+# the proto. All the values must be prefixed with >(java_out_dir), since that
+# is the root directory of all the output.
+#
+# Implementation notes:
+# A target_name of foo and proto-specified 'package' java.package.path produces:
+# <(PRODUCT_DIR)/java_proto/foo/{java/package/path/}{Foo,Bar}.java
+# where Foo and Bar are taken from 'java_outer_classname' of the protos.
+#
+# How the .jar-file is created is different than how protoc is used for other
+# targets, and as such, this lives in its own file.
+
+{
+ 'variables': {
+ 'protoc': '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)protoc<(EXECUTABLE_SUFFIX)',
+ 'java_out_dir': '<(PRODUCT_DIR)/java_proto/<(_target_name)/src',
+ 'proto_in_dir%': '.',
+ 'stamp_file': '<(java_out_dir).stamp',
+ # Variables needed by java.gypi below.
+ 'package_name': '<(_target_name)',
+ 'java_in_dir': '<(DEPTH)/build/android/empty',
+ 'script': '<(DEPTH)/build/protoc_java.py',
+ 'generated_src_dirs': ['<(java_out_dir)'],
+ },
+ 'actions': [
+ {
+ 'action_name': 'genproto_java',
+ 'inputs': [
+ '<(script)',
+ '<(protoc)',
+ '<@(_sources)',
+ ],
+ # We do not know the names of the generated files, so we use a stamp.
+ 'outputs': [
+ '<(stamp_file)',
+ ],
+ 'action': [
+ '<(script)',
+ '<(protoc)',
+ '<(proto_in_dir)',
+ '<(java_out_dir)',
+ '<(stamp_file)',
+ '<@(_sources)',
+ ],
+ 'message': 'Generating Java code from <(proto_in_dir)',
+ },
+ ],
+ 'dependencies': [
+ '<(DEPTH)/third_party/protobuf/protobuf.gyp:protoc#host',
+ '<(DEPTH)/third_party/protobuf/protobuf.gyp:protobuf_lite_javalib',
+ ],
+ 'includes': [ 'java.gypi' ],
+}
diff --git a/build/protoc_java.py b/build/protoc_java.py
new file mode 100755
index 0000000..42e2044
--- /dev/null
+++ b/build/protoc_java.py
@@ -0,0 +1,56 @@
+#!/usr/bin/env python
+# Copyright (c) 2012 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.
+
+"""Generate java source files from protobufs
+
+Usage:
+ protoc_java.py {protoc} {proto_path} {java_out} {stamp_file} {proto_files}
+
+This is a helper file for the genproto_java action in protoc_java.gypi.
+
+It performs the following steps:
+1. Deletes all old sources (ensures deleted classes are not part of new jars).
+2. Creates source directory.
+3. Generates Java files using protoc.
+4. Creates a new stamp file.
+"""
+
+import os
+import shutil
+import subprocess
+import sys
+
+def main(argv):
+ if len(argv) < 5:
+ usage()
+ return 1
+
+ protoc_path, proto_path, java_out, stamp_file = argv[1:5]
+ proto_files = argv[5:]
+
+ # Delete all old sources
+ if os.path.exists(java_out):
+ shutil.rmtree(java_out)
+
+ # Create source directory
+ os.makedirs(java_out)
+
+ # Generate Java files using protoc
+ ret = subprocess.call(
+ [protoc_path, '--proto_path', proto_path, '--java_out', java_out]
+ + proto_files)
+
+ if ret == 0:
+ # Create a new stamp file
+ with file(stamp_file, 'a'):
+ os.utime(stamp_file, None)
+
+ return ret
+
+def usage():
+ print(__doc__);
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv))
diff --git a/third_party/cacheinvalidation/cacheinvalidation.gyp b/third_party/cacheinvalidation/cacheinvalidation.gyp
index 2e71733..84aeb96 100644
--- a/third_party/cacheinvalidation/cacheinvalidation.gyp
+++ b/third_party/cacheinvalidation/cacheinvalidation.gyp
@@ -7,19 +7,22 @@
# This library should build cleanly with the extra warnings turned on
# for Chromium.
'chromium_code': 1,
- # The relative path of the cacheinvalidation proto files from 'src'.
- # TODO(akalin): Add a RULE_INPUT_DIR predefined variable to gyp so
- # we don't need this variable.
- 'proto_dir_relpath': 'google/cacheinvalidation',
- # Where files generated from proto files are put.
- 'proto_in_dir': 'src/<(proto_dir_relpath)',
- 'proto_out_dir': '<(proto_dir_relpath)',
},
'targets': [
# The C++ files generated from the cache invalidation protocol buffers.
{
'target_name': 'cacheinvalidation_proto_cpp',
'type': 'static_library',
+ 'variables': {
+ # The relative path of the cacheinvalidation proto files from this
+ # gyp-file.
+ # TODO(akalin): Add a RULE_INPUT_DIR predefined variable to gyp so
+ # we don't need this variable.
+ 'proto_dir_relpath': 'google/cacheinvalidation',
+ # Where files generated from proto files are put.
+ 'proto_in_dir': 'src/<(proto_dir_relpath)',
+ 'proto_out_dir': '<(proto_dir_relpath)',
+ },
'sources': [
'<(proto_in_dir)/client.proto',
'<(proto_in_dir)/client_gateway.proto',
@@ -166,5 +169,71 @@
},
],
}],
+ ['OS == "android"', {
+ 'targets': [
+ {
+ 'target_name': 'cacheinvalidation_proto_java',
+ 'type': 'none',
+ 'variables': {
+ 'proto_in_dir': '../../third_party/cacheinvalidation/src/proto',
+ },
+ 'sources': [
+ '<(proto_in_dir)/android_channel.proto',
+ '<(proto_in_dir)/android_service.proto',
+ '<(proto_in_dir)/android_state.proto',
+ '<(proto_in_dir)/channel.proto',
+ '<(proto_in_dir)/channel_common.proto',
+ '<(proto_in_dir)/client.proto',
+ '<(proto_in_dir)/client_protocol.proto',
+ '<(proto_in_dir)/java_client.proto',
+ '<(proto_in_dir)/types.proto',
+ ],
+ 'includes': [ '../../build/protoc_java.gypi' ],
+ },
+ {
+ 'target_name': 'cacheinvalidation_javalib',
+ 'type': 'none',
+ 'dependencies': [
+ '../../third_party/android_tools/android_tools.gyp:android_gcm',
+ 'cacheinvalidation_aidl_javalib',
+ 'cacheinvalidation_guava_javalib',
+ 'cacheinvalidation_proto_java',
+ ],
+ 'variables': {
+ 'package_name': '<(_target_name)',
+ 'java_in_dir': '../../build/android/empty',
+ 'additional_src_dirs': [ 'src/java/' ],
+ },
+ 'includes': [ '../../build/java.gypi' ],
+ },
+ {
+ 'target_name': 'cacheinvalidation_aidl_javalib',
+ 'type': 'none',
+ 'variables': {
+ 'package_name': '<(_target_name)',
+ # TODO(shashishekhar): aidl_interface_file should be made optional.
+ 'aidl_interface_file':'<(android_sdk)/framework.aidl'
+ },
+ 'sources': [
+ 'src/java/com/google/ipc/invalidation/external/client/android/service/InvalidationService.aidl',
+ 'src/java/com/google/ipc/invalidation/external/client/android/service/ListenerService.aidl',
+ 'src/java/com/google/ipc/invalidation/testing/android/InvalidationTest.aidl',
+ ],
+ 'includes': [ '../../build/java_aidl.gypi' ],
+ },
+ # TODO(nyquist): Depend on guava from third_party/guava. See http://crbug.com/159873.
+ {
+ 'target_name': 'cacheinvalidation_guava_javalib',
+ 'type' : 'none',
+ 'all_dependent_settings': {
+ 'variables': {
+ 'input_jars_paths' : [
+ 'src/example-app-build/libs/guava-13.0.1.jar',
+ ],
+ }
+ }
+ },
+ ],
+ }],
],
}
diff --git a/third_party/protobuf/README.chromium b/third_party/protobuf/README.chromium
index 38b9936..2599737 100644
--- a/third_party/protobuf/README.chromium
+++ b/third_party/protobuf/README.chromium
@@ -29,5 +29,5 @@ not support unknown field retention.
The list of Java files included in the lite profile for Java is parsed from the
maven java/pom.xml by the script protobuf_lite_java_parse_pom.py. See
-'javac_includes' variable in protobuf_lite_java GYP target.
+'javac_includes' variable in protobuf_lite_javalib GYP target.
diff --git a/third_party/protobuf/protobuf.gyp b/third_party/protobuf/protobuf.gyp
index ccc763b..f337124 100644
--- a/third_party/protobuf/protobuf.gyp
+++ b/third_party/protobuf/protobuf.gyp
@@ -70,7 +70,7 @@
['OS=="android"', {
'targets': [
{
- 'target_name': 'protobuf_lite_java',
+ 'target_name': 'protobuf_lite_javalib',
'type' : 'none',
'dependencies': [
'protoc#host',