Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Unified Diff: build/config/android/rules.gni

Issue 580343002: Add proto_java_library to gn (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: = Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | build/protoc_java.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/config/android/rules.gni
diff --git a/build/config/android/rules.gni b/build/config/android/rules.gni
index 4e9f3a81002609eaea2bb9d49922ad5eb925d410..3c09a585c104dc688b401adae3b2aa5f363a5747 100644
--- a/build/config/android/rules.gni
+++ b/build/config/android/rules.gni
@@ -1091,3 +1091,55 @@ template("create_native_executable_dist") {
deps = final_deps
}
}
+
+
+# Compile a protocol buffer to java.
+#
+# This generates java files from protocol buffers and creates an Android library
+# containing the classes.
+#
+# Variables
+# sources: Paths to .proto files to compile.
+# proto_path: Root directory of .proto files.
+#
+# Example:
+# proto_java_library("foo_proto_java") {
+# proto_path = [ "src/foo" ]
+# sources = [ "$proto_path/foo.proto" ]
+# }
+template("proto_java_library") {
+ _protoc_dep = "//third_party/android_protobuf:android_protoc($host_toolchain)"
+ _protoc_out_dir = get_label_info(_protoc_dep, "root_out_dir")
+ _protoc_bin = "$_protoc_out_dir/android_protoc"
+ _proto_path = invoker.proto_path
+
+ _template_name = target_name
+
+ action("${_template_name}__protoc_java") {
+ srcjar_path = "$target_gen_dir/$target_name.srcjar"
+ script = "//build/protoc_java.py"
+ deps = [
+ _protoc_dep
+ ]
+ sources = invoker.sources
+ depfile = "$target_gen_dir/$target_name.d"
+ outputs = [
+ depfile,
+ srcjar_path,
+ ]
+ args = [
+ "--depfile", rebase_path(depfile, root_build_dir),
+ "--protoc", rebase_path(_protoc_bin, root_build_dir),
+ "--proto-path", rebase_path(_proto_path, root_build_dir),
+ "--srcjar", rebase_path(srcjar_path, root_build_dir),
+ ] + rebase_path(sources, root_build_dir)
+ }
+
+ android_library(target_name) {
+ java_files = []
+ srcjar_deps = [ ":${_template_name}__protoc_java" ]
+ deps = [
+ "//third_party/android_protobuf:protobuf_nano_javalib",
+ ]
+ }
+}
« no previous file with comments | « no previous file | build/protoc_java.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698