diff --git a/README.upgrading b/README.upgrading index fc81ea76..92ae2abf 100644 --- a/README.upgrading +++ b/README.upgrading @@ -1,5 +1,5 @@ README.upgrading for Widevine CDM Partner Kit v2.1 -Date: 7/02/2014 +Date: 7/07/2014 This document provides details on important changes between versions of the Widevine CDM. Some upgrades may require you to make changes to your @@ -9,13 +9,13 @@ NOTE: All gyp variables have default values in platforms/global_config.gypi. You may override these defaults in your platform-specific gypi. -New in v2.1.4: +New in v2.1.5: ===== New gyp variables have been introduced to make the build more configurable: - * protobuf_gyp - For gyp-based projects with their own internal version of protobuf, allows - the path to the protobuf gyp file to be overridden. The default is - third_party/protobuf.gyp. Ignored if use_system_protobuf is 'true'. + * protobuf_lib_type and protobuf_lib + These, along with 'protoc_dir', form a new protobuf configuration model + and replace the variables 'protobuf_source_dir', 'use_system_protobuf', + and 'protobuf_gyp'. For details, see platforms/global_config.gypi. New in v2.1.3: @@ -103,12 +103,3 @@ updated in oemcrypto/include. The following functions were added: The file ./platforms/x86-64/x86-64.gypi now contains examples of how settings can be customized for a given platform. - -New gyp variables have been introduced to make the build more configurable: - * use_system_protobuf - Allows building protobuf from source, rather than using a system-wide - installation of the library and its tools. Defaults to 'true'. - * protobuf_source_dir - The path to the protobuf sources. Ignored if use_system_protobuf is - 'true'. The source dir is expected to have a valid config.h for the - platform. diff --git a/cdm/cdm.gyp b/cdm/cdm.gyp index c58c94e6..49818e92 100644 --- a/cdm/cdm.gyp +++ b/cdm/cdm.gyp @@ -4,8 +4,6 @@ # setting up your system, performing the build, and using/testing # the build targets. -# Set external_build=0 via GYP_DEFINES if debug information in -# libwvcdm_shared.so is desirable. { 'targets': [ { @@ -14,7 +12,6 @@ 'sources': ['../core/src/license_protocol.proto',], 'variables': { 'proto_in_dir': '../core/src', - 'proto_out_dir': 'license_protocol', }, 'includes': ['../third_party/protoc.gypi'], }, @@ -24,7 +21,6 @@ 'sources': ['../core/src/device_files.proto',], 'variables': { 'proto_in_dir': '../core/src', - 'proto_out_dir': 'device_files', }, 'includes': ['../third_party/protoc.gypi'], }, @@ -57,10 +53,15 @@ 'wvcdm_sysdep', '<(oemcrypto_target)', ], + # Without this, library deps do not propagate from the protocol targets + # up to the shared lib or executable above. + 'export_dependent_settings': [ + 'device_files', + 'license_protocol', + ], 'include_dirs': [ '../cdm/include', '../core/include', - '../third_party/gmock/include', '../linux/include', '../oemcrypto/include', ], @@ -99,13 +100,6 @@ '../core/src/oemcrypto_adapter_static_v8.cpp', ], }], - ['use_system_protobuf=="true"', { - 'direct_dependent_settings': { - 'libraries': [ - '-lprotobuf', - ], - }, - }], ], }, { diff --git a/cdm/include/wv_cdm_version.h b/cdm/include/wv_cdm_version.h index dd0cd578..b9aed4da 100644 --- a/cdm/include/wv_cdm_version.h +++ b/cdm/include/wv_cdm_version.h @@ -1,3 +1,3 @@ // Widevine CDM Kit Version - #define WV_CDM_VERSION "v2.1.4-0-804" + #define WV_CDM_VERSION "v2.1.5-0-811" diff --git a/core/include/cdm_session.h b/core/include/cdm_session.h index a45266c5..396cebb1 100644 --- a/core/include/cdm_session.h +++ b/core/include/cdm_session.h @@ -83,8 +83,9 @@ class CdmSession { virtual void OnTimerEvent(); virtual void OnKeyReleaseEvent(const CdmKeySetId& key_set_id); - virtual SecurityLevel GetRequestedSecurityLevel(); - virtual CdmSecurityLevel GetSecurityLevel(); + virtual SecurityLevel GetRequestedSecurityLevel() { + return requested_security_level_; } + virtual CdmSecurityLevel GetSecurityLevel() { return security_level_; } virtual CdmResponseType UpdateUsageInformation(); @@ -119,7 +120,9 @@ class CdmSession { bool is_release_; bool is_usage_update_needed_; bool is_initial_decryption_; + CdmSecurityLevel security_level_; + SecurityLevel requested_security_level_; // information useful for offline and usage scenarios CdmKeyMessage key_request_; diff --git a/core/src/buffer_reader.cpp b/core/src/buffer_reader.cpp index a548b8a9..f81b9a21 100644 --- a/core/src/buffer_reader.cpp +++ b/core/src/buffer_reader.cpp @@ -8,7 +8,7 @@ namespace wvcdm { bool BufferReader::Read1(uint8_t* v) { if (!HasBytes(1)) { - LOGE("BufferReader::Read1 : Failure while parsing: Not enough bytes (1)"); + LOGW("BufferReader::Read1 : Failure while parsing: Not enough bytes (1)"); return false; } @@ -19,7 +19,7 @@ bool BufferReader::Read1(uint8_t* v) { // Internal implementation of multi-byte reads template bool BufferReader::Read(T* v) { if (!HasBytes(sizeof(T))) { - LOGE("BufferReader::Read : Failure during parse: Not enough bytes (%u)", + LOGW("BufferReader::Read : Failure during parse: Not enough bytes (%u)", sizeof(T)); return false; } @@ -42,7 +42,7 @@ bool BufferReader::Read8s(int64_t* v) { return Read(v); } bool BufferReader::ReadString(std::string* str, int count) { if (!HasBytes(count)) { - LOGE("BufferReader::ReadString : Parse Failure: Not enough bytes (%d)", + LOGW("BufferReader::ReadString : Parse Failure: Not enough bytes (%d)", count); return false; } @@ -54,7 +54,7 @@ bool BufferReader::ReadString(std::string* str, int count) { bool BufferReader::ReadVec(std::vector* vec, int count) { if (!HasBytes(count)) { - LOGE("BufferReader::ReadVec : Parse Failure: Not enough bytes (%d)", count); + LOGW("BufferReader::ReadVec : Parse Failure: Not enough bytes (%d)", count); return false; } @@ -66,7 +66,7 @@ bool BufferReader::ReadVec(std::vector* vec, int count) { bool BufferReader::SkipBytes(int bytes) { if (!HasBytes(bytes)) { - LOGE("BufferReader::SkipBytes : Parse Failure: Not enough bytes (%d)", + LOGW("BufferReader::SkipBytes : Parse Failure: Not enough bytes (%d)", bytes); return false; } diff --git a/core/src/cdm_session.cpp b/core/src/cdm_session.cpp index da013157..6b3b4c8b 100644 --- a/core/src/cdm_session.cpp +++ b/core/src/cdm_session.cpp @@ -73,8 +73,12 @@ void CdmSession::Create( is_release_ = false; is_usage_update_needed_ = false; is_initial_decryption_ = true; - security_level_ = crypto_session_.get()->GetSecurityLevel(); - if (cdm_client_property_set) { + requested_security_level_ = kLevelDefault; + if (NULL != cdm_client_property_set) { + if (QUERY_VALUE_SECURITY_LEVEL_L3.compare( + cdm_client_property_set->security_level()) == 0) { + requested_security_level_ = kLevel3; + } Properties::AddSessionPropertySet(session_id_, cdm_client_property_set); } } @@ -90,8 +94,9 @@ CdmResponseType CdmSession::Init() { LOGE("CdmSession::Init: Failed due to previous initialization"); return UNKNOWN_ERROR; } - CdmResponseType sts = crypto_session_->Open(GetRequestedSecurityLevel()); + CdmResponseType sts = crypto_session_->Open(requested_security_level_); if (NO_ERROR != sts) return sts; + security_level_ = crypto_session_->GetSecurityLevel(); std::string token; if (Properties::use_certificates_as_identification()) { @@ -271,7 +276,7 @@ CdmResponseType CdmSession::QueryStatus(CdmQueryMap* key_info) { return UNKNOWN_ERROR; } - switch (crypto_session_->GetSecurityLevel()) { + switch (security_level_) { case kSecurityLevelL1: (*key_info)[QUERY_KEY_SECURITY_LEVEL] = QUERY_VALUE_SECURITY_LEVEL_L1; break; @@ -530,23 +535,6 @@ void CdmSession::OnKeyReleaseEvent(const CdmKeySetId& key_set_id) { } } -SecurityLevel CdmSession::GetRequestedSecurityLevel() { - std::string security_level; - if (Properties::GetSecurityLevel(session_id_, &security_level) && - security_level == QUERY_VALUE_SECURITY_LEVEL_L3) { - return kLevel3; - } - - return kLevelDefault; -} - -CdmSecurityLevel CdmSession::GetSecurityLevel() { - if (NULL == crypto_session_.get()) - return kSecurityLevelUninitialized; - - return crypto_session_.get()->GetSecurityLevel(); -} - CdmResponseType CdmSession::UpdateUsageInformation() { return crypto_session_->UpdateUsageInformation(); } diff --git a/core/src/crypto_session.cpp b/core/src/crypto_session.cpp index c9de26ac..75e69b4e 100644 --- a/core/src/crypto_session.cpp +++ b/core/src/crypto_session.cpp @@ -168,13 +168,9 @@ bool CryptoSession::GetApiVersion(uint32_t* version) { if (!initialized_) { return false; } - CdmSecurityLevel level = GetSecurityLevel(); - SecurityLevel security_level = kLevelDefault; - if (kSecurityLevelL3 == level) security_level = kLevel3; LOGV("CryptoSession::GetApiVersion: Lock"); - AutoLock auto_lock(crypto_lock_); - *version = OEMCrypto_APIVersion(security_level); + *version = OEMCrypto_APIVersion(requested_security_level_); return true; } diff --git a/core/src/properties.cpp b/core/src/properties.cpp index 962c627b..451cdc9d 100644 --- a/core/src/properties.cpp +++ b/core/src/properties.cpp @@ -65,8 +65,6 @@ bool Properties::GetSecurityLevel(const CdmSessionId& session_id, const CdmClientPropertySet* property_set = GetCdmClientPropertySet(session_id); if (NULL == property_set) { - LOGE("Properties::GetSecurityLevel: cannot find property set for %s", - session_id.c_str()); return false; } *security_level = property_set->security_level(); @@ -78,8 +76,6 @@ bool Properties::GetServiceCertificate(const CdmSessionId& session_id, const CdmClientPropertySet* property_set = GetCdmClientPropertySet(session_id); if (NULL == property_set) { - LOGE("Properties::GetServiceCertificate: cannot find property set for %s", - session_id.c_str()); return false; } *service_certificate = property_set->service_certificate(); @@ -90,8 +86,6 @@ bool Properties::UsePrivacyMode(const CdmSessionId& session_id) { const CdmClientPropertySet* property_set = GetCdmClientPropertySet(session_id); if (NULL == property_set) { - LOGE("Properties::UsePrivacyMode: cannot find property set for %s", - session_id.c_str()); return false; } return property_set->use_privacy_mode(); @@ -101,8 +95,6 @@ uint32_t Properties::GetSessionSharingId(const CdmSessionId& session_id) { const CdmClientPropertySet* property_set = GetCdmClientPropertySet(session_id); if (NULL == property_set) { - LOGE("Properties::GetSessionSharingId: cannot find property set for %s", - session_id.c_str()); return 0; } return property_set->session_sharing_id(); diff --git a/core/test/cdm_session_unittest.cpp b/core/test/cdm_session_unittest.cpp index d204be44..51d41206 100644 --- a/core/test/cdm_session_unittest.cpp +++ b/core/test/cdm_session_unittest.cpp @@ -91,6 +91,7 @@ using ::testing::Eq; using ::testing::NotNull; using ::testing::Return; using ::testing::SetArgPointee; +using ::testing::Sequence; using ::testing::StrEq; class MockDeviceFiles : public DeviceFiles { @@ -150,15 +151,20 @@ class CdmSessionTest : public ::testing::Test { }; TEST_F(CdmSessionTest, InitWithCertificate) { + Sequence crypto_session_seq; CdmSecurityLevel level = kSecurityLevelL1; - EXPECT_CALL(*crypto_session_, GetSecurityLevel()).WillOnce(Return(level)); EXPECT_CALL(*crypto_session_, Open(Eq(kLevelDefault))) + .InSequence(crypto_session_seq) .WillOnce(Return(NO_ERROR)); + EXPECT_CALL(*crypto_session_, GetSecurityLevel()) + .InSequence(crypto_session_seq) + .WillOnce(Return(level)); EXPECT_CALL(*file_handle_, Init(Eq(level))).WillOnce(Return(true)); EXPECT_CALL(*file_handle_, RetrieveCertificate(NotNull(), NotNull())) .WillOnce(DoAll(SetArgPointee<0>(kToken), SetArgPointee<1>(kWrappedKey), Return(true))); EXPECT_CALL(*crypto_session_, LoadCertificatePrivateKey(StrEq(kWrappedKey))) + .InSequence(crypto_session_seq) .WillOnce(Return(true)); EXPECT_CALL(*license_parser_, Init(Eq(kToken), Eq(crypto_session_), Eq(policy_engine_))) @@ -171,11 +177,16 @@ TEST_F(CdmSessionTest, InitWithCertificate) { } TEST_F(CdmSessionTest, InitWithKeybox) { + Sequence crypto_session_seq; CdmSecurityLevel level = kSecurityLevelL1; - EXPECT_CALL(*crypto_session_, GetSecurityLevel()).WillOnce(Return(level)); EXPECT_CALL(*crypto_session_, Open(Eq(kLevelDefault))) + .InSequence(crypto_session_seq) .WillOnce(Return(NO_ERROR)); + EXPECT_CALL(*crypto_session_, GetSecurityLevel()) + .InSequence(crypto_session_seq) + .WillOnce(Return(level)); EXPECT_CALL(*crypto_session_, GetToken(NotNull())) + .InSequence(crypto_session_seq) .WillOnce(DoAll(SetArgPointee<0>(kToken), Return(true))); EXPECT_CALL(*license_parser_, Init(Eq(kToken), Eq(crypto_session_), Eq(policy_engine_))) @@ -188,15 +199,20 @@ TEST_F(CdmSessionTest, InitWithKeybox) { } TEST_F(CdmSessionTest, ReInitFail) { + Sequence crypto_session_seq; CdmSecurityLevel level = kSecurityLevelL1; - EXPECT_CALL(*crypto_session_, GetSecurityLevel()).WillOnce(Return(level)); EXPECT_CALL(*crypto_session_, Open(Eq(kLevelDefault))) + .InSequence(crypto_session_seq) .WillOnce(Return(NO_ERROR)); + EXPECT_CALL(*crypto_session_, GetSecurityLevel()) + .InSequence(crypto_session_seq) + .WillOnce(Return(level)); EXPECT_CALL(*file_handle_, Init(Eq(level))).WillOnce(Return(true)); EXPECT_CALL(*file_handle_, RetrieveCertificate(NotNull(), NotNull())) .WillOnce(DoAll(SetArgPointee<0>(kToken), SetArgPointee<1>(kWrappedKey), Return(true))); EXPECT_CALL(*crypto_session_, LoadCertificatePrivateKey(StrEq(kWrappedKey))) + .InSequence(crypto_session_seq) .WillOnce(Return(true)); EXPECT_CALL(*license_parser_, Init(Eq(kToken), Eq(crypto_session_), Eq(policy_engine_))) @@ -211,7 +227,6 @@ TEST_F(CdmSessionTest, ReInitFail) { TEST_F(CdmSessionTest, InitFailCryptoError) { CdmSecurityLevel level = kSecurityLevelL1; - EXPECT_CALL(*crypto_session_, GetSecurityLevel()).WillOnce(Return(level)); EXPECT_CALL(*crypto_session_, Open(Eq(kLevelDefault))) .WillOnce(Return(UNKNOWN_ERROR)); @@ -222,10 +237,14 @@ TEST_F(CdmSessionTest, InitFailCryptoError) { } TEST_F(CdmSessionTest, InitNeedsProvisioning) { + Sequence crypto_session_seq; CdmSecurityLevel level = kSecurityLevelL1; - EXPECT_CALL(*crypto_session_, GetSecurityLevel()).WillOnce(Return(level)); EXPECT_CALL(*crypto_session_, Open(Eq(kLevelDefault))) + .InSequence(crypto_session_seq) .WillOnce(Return(NO_ERROR)); + EXPECT_CALL(*crypto_session_, GetSecurityLevel()) + .InSequence(crypto_session_seq) + .WillOnce(Return(level)); EXPECT_CALL(*file_handle_, Init(Eq(level))).WillOnce(Return(true)); EXPECT_CALL(*file_handle_, RetrieveCertificate(NotNull(), NotNull())) .WillOnce(Return(false)); diff --git a/oemcrypto/test/oemcrypto_test.cpp b/oemcrypto/test/oemcrypto_test.cpp index 631e998a..11d2aacc 100644 --- a/oemcrypto/test/oemcrypto_test.cpp +++ b/oemcrypto/test/oemcrypto_test.cpp @@ -2879,14 +2879,15 @@ TEST_F(DISABLED_TestKeybox, RSASignature) { OEMCrypto_GetRandom(&licenseRequest[0], licenseRequest.size()); size_t signature_length = 0; + uint8_t signature[500]; + sts = OEMCrypto_GenerateRSASignature(s.session_id(), &licenseRequest[0], licenseRequest.size(), signature, &signature_length, kSign_RSASSA_PSS); ASSERT_EQ(OEMCrypto_ERROR_SHORT_BUFFER, sts); ASSERT_NE(static_cast(0), signature_length); - - uint8_t* signature = new uint8_t[signature_length]; + ASSERT_GE(sizeof(signature), signature_length); sts = OEMCrypto_GenerateRSASignature(s.session_id(), &licenseRequest[0], licenseRequest.size(), signature, @@ -2898,7 +2899,6 @@ TEST_F(DISABLED_TestKeybox, RSASignature) { s.PreparePublicKey(); s.VerifyRSASignature(&licenseRequest[0], licenseRequest.size(), signature, signature_length, kSign_RSASSA_PSS); - delete[] signature; } TEST_F(DISABLED_TestKeybox, LoadRSASessionKey) { diff --git a/platforms/global_config.gypi b/platforms/global_config.gypi index 4204f20a..66a82678 100644 --- a/platforms/global_config.gypi +++ b/platforms/global_config.gypi @@ -12,13 +12,29 @@ 'buildinfo_data%': '"UndefinedBuildInfo"', 'oemcrypto_target%': '../oemcrypto/mock/oec_mock.gyp:oec_mock', 'oemcrypto_v8%': 'false', - 'protobuf_source_dir%': '', - 'use_system_protobuf%': 'true', - 'protoc_dir%': '/usr/bin', 'certificate_provision%': 'false', 'force_use_of_secure_buffers%': 'false', 'disable_privacy_crypto%': 'false', - 'protobuf_gyp%': '<(DEPTH)/third_party/protobuf.gyp', + + # There are three protobuf configurations: + # + # 1) protobuf_lib_type == 'system' + # Use a system-wide installation of protobuf. + # Specify the protobuf library in protobuf_lib. + # Specify the path to protoc in protoc_dir. + # + # 2) protobuf_lib_type == 'target' + # Use an existing protobuf gyp target from your project. + # Specify the protobuf gyp file and target in protobuf_lib. + # Specify the path to protoc in protoc_dir. + # + # 3) protobuf_lib_type == 'source' + # Build protobuf and protoc from source. + # Specify the path to the protobuf source in protobuf_lib. + # Make sure that a valid config.h for your target is in the source tree. + 'protobuf_lib_type%': 'system', + 'protobuf_lib%': '-lprotobuf', + 'protoc_dir%': '/usr/bin', }, # end variables 'target_defaults': { diff --git a/third_party/protobuf.gyp b/third_party/protobuf.gyp index 0729e234..8557d56c 100644 --- a/third_party/protobuf.gyp +++ b/third_party/protobuf.gyp @@ -1,8 +1,8 @@ # Copyright 2014 Google Inc. All Rights Reserved. # Describes building protobuf and protoc from sources. -# Requires configuration of protobuf_source_dir and setting of -# use_system_protobuf to false. +# Requires configuration of protobuf_lib and setting of +# protobuf_lib_type to 'source'. { # Some sources are used by both libprotobuf_lite and libprotobuf. @@ -13,21 +13,21 @@ # instead. 'variables': { 'protobuf_lite_sources': [ - '<(protobuf_source_dir)/src/google/protobuf/extension_set.cc', - '<(protobuf_source_dir)/src/google/protobuf/generated_message_util.cc', - '<(protobuf_source_dir)/src/google/protobuf/message_lite.cc', - '<(protobuf_source_dir)/src/google/protobuf/repeated_field.cc', - '<(protobuf_source_dir)/src/google/protobuf/wire_format_lite.cc', + '<(protobuf_lib)/src/google/protobuf/extension_set.cc', + '<(protobuf_lib)/src/google/protobuf/generated_message_util.cc', + '<(protobuf_lib)/src/google/protobuf/message_lite.cc', + '<(protobuf_lib)/src/google/protobuf/repeated_field.cc', + '<(protobuf_lib)/src/google/protobuf/wire_format_lite.cc', - '<(protobuf_source_dir)/src/google/protobuf/io/coded_stream.cc', - '<(protobuf_source_dir)/src/google/protobuf/io/zero_copy_stream.cc', - '<(protobuf_source_dir)/src/google/protobuf/io/zero_copy_stream_impl_lite.cc', + '<(protobuf_lib)/src/google/protobuf/io/coded_stream.cc', + '<(protobuf_lib)/src/google/protobuf/io/zero_copy_stream.cc', + '<(protobuf_lib)/src/google/protobuf/io/zero_copy_stream_impl_lite.cc', - '<(protobuf_source_dir)/src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc', - '<(protobuf_source_dir)/src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc', - '<(protobuf_source_dir)/src/google/protobuf/stubs/common.cc', - '<(protobuf_source_dir)/src/google/protobuf/stubs/once.cc', - '<(protobuf_source_dir)/src/google/protobuf/stubs/stringprintf.cc', + '<(protobuf_lib)/src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc', + '<(protobuf_lib)/src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc', + '<(protobuf_lib)/src/google/protobuf/stubs/common.cc', + '<(protobuf_lib)/src/google/protobuf/stubs/once.cc', + '<(protobuf_lib)/src/google/protobuf/stubs/stringprintf.cc', ], }, 'targets': [ @@ -39,12 +39,12 @@ '<@(protobuf_lite_sources)', ], 'include_dirs': [ - '<(protobuf_source_dir)', - '<(protobuf_source_dir)/src', + '<(protobuf_lib)', + '<(protobuf_lib)/src', ], 'direct_dependent_settings': { 'include_dirs': [ - '<(protobuf_source_dir)/src', + '<(protobuf_lib)/src', ], }, }, @@ -56,34 +56,34 @@ 'sources': [ '<@(protobuf_lite_sources)', - '<(protobuf_source_dir)/src/google/protobuf/descriptor.cc', - '<(protobuf_source_dir)/src/google/protobuf/descriptor.pb.cc', - '<(protobuf_source_dir)/src/google/protobuf/descriptor_database.cc', - '<(protobuf_source_dir)/src/google/protobuf/dynamic_message.cc', - '<(protobuf_source_dir)/src/google/protobuf/extension_set_heavy.cc', - '<(protobuf_source_dir)/src/google/protobuf/generated_message_reflection.cc', - '<(protobuf_source_dir)/src/google/protobuf/message.cc', - '<(protobuf_source_dir)/src/google/protobuf/reflection_ops.cc', - '<(protobuf_source_dir)/src/google/protobuf/service.cc', - '<(protobuf_source_dir)/src/google/protobuf/text_format.cc', - '<(protobuf_source_dir)/src/google/protobuf/unknown_field_set.cc', - '<(protobuf_source_dir)/src/google/protobuf/wire_format.cc', + '<(protobuf_lib)/src/google/protobuf/descriptor.cc', + '<(protobuf_lib)/src/google/protobuf/descriptor.pb.cc', + '<(protobuf_lib)/src/google/protobuf/descriptor_database.cc', + '<(protobuf_lib)/src/google/protobuf/dynamic_message.cc', + '<(protobuf_lib)/src/google/protobuf/extension_set_heavy.cc', + '<(protobuf_lib)/src/google/protobuf/generated_message_reflection.cc', + '<(protobuf_lib)/src/google/protobuf/message.cc', + '<(protobuf_lib)/src/google/protobuf/reflection_ops.cc', + '<(protobuf_lib)/src/google/protobuf/service.cc', + '<(protobuf_lib)/src/google/protobuf/text_format.cc', + '<(protobuf_lib)/src/google/protobuf/unknown_field_set.cc', + '<(protobuf_lib)/src/google/protobuf/wire_format.cc', - '<(protobuf_source_dir)/src/google/protobuf/compiler/importer.cc', - '<(protobuf_source_dir)/src/google/protobuf/compiler/parser.cc', + '<(protobuf_lib)/src/google/protobuf/compiler/importer.cc', + '<(protobuf_lib)/src/google/protobuf/compiler/parser.cc', - '<(protobuf_source_dir)/src/google/protobuf/io/gzip_stream.cc', - '<(protobuf_source_dir)/src/google/protobuf/io/printer.cc', - '<(protobuf_source_dir)/src/google/protobuf/io/tokenizer.cc', - '<(protobuf_source_dir)/src/google/protobuf/io/zero_copy_stream_impl.cc', + '<(protobuf_lib)/src/google/protobuf/io/gzip_stream.cc', + '<(protobuf_lib)/src/google/protobuf/io/printer.cc', + '<(protobuf_lib)/src/google/protobuf/io/tokenizer.cc', + '<(protobuf_lib)/src/google/protobuf/io/zero_copy_stream_impl.cc', - '<(protobuf_source_dir)/src/google/protobuf/stubs/structurally_valid.cc', - '<(protobuf_source_dir)/src/google/protobuf/stubs/strutil.cc', - '<(protobuf_source_dir)/src/google/protobuf/stubs/substitute.cc', + '<(protobuf_lib)/src/google/protobuf/stubs/structurally_valid.cc', + '<(protobuf_lib)/src/google/protobuf/stubs/strutil.cc', + '<(protobuf_lib)/src/google/protobuf/stubs/substitute.cc', ], 'include_dirs': [ - '<(protobuf_source_dir)', - '<(protobuf_source_dir)/src', + '<(protobuf_lib)', + '<(protobuf_lib)/src', ], }, { @@ -92,46 +92,46 @@ 'toolsets': ['host'], 'includes': ['xcode_host.gypi'], # xcode workaround 'sources': [ - '<(protobuf_source_dir)/src/google/protobuf/compiler/code_generator.cc', - '<(protobuf_source_dir)/src/google/protobuf/compiler/command_line_interface.cc', - '<(protobuf_source_dir)/src/google/protobuf/compiler/main.cc', - '<(protobuf_source_dir)/src/google/protobuf/compiler/plugin.cc', - '<(protobuf_source_dir)/src/google/protobuf/compiler/plugin.pb.cc', - '<(protobuf_source_dir)/src/google/protobuf/compiler/subprocess.cc', - '<(protobuf_source_dir)/src/google/protobuf/compiler/zip_writer.cc', + '<(protobuf_lib)/src/google/protobuf/compiler/code_generator.cc', + '<(protobuf_lib)/src/google/protobuf/compiler/command_line_interface.cc', + '<(protobuf_lib)/src/google/protobuf/compiler/main.cc', + '<(protobuf_lib)/src/google/protobuf/compiler/plugin.cc', + '<(protobuf_lib)/src/google/protobuf/compiler/plugin.pb.cc', + '<(protobuf_lib)/src/google/protobuf/compiler/subprocess.cc', + '<(protobuf_lib)/src/google/protobuf/compiler/zip_writer.cc', - '<(protobuf_source_dir)/src/google/protobuf/compiler/cpp/cpp_enum.cc', - '<(protobuf_source_dir)/src/google/protobuf/compiler/cpp/cpp_enum_field.cc', - '<(protobuf_source_dir)/src/google/protobuf/compiler/cpp/cpp_extension.cc', - '<(protobuf_source_dir)/src/google/protobuf/compiler/cpp/cpp_field.cc', - '<(protobuf_source_dir)/src/google/protobuf/compiler/cpp/cpp_file.cc', - '<(protobuf_source_dir)/src/google/protobuf/compiler/cpp/cpp_generator.cc', - '<(protobuf_source_dir)/src/google/protobuf/compiler/cpp/cpp_helpers.cc', - '<(protobuf_source_dir)/src/google/protobuf/compiler/cpp/cpp_message.cc', - '<(protobuf_source_dir)/src/google/protobuf/compiler/cpp/cpp_message_field.cc', - '<(protobuf_source_dir)/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc', - '<(protobuf_source_dir)/src/google/protobuf/compiler/cpp/cpp_service.cc', - '<(protobuf_source_dir)/src/google/protobuf/compiler/cpp/cpp_string_field.cc', + '<(protobuf_lib)/src/google/protobuf/compiler/cpp/cpp_enum.cc', + '<(protobuf_lib)/src/google/protobuf/compiler/cpp/cpp_enum_field.cc', + '<(protobuf_lib)/src/google/protobuf/compiler/cpp/cpp_extension.cc', + '<(protobuf_lib)/src/google/protobuf/compiler/cpp/cpp_field.cc', + '<(protobuf_lib)/src/google/protobuf/compiler/cpp/cpp_file.cc', + '<(protobuf_lib)/src/google/protobuf/compiler/cpp/cpp_generator.cc', + '<(protobuf_lib)/src/google/protobuf/compiler/cpp/cpp_helpers.cc', + '<(protobuf_lib)/src/google/protobuf/compiler/cpp/cpp_message.cc', + '<(protobuf_lib)/src/google/protobuf/compiler/cpp/cpp_message_field.cc', + '<(protobuf_lib)/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc', + '<(protobuf_lib)/src/google/protobuf/compiler/cpp/cpp_service.cc', + '<(protobuf_lib)/src/google/protobuf/compiler/cpp/cpp_string_field.cc', - '<(protobuf_source_dir)/src/google/protobuf/compiler/java/java_doc_comment.cc', - '<(protobuf_source_dir)/src/google/protobuf/compiler/java/java_enum.cc', - '<(protobuf_source_dir)/src/google/protobuf/compiler/java/java_enum_field.cc', - '<(protobuf_source_dir)/src/google/protobuf/compiler/java/java_extension.cc', - '<(protobuf_source_dir)/src/google/protobuf/compiler/java/java_field.cc', - '<(protobuf_source_dir)/src/google/protobuf/compiler/java/java_file.cc', - '<(protobuf_source_dir)/src/google/protobuf/compiler/java/java_generator.cc', - '<(protobuf_source_dir)/src/google/protobuf/compiler/java/java_helpers.cc', - '<(protobuf_source_dir)/src/google/protobuf/compiler/java/java_message.cc', - '<(protobuf_source_dir)/src/google/protobuf/compiler/java/java_message_field.cc', - '<(protobuf_source_dir)/src/google/protobuf/compiler/java/java_primitive_field.cc', - '<(protobuf_source_dir)/src/google/protobuf/compiler/java/java_service.cc', - '<(protobuf_source_dir)/src/google/protobuf/compiler/java/java_string_field.cc', + '<(protobuf_lib)/src/google/protobuf/compiler/java/java_doc_comment.cc', + '<(protobuf_lib)/src/google/protobuf/compiler/java/java_enum.cc', + '<(protobuf_lib)/src/google/protobuf/compiler/java/java_enum_field.cc', + '<(protobuf_lib)/src/google/protobuf/compiler/java/java_extension.cc', + '<(protobuf_lib)/src/google/protobuf/compiler/java/java_field.cc', + '<(protobuf_lib)/src/google/protobuf/compiler/java/java_file.cc', + '<(protobuf_lib)/src/google/protobuf/compiler/java/java_generator.cc', + '<(protobuf_lib)/src/google/protobuf/compiler/java/java_helpers.cc', + '<(protobuf_lib)/src/google/protobuf/compiler/java/java_message.cc', + '<(protobuf_lib)/src/google/protobuf/compiler/java/java_message_field.cc', + '<(protobuf_lib)/src/google/protobuf/compiler/java/java_primitive_field.cc', + '<(protobuf_lib)/src/google/protobuf/compiler/java/java_service.cc', + '<(protobuf_lib)/src/google/protobuf/compiler/java/java_string_field.cc', - '<(protobuf_source_dir)/src/google/protobuf/compiler/python/python_generator.cc', + '<(protobuf_lib)/src/google/protobuf/compiler/python/python_generator.cc', ], 'include_dirs': [ - '<(protobuf_source_dir)', - '<(protobuf_source_dir)/src', + '<(protobuf_lib)', + '<(protobuf_lib)/src', ], 'dependencies': [ 'protobuf', diff --git a/third_party/protoc.gypi b/third_party/protoc.gypi index 9ea637ad..3f13d089 100644 --- a/third_party/protoc.gypi +++ b/third_party/protoc.gypi @@ -1,25 +1,42 @@ # Copyright 2014 Google Inc. All rights reserved. { 'variables': { - 'cc_dir': '<(SHARED_INTERMEDIATE_DIR)/protoc_out/<(proto_out_dir)', + 'cc_dir': '<(SHARED_INTERMEDIATE_DIR)/protoc_out', 'proto_in_dir%': '.', }, 'conditions': [ - ['use_system_protobuf=="false"', { - 'variables': { - 'protoc_dir': '<(PRODUCT_DIR)', + ['protobuf_lib_type=="system"', { + # protobuf_lib is a library setting. + 'direct_dependent_settings': { + 'libraries': [ + '<(protobuf_lib)', + ], }, + }], + ['protobuf_lib_type=="target"', { + # protobuf_lib is a gyp target. 'dependencies': [ - '<(protobuf_gyp):protoc#host', - '<(protobuf_gyp):protobuf_lite', + '<(protobuf_lib)', ], 'export_dependent_settings': [ - # Direct dependents of protobuf_lite have the correct protobuf include - # path, so export this as a dep to anyone who depends on the sources - # generated by this target. - '<(protobuf_gyp):protobuf_lite', + '<(protobuf_lib)', ], }], + ['protobuf_lib_type=="source"', { + # protobuf_lib is a source folder. + # We use protobuf.gyp to describe the build. + 'dependencies': [ + '../third_party/protobuf.gyp:protoc#host', + '../third_party/protobuf.gyp:protobuf_lite', + ], + 'export_dependent_settings': [ + '../third_party/protobuf.gyp:protobuf_lite', + ], + 'variables': { + # Since we are building our own protoc, override protoc_dir. + 'protoc_dir': '<(PRODUCT_DIR)', + }, + }], ], 'rules': [ { @@ -42,12 +59,10 @@ }, ], 'include_dirs': [ - '<(SHARED_INTERMEDIATE_DIR)/protoc_out', - '<(proto_out_dir)', + '<(cc_dir)', ], 'direct_dependent_settings': { 'include_dirs': [ - '<(SHARED_INTERMEDIATE_DIR)/protoc_out', '<(cc_dir)', ] },