summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-28 05:25:06 +0000
committerrsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-28 05:25:06 +0000
commit3354c312c47227dd6529abae0b755afd3fe0fabb (patch)
tree24207f9301d9ff3fc97fff397baf3a3a8ff3b885
parenta263b0455b691f913c9d246c20c4970daf465271 (diff)
downloadchromium_src-3354c312c47227dd6529abae0b755afd3fe0fabb.zip
chromium_src-3354c312c47227dd6529abae0b755afd3fe0fabb.tar.gz
chromium_src-3354c312c47227dd6529abae0b755afd3fe0fabb.tar.bz2
Revert 123894 - Remove hand-rolled protobufs generation; enable rel paths in protoc.gypi
protoc.gypi now accepts a relative path to handle the way that protoc_out_dir is applied to build the generated path. Remove the 'cacheinvalidation_proto_cpp' target and instead generate a static_library to begin with. Simplify all steps by removing the actions and including the protoc.gypi file. BUG=113339 Review URL: http://codereview.chromium.org/9378041 TBR=kushi.p@gmail.com Review URL: https://chromiumcodereview.appspot.com/9480022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@123896 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--build/protoc.gypi29
-rw-r--r--third_party/cacheinvalidation/cacheinvalidation.gyp86
2 files changed, 78 insertions, 37 deletions
diff --git a/build/protoc.gypi b/build/protoc.gypi
index 5c1fd2b..555c5be 100644
--- a/build/protoc.gypi
+++ b/build/protoc.gypi
@@ -1,4 +1,4 @@
-# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Copyright (c) 2011 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.
@@ -32,24 +32,8 @@
# like:
# #include "dir/for/my_proto_lib/foo.pb.h"
#
-# The 'proto_relpath' variable specifies another way to provide the path
-# suffix that files are generated under. 'proto_relpath' exists because there
-# are some protos which import using qualified paths, rather than the more
-# common relative import.
-#
-# By using 'proto_relpath', projects can continue to use qualified imports
-# instead of enforcing an import style through this gypi. If provided,
-# 'proto_relpath' must have a trailing slash.
-#
# Implementation notes:
-# A 'proto_out_dir' of 'foo/bar', with no 'proto_relpath' provided, produces:
-# <(SHARED_INTERMEDIATE_DIR)/protoc_out/foo/bar/{file1,file2}.pb.{cc,h}
-# <(SHARED_INTERMEDIATE_DIR)/pyproto/foo/bar/{file1,file2}_pb2.py
-#
-# By setting 'proto_relpath' to 'foo/bar', with a 'proto_out_dir' of '', the
-# protos can use qualified imports instead of relative imports,
-# e.g. #import "foo/bar/file2.proto"; instead of #import "file2.proto";
-# A 'proto_out_dir' of '', with a 'proto_relpath' of 'foo/bar/' produces:
+# A proto_out_dir of foo/bar produces
# <(SHARED_INTERMEDIATE_DIR)/protoc_out/foo/bar/{file1,file2}.pb.{cc,h}
# <(SHARED_INTERMEDIATE_DIR)/pyproto/foo/bar/{file1,file2}_pb2.py
@@ -59,7 +43,6 @@
'cc_dir': '<(SHARED_INTERMEDIATE_DIR)/protoc_out/<(proto_out_dir)',
'py_dir': '<(PRODUCT_DIR)/pyproto/<(proto_out_dir)',
'proto_in_dir%': '.',
- 'proto_relpath%': '',
},
'rules': [
{
@@ -69,16 +52,16 @@
'<(protoc)',
],
'outputs': [
- '<(py_dir)/<(proto_relpath)<(RULE_INPUT_ROOT)_pb2.py',
- '<(cc_dir)/<(proto_relpath)<(RULE_INPUT_ROOT).pb.cc',
- '<(cc_dir)/<(proto_relpath)<(RULE_INPUT_ROOT).pb.h',
+ '<(py_dir)/<(RULE_INPUT_ROOT)_pb2.py',
+ '<(cc_dir)/<(RULE_INPUT_ROOT).pb.cc',
+ '<(cc_dir)/<(RULE_INPUT_ROOT).pb.h',
],
'action': [
'<(protoc)',
'--proto_path=<(proto_in_dir)',
# Naively you'd use <(RULE_INPUT_PATH) here, but protoc requires
# --proto_path is a strict prefix of the path given as an argument.
- '<(proto_in_dir)/<(proto_relpath)<(RULE_INPUT_ROOT)<(RULE_INPUT_EXT)',
+ '<(proto_in_dir)/<(RULE_INPUT_ROOT)<(RULE_INPUT_EXT)',
'--cpp_out=<(cc_dir)',
'--python_out=<(py_dir)',
],
diff --git a/third_party/cacheinvalidation/cacheinvalidation.gyp b/third_party/cacheinvalidation/cacheinvalidation.gyp
index 061c4cc..dce6f6e 100644
--- a/third_party/cacheinvalidation/cacheinvalidation.gyp
+++ b/third_party/cacheinvalidation/cacheinvalidation.gyp
@@ -15,13 +15,17 @@
# we don't need this variable.
# TODO(ghc): Remove v2/ dir and move all files up a level.
'proto_dir_relpath': 'google/cacheinvalidation/v2',
+ # Where files generated from proto files are put.
+ 'protoc_out_dir': '<(SHARED_INTERMEDIATE_DIR)/protoc_out',
+ # The path to the protoc executable.
+ 'protoc': '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)protoc<(EXECUTABLE_SUFFIX)',
},
'targets': [
# The rule/action to generate files from the cacheinvalidation proto
- # files and package them into a static library.
+ # files.
{
'target_name': 'cacheinvalidation_proto',
- 'type': 'static_library',
+ 'type': 'none',
'sources': [
'<(proto_dir_root)/<(proto_dir_relpath)/client.proto',
'<(proto_dir_root)/<(proto_dir_relpath)/client_gateway.proto',
@@ -29,18 +33,68 @@
'<(proto_dir_root)/<(proto_dir_relpath)/client_test_internal.proto',
'<(proto_dir_root)/<(proto_dir_relpath)/types.proto',
],
- 'variables': {
- 'proto_in_dir': '<(proto_dir_root)',
- 'proto_out_dir': '',
- 'proto_relpath': '<(proto_dir_relpath)/',
- # This is necessary because these protos import with
- # qualified paths, such as:
- # #import "google/cacheinvalidation/v2/client_protocol.proto"
- # rather than the more common form of:
- # #import "client_protocol.proto"
- # NOTE: The trailing slash is required, see build/protoc.gypi
+ # TODO(akalin): This block was copied from the sync_proto target
+ # from chrome.gyp. Decomp the shared blocks out somehow.
+ 'rules': [
+ {
+ 'rule_name': 'genproto',
+ 'extension': 'proto',
+ 'inputs': [
+ '<(protoc)',
+ ],
+ 'outputs': [
+ '<(protoc_out_dir)/<(proto_dir_relpath)/<(RULE_INPUT_ROOT).pb.h',
+ '<(protoc_out_dir)/<(proto_dir_relpath)/<(RULE_INPUT_ROOT).pb.cc',
+ ],
+ 'action': [
+ '<(protoc)',
+ '--proto_path=<(proto_dir_root)',
+ # This path needs to be prefixed by proto_path, so we can't
+ # use RULE_INPUT_PATH (which is an absolute path).
+ '<(proto_dir_root)/<(proto_dir_relpath)/<(RULE_INPUT_NAME)',
+ '--cpp_out=<(protoc_out_dir)',
+ ],
+ 'message': 'Generating C++ code from <(RULE_INPUT_PATH)',
+ },
+ ],
+ 'dependencies': [
+ '../../third_party/protobuf/protobuf.gyp:protoc#host',
+ ],
+ },
+ # The C++ files generated from the cache invalidation protocol buffers.
+ {
+ 'target_name': 'cacheinvalidation_proto_cpp',
+ 'type': 'static_library',
+ 'sources': [
+ '<(protoc_out_dir)/<(proto_dir_relpath)/client.pb.h',
+ '<(protoc_out_dir)/<(proto_dir_relpath)/client.pb.cc',
+ '<(protoc_out_dir)/<(proto_dir_relpath)/client_gateway.pb.h',
+ '<(protoc_out_dir)/<(proto_dir_relpath)/client_gateway.pb.cc',
+ '<(protoc_out_dir)/<(proto_dir_relpath)/client_protocol.pb.h',
+ '<(protoc_out_dir)/<(proto_dir_relpath)/client_protocol.pb.cc',
+ '<(protoc_out_dir)/<(proto_dir_relpath)/client_test_internal.pb.h',
+ '<(protoc_out_dir)/<(proto_dir_relpath)/client_test_internal.pb.cc',
+ '<(protoc_out_dir)/<(proto_dir_relpath)/types.pb.h',
+ '<(protoc_out_dir)/<(proto_dir_relpath)/types.pb.cc',
+ ],
+ 'dependencies': [
+ '../../third_party/protobuf/protobuf.gyp:protobuf_lite',
+ 'cacheinvalidation_proto',
+ ],
+ 'include_dirs': [
+ '<(protoc_out_dir)',
+ ],
+ 'direct_dependent_settings': {
+ 'include_dirs': [
+ '<(protoc_out_dir)',
+ ],
},
- 'includes': [ '../../build/protoc.gypi' ],
+ 'export_dependent_settings': [
+ '../../third_party/protobuf/protobuf.gyp:protobuf_lite',
+ ],
+ # This target exports a hard dependency because it contains generated
+ # header files.
+ 'hard_dependency': 1,
},
# The main cache invalidation library. External clients should depend
# only on this.
@@ -116,7 +170,11 @@
'dependencies': [
'../../base/base.gyp:base',
'cacheinvalidation_proto',
+ 'cacheinvalidation_proto_cpp',
],
+ # This target exports a hard dependency because its include files
+ # include generated header files from cache_invalidation_proto_cpp.
+ 'hard_dependency': 1,
'direct_dependent_settings': {
'include_dirs': [
'./overrides',
@@ -125,7 +183,7 @@
},
'export_dependent_settings': [
'../../base/base.gyp:base',
- 'cacheinvalidation_proto',
+ 'cacheinvalidation_proto_cpp',
],
},
# Unittests for the cache invalidation library.