diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-18 21:52:15 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-18 21:52:15 +0000 |
commit | 6fa9e6f0c0fd3a66789de9df381cc16c36ca6da1 (patch) | |
tree | 6d8c997b1d030068d380184b381ea8bb6c552a02 /build/protoc.gypi | |
parent | f8cc62e64f6c43deb5973cadecf74e63d7162410 (diff) | |
download | chromium_src-6fa9e6f0c0fd3a66789de9df381cc16c36ca6da1.zip chromium_src-6fa9e6f0c0fd3a66789de9df381cc16c36ca6da1.tar.gz chromium_src-6fa9e6f0c0fd3a66789de9df381cc16c36ca6da1.tar.bz2 |
Unify gyp rules for running protoc.
- Add a protoc.gypi that can be gyp-included into any gyp file that
wants to build .proto files.
- Convert two remoting gyp files to use this new protoc.gypi.
(Also fixes a bug in one of those remoting gyp files; a mistaken path
was causing it to always rebuild under Xcode.)
Review URL: http://codereview.chromium.org/7621073
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97366 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'build/protoc.gypi')
-rw-r--r-- | build/protoc.gypi | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/build/protoc.gypi b/build/protoc.gypi new file mode 100644 index 0000000..d5df91f --- /dev/null +++ b/build/protoc.gypi @@ -0,0 +1,87 @@ +# 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. + +# This file is meant to be included into an target to provide a rule +# to invoke protoc in a consistent manner. +# +# To use this, create a gyp target with the following form: +# { +# 'target_name': 'my_proto_lib', +# 'type': 'static_library', +# 'sources': [ +# 'foo.proto', +# 'bar.proto', +# ], +# 'variables': { +# # Optional, see below: 'proto_in_dir': '.' +# 'proto_out_dir': 'dir/for/my_proto_lib' +# }, +# 'includes': ['path/to/this/gypi/file'], +# } +# If necessary, you may add normal .cc files to the sources list or other gyp +# dependencies. The proto headers are guaranteed to be generated before any +# source files, even within this target, are compiled. +# +# The 'proto_in_dir' variable must be the relative path to the +# directory containing the .proto files. If left out, it defaults to '.'. +# +# The 'proto_out_dir' variable specifies the path suffix that output +# files are generated under. Targets that gyp-depend on my_proto_lib +# will be able to include the resulting proto headers with an include +# like: +# #include "dir/for/my_proto_lib/foo.pb.h" +# +# Implementation notes: +# 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 + +{ + 'variables': { + 'protoc': '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)protoc<(EXECUTABLE_SUFFIX)', + 'cc_dir': '<(SHARED_INTERMEDIATE_DIR)/protoc_out/<(proto_out_dir)', + 'py_dir': '<(PRODUCT_DIR)/pyproto/<(proto_out_dir)', + 'proto_in_dir%': '.', + }, + 'rules': [ + { + 'rule_name': 'genproto', + 'extension': 'proto', + 'inputs': [ + '<(protoc)', + ], + 'outputs': [ + '<(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)/<(RULE_INPUT_ROOT)<(RULE_INPUT_EXT)', + '--cpp_out=<(cc_dir)', + '--python_out=<(py_dir)', + ], + 'message': 'Generating C++ and Python code from <(RULE_INPUT_PATH)', + 'process_outputs_as_sources': 1, + }, + ], + 'dependencies': [ + '<(DEPTH)/third_party/protobuf/protobuf.gyp:protoc#host', + '<(DEPTH)/third_party/protobuf/protobuf.gyp:protobuf_lite', + ], + 'include_dirs': [ + '<(SHARED_INTERMEDIATE_DIR)/protoc_out', + ], + 'direct_dependent_settings': { + 'include_dirs': [ + '<(SHARED_INTERMEDIATE_DIR)/protoc_out', + ] + }, + # This target exports a hard dependency because it generates header + # files. + 'hard_dependency': 1, +} |