Generate protobuf classes at build-time.

This method is well-established in Chromium. The new code is largely boilerplate copied from there. The advantage is that we don't have to maintain various versions of the classes; we just generate against whatever compiler version happens to exist at build-time.
Review URL: http://webrtc-codereview.appspot.com/93008

git-svn-id: http://webrtc.googlecode.com/svn/trunk@271 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
ajm@google.com 2011-07-29 17:29:08 +00:00
parent f2c1a7b85c
commit f8dc8dc5f6
4 changed files with 48 additions and 2438 deletions

View File

@ -10,6 +10,9 @@
'includes': [ 'includes': [
'../../../common_settings.gypi', '../../../common_settings.gypi',
], ],
'variables': {
'protoc_out_dir': '<(SHARED_INTERMEDIATE_DIR)/protoc_out',
},
'targets': [ 'targets': [
{ {
'target_name': 'unit_test', 'target_name': 'unit_test',
@ -22,30 +25,67 @@
}], }],
], ],
'dependencies': [ 'dependencies': [
'apm_unittest_proto',
'source/apm.gyp:audio_processing', 'source/apm.gyp:audio_processing',
'../../../system_wrappers/source/system_wrappers.gyp:system_wrappers',
'../../../common_audio/signal_processing_library/main/source/spl.gyp:spl', '../../../common_audio/signal_processing_library/main/source/spl.gyp:spl',
'../../../system_wrappers/source/system_wrappers.gyp:system_wrappers',
'../../../../testing/gtest.gyp:gtest', '../../../../testing/gtest.gyp:gtest',
'../../../../testing/gtest.gyp:gtest_main', '../../../../testing/gtest.gyp:gtest_main',
'../../../../third_party/protobuf/protobuf.gyp:protobuf_lite', '../../../../third_party/protobuf/protobuf.gyp:protobuf_lite',
], ],
'include_dirs': [ 'include_dirs': [
'../../../../testing/gtest/include', '../../../../testing/gtest/include',
'<(protoc_out_dir)',
], ],
'sources': [ 'sources': [
'test/unit_test/unit_test.cc', 'test/unit_test/unit_test.cc',
'test/unit_test/audio_processing_unittest.pb.cc', '<(protoc_out_dir)/audio_processing_unittest.pb.cc',
'test/unit_test/audio_processing_unittest.pb.h', '<(protoc_out_dir)/audio_processing_unittest.pb.h',
], ],
}, },
{
# Protobuf compiler / generate rule for unit_test
'target_name': 'apm_unittest_proto',
'type': 'none',
'variables': {
'proto_relpath': 'test/unit_test',
},
'sources': [
'<(proto_relpath)/audio_processing_unittest.proto',
],
'rules': [
{
'rule_name': 'genproto',
'extension': 'proto',
'inputs': [
'<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)protoc<(EXECUTABLE_SUFFIX)',
],
'outputs': [
'<(protoc_out_dir)/<(RULE_INPUT_ROOT).pb.cc',
'<(protoc_out_dir)/<(RULE_INPUT_ROOT).pb.h',
],
'action': [
'<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)protoc<(EXECUTABLE_SUFFIX)',
'--proto_path=<(proto_relpath)',
'<(proto_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',
],
# This target exports a hard dependency because it generates header
# files.
'hard_dependency': 1,
},
{ {
'target_name': 'process_test', 'target_name': 'process_test',
'type': 'executable', 'type': 'executable',
'dependencies': [ 'dependencies': [
'source/apm.gyp:audio_processing', 'source/apm.gyp:audio_processing',
'../../../system_wrappers/source/system_wrappers.gyp:system_wrappers', '../../../system_wrappers/source/system_wrappers.gyp:system_wrappers',
'../../../../testing/gtest.gyp:gtest', '../../../../testing/gtest.gyp:gtest',
'../../../../testing/gtest.gyp:gtest_main', '../../../../testing/gtest.gyp:gtest_main',
], ],

View File

@ -8,7 +8,7 @@
{ {
'includes': [ 'includes': [
'../../../../common_settings.gypi', # Common settings '../../../../common_settings.gypi',
], ],
'targets': [ 'targets': [
{ {
@ -18,18 +18,18 @@
['prefer_fixed_point==1', { ['prefer_fixed_point==1', {
'dependencies': ['../../ns/main/source/ns.gyp:ns_fix'], 'dependencies': ['../../ns/main/source/ns.gyp:ns_fix'],
'defines': ['WEBRTC_NS_FIXED'], 'defines': ['WEBRTC_NS_FIXED'],
}, { # else: prefer_fixed_point==0 }, {
'dependencies': ['../../ns/main/source/ns.gyp:ns'], 'dependencies': ['../../ns/main/source/ns.gyp:ns'],
'defines': ['WEBRTC_NS_FLOAT'], 'defines': ['WEBRTC_NS_FLOAT'],
}], }],
], ],
'dependencies': [ 'dependencies': [
'../../../../system_wrappers/source/system_wrappers.gyp:system_wrappers',
'../../aec/main/source/aec.gyp:aec', '../../aec/main/source/aec.gyp:aec',
'../../aecm/main/source/aecm.gyp:aecm', '../../aecm/main/source/aecm.gyp:aecm',
'../../agc/main/source/agc.gyp:agc', '../../agc/main/source/agc.gyp:agc',
'../../../../common_audio/signal_processing_library/main/source/spl.gyp:spl', '../../../../common_audio/signal_processing_library/main/source/spl.gyp:spl',
'../../../../common_audio/vad/main/source/vad.gyp:vad', '../../../../common_audio/vad/main/source/vad.gyp:vad',
'../../../../system_wrappers/source/system_wrappers.gyp:system_wrappers',
], ],
'include_dirs': [ 'include_dirs': [
'../interface', '../interface',