diff options
author | weili <weili@chromium.org> | 2016-05-16 17:52:17 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-05-16 17:52:17 -0700 |
commit | 5f3b41bca725090391b9053a9435c86fa7b22df1 (patch) | |
tree | 2c2adf52a6cf127de85d1f1705b6c56b52b4fec2 | |
parent | 3857904e520ecb06bad545e4e4bfcf4e60dd1f52 (diff) | |
download | pdfium-5f3b41bca725090391b9053a9435c86fa7b22df1.tar.xz |
Use chromium_code standard for PDFium GYP compilation
Define and use chromium_code to be used in standalone PDFium GYP
build so that PDFium code can have more stringent warning level.
This is also enabled on GN build by default so that GYP and GN
builds can have consistent compilation results.
Also enable chromium_code for PDFium compilation in Chromium
since most of the warnings are cleared. The left ones are clearly
marked and will be addressed soon.
A few more clean-ups for the build:
-- Remove the suppression of sign-compare warnings for Clang since
the code is clean and the warning can be re-enabled.
-- Re-enable "treat warning as errors" on Mac
-- Add a flag to make GCC build works as well.
BUG=pdfium:29, pdfium:475
Review-Url: https://codereview.chromium.org/1985843002
-rw-r--r-- | build_gyp/standalone.gypi | 51 | ||||
-rw-r--r-- | pdfium.gyp | 11 | ||||
-rw-r--r-- | third_party/third_party.gyp | 9 | ||||
-rw-r--r-- | xfa.gyp | 8 |
4 files changed, 54 insertions, 25 deletions
diff --git a/build_gyp/standalone.gypi b/build_gyp/standalone.gypi index be18b5006c..f191c28e42 100644 --- a/build_gyp/standalone.gypi +++ b/build_gyp/standalone.gypi @@ -7,6 +7,7 @@ { 'variables': { 'component%': 'static_library', + 'chromium_code%': 0, 'clang%': 0, 'asan%': 0, 'sanitizer_coverage%': 0, @@ -172,11 +173,9 @@ 'cflags': [ '-Wall', '-Werror', - '-W', + '-Wextra', + # Two common warning flags for Clang and GCC. '-Wno-missing-field-initializers', - # Code might someday be made clean for -Wsign-compare, but for now - # this produces too much noise to be useful. - '-Wno-sign-compare', '-Wno-unused-parameter', '-pthread', '-fno-exceptions', @@ -360,6 +359,7 @@ 'xcode_settings': { 'ALWAYS_SEARCH_USER_PATHS': 'NO', 'CLANG_CXX_LANGUAGE_STANDARD': 'c++11', + 'CLANG_CXX_LIBRARY': 'libc++', # -stdlib=libc++ 'GCC_CW_ASM_SYNTAX': 'NO', # No -fasm-blocks 'GCC_DYNAMIC_NO_PIC': 'NO', # No -mdynamic-no-pic # (Equivalent to -fPIC) @@ -371,6 +371,7 @@ 'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden 'GCC_TREAT_WARNINGS_AS_ERRORS': 'NO', # -Werror 'GCC_WARN_NON_VIRTUAL_DESTRUCTOR': 'YES', # -Wnon-virtual-dtor + 'MACOSX_DEPLOYMENT_TARGET': '10.7', # -mmacosx-version-min 'SYMROOT': '<(DEPTH)/xcodebuild', 'USE_HEADERMAP': 'NO', 'OTHER_CFLAGS': [ @@ -378,12 +379,13 @@ ], 'WARNING_CFLAGS': [ '-Wall', - '-Wendif-labels', - '-W', + '-Werror', + '-Wextra', '-Wno-unused-parameter', ], }, 'variables': { + 'chromium_code%': '<(chromium_code)', 'clang_warning_flags': [ # TODO(thakis): https://crbug.com/604888 '-Wno-undefined-var-template', @@ -469,6 +471,43 @@ 'defines': ['CR_CLANG_REVISION=<!(python <(DEPTH)/tools/clang/scripts/update.py --print-revision)'], }], ], + 'target_conditions': [ + ['chromium_code==0', { + 'variables': { + 'clang_warning_flags': [ + # Suppress unused variable warnings from third-party libraries. + '-Wno-unused-variable', + ], + }, + 'msvs_settings': { + 'VCCLCompilerTool': { + 'WarningLevel': '3', + }, + }, + 'conditions': [ + ['OS!="win"', { + # Remove -Wextra for third-party code. + 'cflags!': [ '-Wextra' ], + }], + ['OS!="win" and clang==0', { + 'cflags!': [ + '-Wall', + ], + }], + ['OS=="mac"', { + 'xcode_settings': { + 'WARNING_CFLAGS!': ['-Wextra'], + }, + }], + ], + }, { # chromium_code==1 + 'msvs_settings': { + 'VCCLCompilerTool': { + 'WarningLevel': '4', + }, + }, + }], + ], # target_conditions for 'target_defaults' }, 'conditions': [ ['OS=="linux" or OS=="mac"', { diff --git a/pdfium.gyp b/pdfium.gyp index 5532bc8360..310fec5bf4 100644 --- a/pdfium.gyp +++ b/pdfium.gyp @@ -4,8 +4,7 @@ { 'variables': { - # TODO(thakis): Enable this, pdfium:29 - #'chromium_code': 1, + 'chromium_code': 1, 'variables': { 'clang_use_pdfium_plugins%': 0, @@ -95,14 +94,6 @@ 'msvs_disabled_warnings': [ 4267, ], - 'variables': { - 'clang_warning_flags': [ - # TODO(thestig): Fix all instances, remove this, pdfium:29 - '-Wno-sign-compare', - ], - # Make sure Chromium's build/common.gypi doesn't re-add the flag on linux. - 'cflags_cc!': [ '-Wsign-compare' ], - }, }, 'targets': [ { diff --git a/third_party/third_party.gyp b/third_party/third_party.gyp index 2e03b59656..41db3b28db 100644 --- a/third_party/third_party.gyp +++ b/third_party/third_party.gyp @@ -85,6 +85,13 @@ 'freetype/src/base/fttype1.c', ], }], + ['os_posix==1 and clang==0', { + 'cflags': [ + # open_face_PS_from_sfnt_stream() and open_face_from_buffer() in + # ftbase.h are unused. GCC needs this flag too. + '-Wno-unused-function', + ], + }], ], 'variables': { 'clang_warning_flags': [ @@ -122,7 +129,7 @@ 'conditions': [ ['os_posix==1', { # library contains several enum vs non-enum conditionals. - 'cflags': [ '-Wno-extra', ], + 'cflags': [ '-Wno-extra' ], }], ], 'variables': { @@ -11,14 +11,6 @@ # TODO(thestig): Fix all instances, remove this, pdfium:29 4245, 4310, 4389, 4701, 4702, 4706, 4800, ], - 'variables': { - 'clang_warning_flags': [ - # TODO(thestig): Fix all instances, remove this, pdfium:29 - '-Wno-sign-compare', - ], - # Make sure Chromium's build/common.gypi doesn't re-add the flag on linux. - 'cflags_cc!': [ '-Wsign-compare' ], - }, }, "targets":[ { |