Address gcc build failures in some platforms

Seeing some failures on some platforms when compiled with clang
disabled:
  GYP_DEFINES="clang=0" gclient runhooks

Several changes to make it work:
1. Mark packager code with packager_code=1 in GYP definitions.
2. Disable a few checks in non-packager code, which we do not have
   direct control: dangling-else, deprecated-declarations,
                   unused-function
3. Fix the relevant errors in packager code.
4. Revert HAVE_STROPTS_H in curl config which is not available in
   all linux distributions.

Fixes #286
Fixes #293

Change-Id: I729b41f99403c5ad9487c6cc4a7dc06f6323cef8
This commit is contained in:
KongQun Yang 2017-12-06 15:08:40 -08:00
parent e97c89391a
commit 8e96dd3b37
34 changed files with 150 additions and 110 deletions

View File

@ -56,8 +56,11 @@ if __name__ == '__main__':
if [arg.endswith('.gyp') for arg in args].count(True) == 0: if [arg.endswith('.gyp') for arg in args].count(True) == 0:
args.append(os.path.join(src_dir, 'packager.gyp')) args.append(os.path.join(src_dir, 'packager.gyp'))
# Always include common.gypi. # Always include Chromium's common.gypi and our common.gypi.
args.extend(['-I' + os.path.join(src_dir, 'build', '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. # Set these default GYP_DEFINES if user does not set the value explicitly.
_DEFAULT_DEFINES = {'test_isolation_mode': 'noop', _DEFAULT_DEFINES = {'test_isolation_mode': 'noop',

View File

@ -8,38 +8,62 @@
{ {
'variables': { 'variables': {
# Compile as Chromium code to enable warnings and warnings-as-errors. 'variables': {
'chromium_code': 1, 'shaka_code%': 0,
},
'shaka_code%': '<(shaka_code)',
'libpackager_type%': 'static_library', 'libpackager_type%': 'static_library',
'conditions': [
['shaka_code==1', {
# This enable warnings and warnings-as-errors.
'chromium_code': 1,
}],
],
}, },
'target_defaults': { 'target_defaults': {
'include_dirs': [
'.',
'..',
],
'conditions': [ 'conditions': [
['clang==1', { ['shaka_code==1', {
'cflags': [ 'include_dirs': [
'-Wimplicit-fallthrough', '.',
'..',
], ],
# Revert the relevant settings in Chromium's common.gypi. 'conditions': [
'cflags!': [ ['clang==1', {
'-Wno-char-subscripts', 'cflags': [
'-Wno-unneeded-internal-declaration', '-Wimplicit-fallthrough',
'-Wno-covered-switch-default', ],
# 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: # C++11-related flags:
'-Wno-c++11-narrowing', '-Wno-c++11-narrowing',
'-Wno-reserved-user-defined-literal', '-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']
},
},
}], }],
], ],
}, },

View File

@ -5,9 +5,9 @@
# https://developers.google.com/open-source/licenses/bsd # https://developers.google.com/open-source/licenses/bsd
{ {
'includes': [ 'variables': {
'../common.gypi', 'shaka_code': 1,
], },
'targets': [ 'targets': [
{ {
'target_name': 'file', 'target_name': 'file',

View File

@ -5,9 +5,9 @@
# https://developers.google.com/open-source/licenses/bsd # https://developers.google.com/open-source/licenses/bsd
{ {
'includes': [ 'variables': {
'../common.gypi', 'shaka_code': 1,
], },
'targets': [ 'targets': [
{ {
'target_name': 'hls_builder', 'target_name': 'hls_builder',

View File

@ -5,9 +5,9 @@
# https://developers.google.com/open-source/licenses/bsd # https://developers.google.com/open-source/licenses/bsd
{ {
'includes': [ 'variables': {
'../../common.gypi', 'shaka_code': 1,
], },
'targets': [ 'targets': [
{ {
'target_name': 'ad_cue_generator', 'target_name': 'ad_cue_generator',

View File

@ -603,8 +603,9 @@ TEST_P(AesCbcCryptorVerificationTest, EncryptDecryptTest) {
std::vector<uint8_t> plaintext; std::vector<uint8_t> plaintext;
std::string plaintext_hex(GetParam().plaintext_hex); std::string plaintext_hex(GetParam().plaintext_hex);
if (!plaintext_hex.empty()) if (!plaintext_hex.empty()) {
ASSERT_TRUE(base::HexStringToBytes(plaintext_hex, &plaintext)); ASSERT_TRUE(base::HexStringToBytes(plaintext_hex, &plaintext));
}
std::vector<uint8_t> expected_ciphertext; std::vector<uint8_t> expected_ciphertext;
std::string expected_ciphertext_hex(GetParam().expected_ciphertext_hex); std::string expected_ciphertext_hex(GetParam().expected_ciphertext_hex);

View File

@ -112,8 +112,9 @@ class AesPatternCryptorVerificationTest
TEST_P(AesPatternCryptorVerificationTest, PatternTest) { TEST_P(AesPatternCryptorVerificationTest, PatternTest) {
std::vector<uint8_t> text; std::vector<uint8_t> text;
std::string text_hex(GetParam().text_hex); std::string text_hex(GetParam().text_hex);
if (!text_hex.empty()) if (!text_hex.empty()) {
ASSERT_TRUE(base::HexStringToBytes(text_hex, &text)); ASSERT_TRUE(base::HexStringToBytes(text_hex, &text));
}
std::vector<uint8_t> expected_crypt_text; std::vector<uint8_t> expected_crypt_text;
std::string expected_crypt_text_hex(GetParam().expected_crypt_text_hex); std::string expected_crypt_text_hex(GetParam().expected_crypt_text_hex);
if (!expected_crypt_text_hex.empty()) { if (!expected_crypt_text_hex.empty()) {

View File

@ -5,9 +5,9 @@
# https://developers.google.com/open-source/licenses/bsd # https://developers.google.com/open-source/licenses/bsd
{ {
'includes': [ 'variables': {
'../../common.gypi', 'shaka_code': 1,
], },
'targets': [ 'targets': [
{ {
'target_name': 'media_base', 'target_name': 'media_base',

View File

@ -86,8 +86,9 @@ TEST_P(RsaKeyTest, LoadPrivateKeyInPublicKey) {
TEST_P(RsaKeyTest, EncryptAndDecrypt) { TEST_P(RsaKeyTest, EncryptAndDecrypt) {
std::string encrypted_message; std::string encrypted_message;
EXPECT_TRUE(public_key_->Encrypt(test_set_.test_message, &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); EXPECT_EQ(test_set_.encrypted_message, encrypted_message);
}
std::string decrypted_message; std::string decrypted_message;
EXPECT_TRUE(private_key_->Decrypt(encrypted_message, &decrypted_message)); EXPECT_TRUE(private_key_->Decrypt(encrypted_message, &decrypted_message));
@ -124,8 +125,9 @@ TEST_P(RsaKeyTest, SignAndVerify) {
std::string signature; std::string signature;
EXPECT_TRUE( EXPECT_TRUE(
private_key_->GenerateSignature(test_set_.test_message, &signature)); private_key_->GenerateSignature(test_set_.test_message, &signature));
if (kIsFakePrngSupported) if (kIsFakePrngSupported) {
EXPECT_EQ(test_set_.signature, signature); EXPECT_EQ(test_set_.signature, signature);
}
EXPECT_TRUE(public_key_->VerifySignature(test_set_.test_message, signature)); EXPECT_TRUE(public_key_->VerifySignature(test_set_.test_message, signature));
} }

View File

@ -5,9 +5,9 @@
# https://developers.google.com/open-source/licenses/bsd # https://developers.google.com/open-source/licenses/bsd
{ {
'includes': [ 'variables': {
'../../common.gypi', 'shaka_code': 1,
], },
'targets': [ 'targets': [
{ {
'target_name': 'chunking', 'target_name': 'chunking',

View File

@ -5,9 +5,9 @@
# https://developers.google.com/open-source/licenses/bsd # https://developers.google.com/open-source/licenses/bsd
{ {
'includes': [ 'variables': {
'../../common.gypi', 'shaka_code': 1,
], },
'targets': [ 'targets': [
{ {
'target_name': 'codecs', 'target_name': 'codecs',

View File

@ -5,9 +5,9 @@
# https://developers.google.com/open-source/licenses/bsd # https://developers.google.com/open-source/licenses/bsd
{ {
'includes': [ 'variables': {
'../../common.gypi', 'shaka_code': 1,
], },
'targets': [ 'targets': [
{ {
'target_name': 'crypto', 'target_name': 'crypto',

View File

@ -5,9 +5,9 @@
# https://developers.google.com/open-source/licenses/bsd # https://developers.google.com/open-source/licenses/bsd
{ {
'includes': [ 'variables': {
'../../common.gypi', 'shaka_code': 1,
], },
'targets': [ 'targets': [
{ {
'target_name': 'demuxer', 'target_name': 'demuxer',

View File

@ -5,9 +5,9 @@
# https://developers.google.com/open-source/licenses/bsd # https://developers.google.com/open-source/licenses/bsd
{ {
'includes': [ 'variables': {
'../../common.gypi', 'shaka_code': 1,
], },
'targets': [ 'targets': [
{ {
'target_name': 'media_event', 'target_name': 'media_event',

View File

@ -166,8 +166,9 @@ class EsParserH26xTest : public testing::Test {
void EmitSample(uint32_t pid, const std::shared_ptr<MediaSample>& sample) { void EmitSample(uint32_t pid, const std::shared_ptr<MediaSample>& sample) {
size_t sample_id = sample_count_; size_t sample_id = sample_count_;
sample_count_++; sample_count_++;
if (sample_count_ == 1) if (sample_count_ == 1) {
EXPECT_TRUE(sample->is_key_frame()); EXPECT_TRUE(sample->is_key_frame());
}
ASSERT_GT(samples_.size(), sample_id); ASSERT_GT(samples_.size(), sample_id);
const std::vector<uint8_t> sample_data( const std::vector<uint8_t> sample_data(

View File

@ -5,9 +5,9 @@
# https://developers.google.com/open-source/licenses/bsd # https://developers.google.com/open-source/licenses/bsd
{ {
'includes': [ 'variables': {
'../../../common.gypi', 'shaka_code': 1,
], },
'targets': [ 'targets': [
{ {
'target_name': 'mp2t', 'target_name': 'mp2t',

View File

@ -5,9 +5,9 @@
# https://developers.google.com/open-source/licenses/bsd # https://developers.google.com/open-source/licenses/bsd
{ {
'includes': [ 'variables': {
'../../../common.gypi', 'shaka_code': 1,
], },
'targets': [ 'targets': [
{ {
'target_name': 'mp4', 'target_name': 'mp4',

View File

@ -191,10 +191,12 @@ bool TrackRunIterator::Init() {
// Check that total number of samples match. // Check that total number of samples match.
DCHECK_EQ(num_samples, decoding_time.NumSamples()); DCHECK_EQ(num_samples, decoding_time.NumSamples());
if (has_composition_offset) if (has_composition_offset) {
DCHECK_EQ(num_samples, composition_offset.NumSamples()); 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_EQ(num_samples, chunk_info.NumSamples(1, num_chunks));
}
DCHECK_GE(num_chunks, chunk_info.LastFirstChunk()); DCHECK_GE(num_chunks, chunk_info.LastFirstChunk());
if (num_samples > 0) { if (num_samples > 0) {

View File

@ -18,6 +18,8 @@ const int kSumAscending1 = 45;
const int kAudioScale = 48000; const int kAudioScale = 48000;
const int kVideoScale = 25; const int kVideoScale = 25;
const uint8_t kFullSampleEncryptionFlag = 0;
const uint8_t kDefaultCryptByteBlock = 2; const uint8_t kDefaultCryptByteBlock = 2;
const uint8_t kDefaultSkipByteBlock = 8; const uint8_t kDefaultSkipByteBlock = 8;
@ -478,8 +480,7 @@ TEST_F(TrackRunIteratorTest,
iter_.reset(new TrackRunIterator(&moov_)); iter_.reset(new TrackRunIterator(&moov_));
MovieFragment moof = CreateFragment(); MovieFragment moof = CreateFragment();
AddSampleEncryption(!SampleEncryption::kUseSubsampleEncryption, AddSampleEncryption(kFullSampleEncryptionFlag, &moof.tracks[1]);
&moof.tracks[1]);
ASSERT_TRUE(iter_->Init(moof)); ASSERT_TRUE(iter_->Init(moof));
// The run for track 2 will be the second, which is parsed according to // 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_)); iter_.reset(new TrackRunIterator(&moov_));
MovieFragment moof = CreateFragment(); MovieFragment moof = CreateFragment();
AddSampleEncryptionWithConstantIv(!SampleEncryption::kUseSubsampleEncryption, AddSampleEncryptionWithConstantIv(kFullSampleEncryptionFlag, &moof.tracks[1]);
&moof.tracks[1]);
ASSERT_TRUE(iter_->Init(moof)); ASSERT_TRUE(iter_->Init(moof));
// The run for track 2 will be the second, which is parsed according to // The run for track 2 will be the second, which is parsed according to

View File

@ -224,8 +224,9 @@ TEST_F(EncryptedSegmenterTest, BasicSupport) {
// There should be 2 segments with the first segment in clear and the second // There should be 2 segments with the first segment in clear and the second
// segment encrypted. // segment encrypted.
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
if (i == 3) if (i == 3) {
ASSERT_OK(segmenter_->FinalizeSegment(0, 3 * kDuration, !kSubsegment)); ASSERT_OK(segmenter_->FinalizeSegment(0, 3 * kDuration, !kSubsegment));
}
std::shared_ptr<MediaSample> sample = std::shared_ptr<MediaSample> sample =
CreateSample(kKeyFrame, kDuration, kNoSideData); CreateSample(kKeyFrame, kDuration, kNoSideData);
if (i >= 3) { if (i >= 3) {

View File

@ -144,8 +144,9 @@ TEST_F(MultiSegmentSegmenterTest, SplitsFilesOnSegment) {
// Write the samples to the Segmenter. // Write the samples to the Segmenter.
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
if (i == 5) if (i == 5) {
ASSERT_OK(segmenter_->FinalizeSegment(0, 5 * kDuration, !kSubsegment)); ASSERT_OK(segmenter_->FinalizeSegment(0, 5 * kDuration, !kSubsegment));
}
std::shared_ptr<MediaSample> sample = std::shared_ptr<MediaSample> sample =
CreateSample(kKeyFrame, kDuration, kNoSideData); CreateSample(kKeyFrame, kDuration, kNoSideData);
ASSERT_OK(segmenter_->AddSample(*sample)); ASSERT_OK(segmenter_->AddSample(*sample));
@ -174,8 +175,9 @@ TEST_F(MultiSegmentSegmenterTest, SplitsClustersOnSubsegment) {
// Write the samples to the Segmenter. // Write the samples to the Segmenter.
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
if (i == 5) if (i == 5) {
ASSERT_OK(segmenter_->FinalizeSegment(0, 5 * kDuration, kSubsegment)); ASSERT_OK(segmenter_->FinalizeSegment(0, 5 * kDuration, kSubsegment));
}
std::shared_ptr<MediaSample> sample = std::shared_ptr<MediaSample> sample =
CreateSample(kKeyFrame, kDuration, kNoSideData); CreateSample(kKeyFrame, kDuration, kNoSideData);
ASSERT_OK(segmenter_->AddSample(*sample)); ASSERT_OK(segmenter_->AddSample(*sample));

View File

@ -175,8 +175,9 @@ TEST_F(SingleSegmentSegmenterTest, SplitsClustersOnSegment) {
// Write the samples to the Segmenter. // Write the samples to the Segmenter.
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
if (i == 5) if (i == 5) {
ASSERT_OK(segmenter_->FinalizeSegment(0, 5 * kDuration, !kSubsegment)); ASSERT_OK(segmenter_->FinalizeSegment(0, 5 * kDuration, !kSubsegment));
}
std::shared_ptr<MediaSample> sample = std::shared_ptr<MediaSample> sample =
CreateSample(kKeyFrame, kDuration, kNoSideData); CreateSample(kKeyFrame, kDuration, kNoSideData);
ASSERT_OK(segmenter_->AddSample(*sample)); ASSERT_OK(segmenter_->AddSample(*sample));
@ -199,8 +200,9 @@ TEST_F(SingleSegmentSegmenterTest, IgnoresSubsegment) {
// Write the samples to the Segmenter. // Write the samples to the Segmenter.
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
if (i == 5) if (i == 5) {
ASSERT_OK(segmenter_->FinalizeSegment(0, 5 * kDuration, kSubsegment)); ASSERT_OK(segmenter_->FinalizeSegment(0, 5 * kDuration, kSubsegment));
}
std::shared_ptr<MediaSample> sample = std::shared_ptr<MediaSample> sample =
CreateSample(kKeyFrame, kDuration, kNoSideData); CreateSample(kKeyFrame, kDuration, kNoSideData);
ASSERT_OK(segmenter_->AddSample(*sample)); ASSERT_OK(segmenter_->AddSample(*sample));

View File

@ -5,9 +5,9 @@
# https://developers.google.com/open-source/licenses/bsd # https://developers.google.com/open-source/licenses/bsd
{ {
'includes': [ 'variables': {
'../../../common.gypi', 'shaka_code': 1,
], },
'targets': [ 'targets': [
{ {
'target_name': 'webm', 'target_name': 'webm',

View File

@ -5,9 +5,9 @@
# https://developers.google.com/open-source/licenses/bsd # https://developers.google.com/open-source/licenses/bsd
{ {
'includes': [ 'variables': {
'../../../common.gypi', 'shaka_code': 1,
], },
'targets': [ 'targets': [
{ {
'target_name': 'webvtt', 'target_name': 'webvtt',

View File

@ -5,9 +5,9 @@
# https://developers.google.com/open-source/licenses/bsd # https://developers.google.com/open-source/licenses/bsd
{ {
'includes': [ 'variables': {
'../../../common.gypi', 'shaka_code': 1,
], },
'targets': [ 'targets': [
{ {
'target_name': 'wvm', 'target_name': 'wvm',

View File

@ -5,9 +5,9 @@
# https://developers.google.com/open-source/licenses/bsd # https://developers.google.com/open-source/licenses/bsd
{ {
'includes': [ 'variables': {
'../../common.gypi', 'shaka_code': 1,
], },
'targets': [ 'targets': [
{ {
'target_name': 'origin', 'target_name': 'origin',

View File

@ -5,9 +5,9 @@
# https://developers.google.com/open-source/licenses/bsd # https://developers.google.com/open-source/licenses/bsd
{ {
'includes': [ 'variables': {
'../../common.gypi', 'shaka_code': 1,
], },
'targets': [ 'targets': [
{ {
'target_name': 'public', 'target_name': 'public',

View File

@ -5,9 +5,9 @@
# https://developers.google.com/open-source/licenses/bsd # https://developers.google.com/open-source/licenses/bsd
{ {
'includes': [ 'variables': {
'../../common.gypi', 'shaka_code': 1,
], },
'targets': [ 'targets': [
{ {
'target_name': 'replicator', 'target_name': 'replicator',

View File

@ -5,9 +5,9 @@
# https://developers.google.com/open-source/licenses/bsd # https://developers.google.com/open-source/licenses/bsd
{ {
'includes': [ 'variables': {
'../../common.gypi', 'shaka_code': 1,
], },
'targets': [ 'targets': [
{ {
'target_name': 'run_tests_with_atexit_manager', 'target_name': 'run_tests_with_atexit_manager',

View File

@ -5,9 +5,9 @@
# https://developers.google.com/open-source/licenses/bsd # https://developers.google.com/open-source/licenses/bsd
{ {
'includes': [ 'variables': {
'../../common.gypi', 'shaka_code': 1,
], },
'targets': [ 'targets': [
{ {
'target_name': 'trick_play', 'target_name': 'trick_play',

View File

@ -7,9 +7,9 @@
# GYP file for any MPD generation targets. # GYP file for any MPD generation targets.
{ {
'includes': [ 'variables': {
'../common.gypi', 'shaka_code': 1,
], },
'targets': [ 'targets': [
{ {
'target_name': 'media_info_proto', 'target_name': 'media_info_proto',

View File

@ -5,9 +5,9 @@
# https://developers.google.com/open-source/licenses/bsd # https://developers.google.com/open-source/licenses/bsd
{ {
'includes': [ 'variables': {
'common.gypi', 'shaka_code': 1,
], },
'targets': [ 'targets': [
{ {
'target_name': 'libpackager', 'target_name': 'libpackager',

View File

@ -647,7 +647,8 @@
/* #undef HAVE_STRNICMP */ /* #undef HAVE_STRNICMP */
/* Define to 1 if you have the <stropts.h> header file. */ /* Define to 1 if you have the <stropts.h> 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 to 1 if you have the strstr function. */
#define HAVE_STRSTR 1 #define HAVE_STRSTR 1

View File

@ -5,9 +5,9 @@
# https://developers.google.com/open-source/licenses/bsd # https://developers.google.com/open-source/licenses/bsd
{ {
'includes': [ 'variables': {
'../common.gypi', 'shaka_code': 1,
], },
'targets': [ 'targets': [
{ {
'target_name': 'version', 'target_name': 'version',