diff --git a/gyp_packager.py b/gyp_packager.py index 81519e2dd6..0efe8ac6b1 100755 --- a/gyp_packager.py +++ b/gyp_packager.py @@ -56,8 +56,11 @@ if __name__ == '__main__': if [arg.endswith('.gyp') for arg in args].count(True) == 0: args.append(os.path.join(src_dir, 'packager.gyp')) - # Always include common.gypi. - args.extend(['-I' + os.path.join(src_dir, 'build', 'common.gypi')]) + # Always include Chromium's common.gypi and our common.gypi. + args.extend([ + '-I' + os.path.join(src_dir, 'build', 'common.gypi'), + '-I' + os.path.join(src_dir, 'common.gypi') + ]) # Set these default GYP_DEFINES if user does not set the value explicitly. _DEFAULT_DEFINES = {'test_isolation_mode': 'noop', diff --git a/packager/common.gypi b/packager/common.gypi index 5f8d3cbe0d..a5d37e080c 100644 --- a/packager/common.gypi +++ b/packager/common.gypi @@ -8,38 +8,62 @@ { 'variables': { - # Compile as Chromium code to enable warnings and warnings-as-errors. - 'chromium_code': 1, + 'variables': { + 'shaka_code%': 0, + }, + 'shaka_code%': '<(shaka_code)', 'libpackager_type%': 'static_library', + 'conditions': [ + ['shaka_code==1', { + # This enable warnings and warnings-as-errors. + 'chromium_code': 1, + }], + ], }, 'target_defaults': { - 'include_dirs': [ - '.', - '..', - ], 'conditions': [ - ['clang==1', { - 'cflags': [ - '-Wimplicit-fallthrough', + ['shaka_code==1', { + 'include_dirs': [ + '.', + '..', ], - # Revert the relevant settings in Chromium's common.gypi. - 'cflags!': [ - '-Wno-char-subscripts', - '-Wno-unneeded-internal-declaration', - '-Wno-covered-switch-default', + 'conditions': [ + ['clang==1', { + 'cflags': [ + '-Wimplicit-fallthrough', + ], + # Revert the relevant settings in Chromium's common.gypi. + 'cflags!': [ + '-Wno-char-subscripts', + '-Wno-unneeded-internal-declaration', + '-Wno-covered-switch-default', - # C++11-related flags: - '-Wno-c++11-narrowing', - '-Wno-reserved-user-defined-literal', + # C++11-related flags: + '-Wno-c++11-narrowing', + '-Wno-reserved-user-defined-literal', + ], + }], + ['OS == "win"', { + 'msvs_settings': { + 'VCCLCompilerTool': { + 'WarnAsError': 'true', + 'DisableSpecificWarnings': ['4125'] + }, + }, + }], + ], + }, { + 'conditions': [ + # We do not have control over non-shaka code. Disable some warnings to + # make build pass. + ['clang==0', { + 'cflags': [ + '-Wno-dangling-else', + '-Wno-deprecated-declarations', + '-Wno-unused-function', + ], + }], ], - }], - ['OS == "win"', { - 'msvs_settings': { - 'VCCLCompilerTool': { - 'WarnAsError': 'true', - 'DisableSpecificWarnings': ['4125'] - }, - }, }], ], }, diff --git a/packager/file/file.gyp b/packager/file/file.gyp index ba6ffc9477..de8b41a591 100644 --- a/packager/file/file.gyp +++ b/packager/file/file.gyp @@ -5,9 +5,9 @@ # https://developers.google.com/open-source/licenses/bsd { - 'includes': [ - '../common.gypi', - ], + 'variables': { + 'shaka_code': 1, + }, 'targets': [ { 'target_name': 'file', diff --git a/packager/hls/hls.gyp b/packager/hls/hls.gyp index cc54e4f939..1569cb2bb0 100644 --- a/packager/hls/hls.gyp +++ b/packager/hls/hls.gyp @@ -5,9 +5,9 @@ # https://developers.google.com/open-source/licenses/bsd { - 'includes': [ - '../common.gypi', - ], + 'variables': { + 'shaka_code': 1, + }, 'targets': [ { 'target_name': 'hls_builder', diff --git a/packager/media/ad_cue_generator/ad_cue_generator.gyp b/packager/media/ad_cue_generator/ad_cue_generator.gyp index c14951b9d7..373e16fcf8 100644 --- a/packager/media/ad_cue_generator/ad_cue_generator.gyp +++ b/packager/media/ad_cue_generator/ad_cue_generator.gyp @@ -5,9 +5,9 @@ # https://developers.google.com/open-source/licenses/bsd { - 'includes': [ - '../../common.gypi', - ], + 'variables': { + 'shaka_code': 1, + }, 'targets': [ { 'target_name': 'ad_cue_generator', diff --git a/packager/media/base/aes_cryptor_unittest.cc b/packager/media/base/aes_cryptor_unittest.cc index 7b85cbbeea..84c89aa8ce 100644 --- a/packager/media/base/aes_cryptor_unittest.cc +++ b/packager/media/base/aes_cryptor_unittest.cc @@ -603,8 +603,9 @@ TEST_P(AesCbcCryptorVerificationTest, EncryptDecryptTest) { std::vector plaintext; std::string plaintext_hex(GetParam().plaintext_hex); - if (!plaintext_hex.empty()) + if (!plaintext_hex.empty()) { ASSERT_TRUE(base::HexStringToBytes(plaintext_hex, &plaintext)); + } std::vector expected_ciphertext; std::string expected_ciphertext_hex(GetParam().expected_ciphertext_hex); diff --git a/packager/media/base/aes_pattern_cryptor_unittest.cc b/packager/media/base/aes_pattern_cryptor_unittest.cc index 0b73a2c46e..7625119275 100644 --- a/packager/media/base/aes_pattern_cryptor_unittest.cc +++ b/packager/media/base/aes_pattern_cryptor_unittest.cc @@ -112,8 +112,9 @@ class AesPatternCryptorVerificationTest TEST_P(AesPatternCryptorVerificationTest, PatternTest) { std::vector text; std::string text_hex(GetParam().text_hex); - if (!text_hex.empty()) + if (!text_hex.empty()) { ASSERT_TRUE(base::HexStringToBytes(text_hex, &text)); + } std::vector expected_crypt_text; std::string expected_crypt_text_hex(GetParam().expected_crypt_text_hex); if (!expected_crypt_text_hex.empty()) { diff --git a/packager/media/base/media_base.gyp b/packager/media/base/media_base.gyp index 459406e599..221a1b848a 100644 --- a/packager/media/base/media_base.gyp +++ b/packager/media/base/media_base.gyp @@ -5,9 +5,9 @@ # https://developers.google.com/open-source/licenses/bsd { - 'includes': [ - '../../common.gypi', - ], + 'variables': { + 'shaka_code': 1, + }, 'targets': [ { 'target_name': 'media_base', diff --git a/packager/media/base/rsa_key_unittest.cc b/packager/media/base/rsa_key_unittest.cc index 9f9fa5b024..200137eaf5 100644 --- a/packager/media/base/rsa_key_unittest.cc +++ b/packager/media/base/rsa_key_unittest.cc @@ -86,8 +86,9 @@ TEST_P(RsaKeyTest, LoadPrivateKeyInPublicKey) { TEST_P(RsaKeyTest, EncryptAndDecrypt) { std::string encrypted_message; EXPECT_TRUE(public_key_->Encrypt(test_set_.test_message, &encrypted_message)); - if (kIsFakePrngSupported) + if (kIsFakePrngSupported) { EXPECT_EQ(test_set_.encrypted_message, encrypted_message); + } std::string decrypted_message; EXPECT_TRUE(private_key_->Decrypt(encrypted_message, &decrypted_message)); @@ -124,8 +125,9 @@ TEST_P(RsaKeyTest, SignAndVerify) { std::string signature; EXPECT_TRUE( private_key_->GenerateSignature(test_set_.test_message, &signature)); - if (kIsFakePrngSupported) + if (kIsFakePrngSupported) { EXPECT_EQ(test_set_.signature, signature); + } EXPECT_TRUE(public_key_->VerifySignature(test_set_.test_message, signature)); } diff --git a/packager/media/chunking/chunking.gyp b/packager/media/chunking/chunking.gyp index 89c9ffbfe2..57c00880df 100644 --- a/packager/media/chunking/chunking.gyp +++ b/packager/media/chunking/chunking.gyp @@ -5,9 +5,9 @@ # https://developers.google.com/open-source/licenses/bsd { - 'includes': [ - '../../common.gypi', - ], + 'variables': { + 'shaka_code': 1, + }, 'targets': [ { 'target_name': 'chunking', diff --git a/packager/media/codecs/codecs.gyp b/packager/media/codecs/codecs.gyp index f4c9b313b7..d0a4b49b03 100644 --- a/packager/media/codecs/codecs.gyp +++ b/packager/media/codecs/codecs.gyp @@ -5,9 +5,9 @@ # https://developers.google.com/open-source/licenses/bsd { - 'includes': [ - '../../common.gypi', - ], + 'variables': { + 'shaka_code': 1, + }, 'targets': [ { 'target_name': 'codecs', diff --git a/packager/media/crypto/crypto.gyp b/packager/media/crypto/crypto.gyp index a05e895d28..0b5b436286 100644 --- a/packager/media/crypto/crypto.gyp +++ b/packager/media/crypto/crypto.gyp @@ -5,9 +5,9 @@ # https://developers.google.com/open-source/licenses/bsd { - 'includes': [ - '../../common.gypi', - ], + 'variables': { + 'shaka_code': 1, + }, 'targets': [ { 'target_name': 'crypto', diff --git a/packager/media/demuxer/demuxer.gyp b/packager/media/demuxer/demuxer.gyp index 80492e86fd..473124d1cb 100644 --- a/packager/media/demuxer/demuxer.gyp +++ b/packager/media/demuxer/demuxer.gyp @@ -5,9 +5,9 @@ # https://developers.google.com/open-source/licenses/bsd { - 'includes': [ - '../../common.gypi', - ], + 'variables': { + 'shaka_code': 1, + }, 'targets': [ { 'target_name': 'demuxer', diff --git a/packager/media/event/media_event.gyp b/packager/media/event/media_event.gyp index 1b46e107d1..69956fc5aa 100644 --- a/packager/media/event/media_event.gyp +++ b/packager/media/event/media_event.gyp @@ -5,9 +5,9 @@ # https://developers.google.com/open-source/licenses/bsd { - 'includes': [ - '../../common.gypi', - ], + 'variables': { + 'shaka_code': 1, + }, 'targets': [ { 'target_name': 'media_event', diff --git a/packager/media/formats/mp2t/es_parser_h26x_unittest.cc b/packager/media/formats/mp2t/es_parser_h26x_unittest.cc index 40a5cf64c4..df07c1891e 100644 --- a/packager/media/formats/mp2t/es_parser_h26x_unittest.cc +++ b/packager/media/formats/mp2t/es_parser_h26x_unittest.cc @@ -166,8 +166,9 @@ class EsParserH26xTest : public testing::Test { void EmitSample(uint32_t pid, const std::shared_ptr& sample) { size_t sample_id = sample_count_; sample_count_++; - if (sample_count_ == 1) + if (sample_count_ == 1) { EXPECT_TRUE(sample->is_key_frame()); + } ASSERT_GT(samples_.size(), sample_id); const std::vector sample_data( diff --git a/packager/media/formats/mp2t/mp2t.gyp b/packager/media/formats/mp2t/mp2t.gyp index dc069d9ffc..64e5562934 100644 --- a/packager/media/formats/mp2t/mp2t.gyp +++ b/packager/media/formats/mp2t/mp2t.gyp @@ -5,9 +5,9 @@ # https://developers.google.com/open-source/licenses/bsd { - 'includes': [ - '../../../common.gypi', - ], + 'variables': { + 'shaka_code': 1, + }, 'targets': [ { 'target_name': 'mp2t', diff --git a/packager/media/formats/mp4/mp4.gyp b/packager/media/formats/mp4/mp4.gyp index f8003d592f..c442efa5da 100644 --- a/packager/media/formats/mp4/mp4.gyp +++ b/packager/media/formats/mp4/mp4.gyp @@ -5,9 +5,9 @@ # https://developers.google.com/open-source/licenses/bsd { - 'includes': [ - '../../../common.gypi', - ], + 'variables': { + 'shaka_code': 1, + }, 'targets': [ { 'target_name': 'mp4', diff --git a/packager/media/formats/mp4/track_run_iterator.cc b/packager/media/formats/mp4/track_run_iterator.cc index d05919c045..a1949fdf20 100644 --- a/packager/media/formats/mp4/track_run_iterator.cc +++ b/packager/media/formats/mp4/track_run_iterator.cc @@ -191,10 +191,12 @@ bool TrackRunIterator::Init() { // Check that total number of samples match. DCHECK_EQ(num_samples, decoding_time.NumSamples()); - if (has_composition_offset) + if (has_composition_offset) { DCHECK_EQ(num_samples, composition_offset.NumSamples()); - if (num_chunks > 0) + } + if (num_chunks > 0) { DCHECK_EQ(num_samples, chunk_info.NumSamples(1, num_chunks)); + } DCHECK_GE(num_chunks, chunk_info.LastFirstChunk()); if (num_samples > 0) { diff --git a/packager/media/formats/mp4/track_run_iterator_unittest.cc b/packager/media/formats/mp4/track_run_iterator_unittest.cc index 00cb0d8b01..46bbf14f41 100644 --- a/packager/media/formats/mp4/track_run_iterator_unittest.cc +++ b/packager/media/formats/mp4/track_run_iterator_unittest.cc @@ -18,6 +18,8 @@ const int kSumAscending1 = 45; const int kAudioScale = 48000; const int kVideoScale = 25; +const uint8_t kFullSampleEncryptionFlag = 0; + const uint8_t kDefaultCryptByteBlock = 2; const uint8_t kDefaultSkipByteBlock = 8; @@ -478,8 +480,7 @@ TEST_F(TrackRunIteratorTest, iter_.reset(new TrackRunIterator(&moov_)); MovieFragment moof = CreateFragment(); - AddSampleEncryption(!SampleEncryption::kUseSubsampleEncryption, - &moof.tracks[1]); + AddSampleEncryption(kFullSampleEncryptionFlag, &moof.tracks[1]); ASSERT_TRUE(iter_->Init(moof)); // The run for track 2 will be the second, which is parsed according to @@ -552,8 +553,7 @@ TEST_F(TrackRunIteratorTest, iter_.reset(new TrackRunIterator(&moov_)); MovieFragment moof = CreateFragment(); - AddSampleEncryptionWithConstantIv(!SampleEncryption::kUseSubsampleEncryption, - &moof.tracks[1]); + AddSampleEncryptionWithConstantIv(kFullSampleEncryptionFlag, &moof.tracks[1]); ASSERT_TRUE(iter_->Init(moof)); // The run for track 2 will be the second, which is parsed according to diff --git a/packager/media/formats/webm/encrypted_segmenter_unittest.cc b/packager/media/formats/webm/encrypted_segmenter_unittest.cc index 9a8818b4e2..3054e193f4 100644 --- a/packager/media/formats/webm/encrypted_segmenter_unittest.cc +++ b/packager/media/formats/webm/encrypted_segmenter_unittest.cc @@ -224,8 +224,9 @@ TEST_F(EncryptedSegmenterTest, BasicSupport) { // There should be 2 segments with the first segment in clear and the second // segment encrypted. for (int i = 0; i < 5; i++) { - if (i == 3) + if (i == 3) { ASSERT_OK(segmenter_->FinalizeSegment(0, 3 * kDuration, !kSubsegment)); + } std::shared_ptr sample = CreateSample(kKeyFrame, kDuration, kNoSideData); if (i >= 3) { diff --git a/packager/media/formats/webm/multi_segment_segmenter_unittest.cc b/packager/media/formats/webm/multi_segment_segmenter_unittest.cc index 50b1924a02..5513f00c51 100644 --- a/packager/media/formats/webm/multi_segment_segmenter_unittest.cc +++ b/packager/media/formats/webm/multi_segment_segmenter_unittest.cc @@ -144,8 +144,9 @@ TEST_F(MultiSegmentSegmenterTest, SplitsFilesOnSegment) { // Write the samples to the Segmenter. for (int i = 0; i < 8; i++) { - if (i == 5) + if (i == 5) { ASSERT_OK(segmenter_->FinalizeSegment(0, 5 * kDuration, !kSubsegment)); + } std::shared_ptr sample = CreateSample(kKeyFrame, kDuration, kNoSideData); ASSERT_OK(segmenter_->AddSample(*sample)); @@ -174,8 +175,9 @@ TEST_F(MultiSegmentSegmenterTest, SplitsClustersOnSubsegment) { // Write the samples to the Segmenter. for (int i = 0; i < 8; i++) { - if (i == 5) + if (i == 5) { ASSERT_OK(segmenter_->FinalizeSegment(0, 5 * kDuration, kSubsegment)); + } std::shared_ptr sample = CreateSample(kKeyFrame, kDuration, kNoSideData); ASSERT_OK(segmenter_->AddSample(*sample)); diff --git a/packager/media/formats/webm/single_segment_segmenter_unittest.cc b/packager/media/formats/webm/single_segment_segmenter_unittest.cc index c7d458ec51..175931183b 100644 --- a/packager/media/formats/webm/single_segment_segmenter_unittest.cc +++ b/packager/media/formats/webm/single_segment_segmenter_unittest.cc @@ -175,8 +175,9 @@ TEST_F(SingleSegmentSegmenterTest, SplitsClustersOnSegment) { // Write the samples to the Segmenter. for (int i = 0; i < 8; i++) { - if (i == 5) + if (i == 5) { ASSERT_OK(segmenter_->FinalizeSegment(0, 5 * kDuration, !kSubsegment)); + } std::shared_ptr sample = CreateSample(kKeyFrame, kDuration, kNoSideData); ASSERT_OK(segmenter_->AddSample(*sample)); @@ -199,8 +200,9 @@ TEST_F(SingleSegmentSegmenterTest, IgnoresSubsegment) { // Write the samples to the Segmenter. for (int i = 0; i < 8; i++) { - if (i == 5) + if (i == 5) { ASSERT_OK(segmenter_->FinalizeSegment(0, 5 * kDuration, kSubsegment)); + } std::shared_ptr sample = CreateSample(kKeyFrame, kDuration, kNoSideData); ASSERT_OK(segmenter_->AddSample(*sample)); diff --git a/packager/media/formats/webm/webm.gyp b/packager/media/formats/webm/webm.gyp index cd4f1698cb..9cc94c0147 100644 --- a/packager/media/formats/webm/webm.gyp +++ b/packager/media/formats/webm/webm.gyp @@ -5,9 +5,9 @@ # https://developers.google.com/open-source/licenses/bsd { - 'includes': [ - '../../../common.gypi', - ], + 'variables': { + 'shaka_code': 1, + }, 'targets': [ { 'target_name': 'webm', diff --git a/packager/media/formats/webvtt/webvtt.gyp b/packager/media/formats/webvtt/webvtt.gyp index c0c7d3317a..46864452d3 100644 --- a/packager/media/formats/webvtt/webvtt.gyp +++ b/packager/media/formats/webvtt/webvtt.gyp @@ -5,9 +5,9 @@ # https://developers.google.com/open-source/licenses/bsd { - 'includes': [ - '../../../common.gypi', - ], + 'variables': { + 'shaka_code': 1, + }, 'targets': [ { 'target_name': 'webvtt', diff --git a/packager/media/formats/wvm/wvm.gyp b/packager/media/formats/wvm/wvm.gyp index 530e0ce735..f523b5f92a 100644 --- a/packager/media/formats/wvm/wvm.gyp +++ b/packager/media/formats/wvm/wvm.gyp @@ -5,9 +5,9 @@ # https://developers.google.com/open-source/licenses/bsd { - 'includes': [ - '../../../common.gypi', - ], + 'variables': { + 'shaka_code': 1, + }, 'targets': [ { 'target_name': 'wvm', diff --git a/packager/media/origin/origin.gyp b/packager/media/origin/origin.gyp index 4a5c34e3b0..d1c7c8fddf 100644 --- a/packager/media/origin/origin.gyp +++ b/packager/media/origin/origin.gyp @@ -5,9 +5,9 @@ # https://developers.google.com/open-source/licenses/bsd { - 'includes': [ - '../../common.gypi', - ], + 'variables': { + 'shaka_code': 1, + }, 'targets': [ { 'target_name': 'origin', diff --git a/packager/media/public/public.gyp b/packager/media/public/public.gyp index 4db3bc0a3e..6f5a37212a 100644 --- a/packager/media/public/public.gyp +++ b/packager/media/public/public.gyp @@ -5,9 +5,9 @@ # https://developers.google.com/open-source/licenses/bsd { - 'includes': [ - '../../common.gypi', - ], + 'variables': { + 'shaka_code': 1, + }, 'targets': [ { 'target_name': 'public', diff --git a/packager/media/replicator/replicator.gyp b/packager/media/replicator/replicator.gyp index 6879102a9d..fbb723d5bc 100644 --- a/packager/media/replicator/replicator.gyp +++ b/packager/media/replicator/replicator.gyp @@ -5,9 +5,9 @@ # https://developers.google.com/open-source/licenses/bsd { - 'includes': [ - '../../common.gypi', - ], + 'variables': { + 'shaka_code': 1, + }, 'targets': [ { 'target_name': 'replicator', diff --git a/packager/media/test/media_test.gyp b/packager/media/test/media_test.gyp index 0d3b4f74e6..924bbb40dc 100644 --- a/packager/media/test/media_test.gyp +++ b/packager/media/test/media_test.gyp @@ -5,9 +5,9 @@ # https://developers.google.com/open-source/licenses/bsd { - 'includes': [ - '../../common.gypi', - ], + 'variables': { + 'shaka_code': 1, + }, 'targets': [ { 'target_name': 'run_tests_with_atexit_manager', diff --git a/packager/media/trick_play/trick_play.gyp b/packager/media/trick_play/trick_play.gyp index 5263ccd68d..4590ab375b 100644 --- a/packager/media/trick_play/trick_play.gyp +++ b/packager/media/trick_play/trick_play.gyp @@ -5,9 +5,9 @@ # https://developers.google.com/open-source/licenses/bsd { - 'includes': [ - '../../common.gypi', - ], + 'variables': { + 'shaka_code': 1, + }, 'targets': [ { 'target_name': 'trick_play', diff --git a/packager/mpd/mpd.gyp b/packager/mpd/mpd.gyp index 990ee15f87..4017130baa 100644 --- a/packager/mpd/mpd.gyp +++ b/packager/mpd/mpd.gyp @@ -7,9 +7,9 @@ # GYP file for any MPD generation targets. { - 'includes': [ - '../common.gypi', - ], + 'variables': { + 'shaka_code': 1, + }, 'targets': [ { 'target_name': 'media_info_proto', diff --git a/packager/packager.gyp b/packager/packager.gyp index 467ec3d94b..6d3696eb1f 100644 --- a/packager/packager.gyp +++ b/packager/packager.gyp @@ -5,9 +5,9 @@ # https://developers.google.com/open-source/licenses/bsd { - 'includes': [ - 'common.gypi', - ], + 'variables': { + 'shaka_code': 1, + }, 'targets': [ { 'target_name': 'libpackager', diff --git a/packager/third_party/curl/config/linux/curl_config.h b/packager/third_party/curl/config/linux/curl_config.h index 6d502d629e..3b49fe8fa6 100644 --- a/packager/third_party/curl/config/linux/curl_config.h +++ b/packager/third_party/curl/config/linux/curl_config.h @@ -647,7 +647,8 @@ /* #undef HAVE_STRNICMP */ /* Define to 1 if you have the header file. */ -#define HAVE_STROPTS_H 1 +/* Disabled for packager as it breaks some linux distros. */ +/* #undef HAVE_STROPTS_H */ /* Define to 1 if you have the strstr function. */ #define HAVE_STRSTR 1 diff --git a/packager/version/version.gyp b/packager/version/version.gyp index 37ab00d805..8ec850ee50 100644 --- a/packager/version/version.gyp +++ b/packager/version/version.gyp @@ -5,9 +5,9 @@ # https://developers.google.com/open-source/licenses/bsd { - 'includes': [ - '../common.gypi', - ], + 'variables': { + 'shaka_code': 1, + }, 'targets': [ { 'target_name': 'version',