From 692c03ffe2bd7033dc2e31163095efebace7e642 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Wed, 16 Dec 2015 19:07:14 -0800 Subject: Merge to XFA: Make clang_warning_flags work for standalone builds. Also fix a newly introduced override warning. Also define a host_clang GYP variable. TBR=thakis@chromium.org Review URL: https://codereview.chromium.org/1532723003 . Review URL: https://codereview.chromium.org/1533763002 . (cherry picked from commit e096ca507db9944aebc47d6c2cc1c6fab39498c5) (cherry picked from commit 0a9158b99a2002fb82301ebec20dbc23b3fc084c) Review URL: https://codereview.chromium.org/1535603003 . --- build/set_clang_warning_flags.gypi | 58 ++++++++++++++++++++++ build/standalone.gypi | 6 +++ .../fpdf_parser/fpdf_parser_parser_unittest.cpp | 4 +- 3 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 build/set_clang_warning_flags.gypi diff --git a/build/set_clang_warning_flags.gypi b/build/set_clang_warning_flags.gypi new file mode 100644 index 0000000000..f6d7aea700 --- /dev/null +++ b/build/set_clang_warning_flags.gypi @@ -0,0 +1,58 @@ +# Copyright (c) 2014 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 to set clang-specific compiler flags. +# To use this the following variable can be defined: +# clang_warning_flags: list: Compiler flags to pass to clang. +# clang_warning_flags_unset: list: Compiler flags to not pass to clang. +# +# Only use this in third-party code. In chromium_code, fix your code to not +# warn instead! +# +# Note that the gypi file is included in target_defaults, so it does not need +# to be explicitly included. +# +# Warning flags set by this will be used on all platforms. If you want to set +# warning flags on only some platforms, you have to do so manually. +# +# To use this, create a gyp target with the following form: +# { +# 'target_name': 'my_target', +# 'variables': { +# 'clang_warning_flags': ['-Wno-awesome-warning'], +# 'clang_warning_flags_unset': ['-Wpreviously-set-flag'], +# } +# } + +{ + 'variables': { + 'clang_warning_flags_unset%': [], # Provide a default value. + }, + 'conditions': [ + ['clang==1', { + # This uses >@ instead of @< to also see clang_warning_flags set in + # targets directly, not just the clang_warning_flags in target_defaults. + 'cflags': [ '>@(clang_warning_flags)' ], + 'cflags!': [ '>@(clang_warning_flags_unset)' ], + 'xcode_settings': { + 'WARNING_CFLAGS': ['>@(clang_warning_flags)'], + 'WARNING_CFLAGS!': ['>@(clang_warning_flags_unset)'], + }, + 'msvs_settings': { + 'VCCLCompilerTool': { + 'AdditionalOptions': [ '>@(clang_warning_flags)' ], + 'AdditionalOptions!': [ '>@(clang_warning_flags_unset)' ], + }, + }, + }], + ['clang==0 and host_clang==1', { + 'target_conditions': [ + ['_toolset=="host"', { + 'cflags': [ '>@(clang_warning_flags)' ], + 'cflags!': [ '>@(clang_warning_flags_unset)' ], + }], + ], + }], + ], +} diff --git a/build/standalone.gypi b/build/standalone.gypi index 2eac19882c..de638de97c 100644 --- a/build/standalone.gypi +++ b/build/standalone.gypi @@ -59,8 +59,10 @@ }], ['OS=="linux" or OS=="mac"', { 'clang%': 1, + 'host_clang%': 1, }, { 'clang%': 0, + 'host_clang%': 0, }], # Set default gomadir. ['OS=="win"', { @@ -261,6 +263,10 @@ '-Wno-unused-parameter', ], }, + 'variables': { + 'clang_warning_flags': [], + }, + 'includes': [ 'set_clang_warning_flags.gypi', ], 'conditions': [ ['component=="shared_library"', { 'cflags': [ diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser_unittest.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser_unittest.cpp index aba639c850..d3187c1ff4 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser_unittest.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser_unittest.cpp @@ -43,7 +43,7 @@ class CFX_TestBufferRead : public IFX_FileRead { void Release() override { delete this; } // IFX_FileRead - virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) { + FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override { if (offset < 0 || offset + size > total_size_) { return FALSE; } @@ -51,7 +51,7 @@ class CFX_TestBufferRead : public IFX_FileRead { memcpy(buffer, buffer_ + offset, size); return TRUE; } - virtual FX_FILESIZE GetSize() { return (FX_FILESIZE)total_size_; }; + FX_FILESIZE GetSize() override { return (FX_FILESIZE)total_size_; }; protected: const unsigned char* buffer_; -- cgit v1.2.3