1 # Copyright 2014 PDFium Authors. All rights reserved. 2 # Use of this source code is governed by a BSD-style license that can be 3 # found in the LICENSE file. 4 5 # Definitions to be used when building stand-alone PDFium binaries. 6 7 { 8 'variables': { 9 'component%': 'static_library', 10 'clang%': 0, 11 'asan%': 0, 12 'sanitizer_coverage%': 0, 13 'use_goma%': 0, 14 'gomadir%': '', 15 'msvs_multi_core_compile%': '1', 16 'pdf_enable_xfa%': 1, 17 'variables': { 18 'variables': { 19 'variables': { 20 'conditions': [ 21 ['OS=="linux" or OS=="mac"', { 22 # This handles the Unix platforms we generally deal with. 23 # Anything else gets passed through, which probably won't work 24 # very well; such hosts should pass an explicit target_arch 25 # to gyp. 26 'host_arch%': 27 '<!(uname -m | sed -e "s/i.86/ia32/;\ 28 s/x86_64/x64/;\ 29 s/amd64/x64/;\ 30 s/arm.*/arm/;\ 31 s/aarch64/arm64/;\ 32 s/mips.*/mipsel/")', 33 }, { 34 # OS!="linux" and OS!="mac" 35 'host_arch%': 'ia32', 36 }], 37 ], 38 }, 39 'host_arch%': '<(host_arch)', 40 'target_arch%': '<(host_arch)', 41 }, 42 'host_arch%': '<(host_arch)', 43 'target_arch%': '<(target_arch)', 44 }, 45 'clang_dir%': 'third_party/llvm-build/Release+Asserts', 46 # These two are needed by V8. 47 'host_arch%': '<(host_arch)', 48 'target_arch%': '<(target_arch)', 49 'werror%': '-Werror', 50 'v8_optimized_debug%': 0, 51 'v8_use_external_startup_data%': 0, 52 'icu_gyp_path': '../v8/third_party/icu/icu.gyp', 53 'libjpeg_gyp_path': '../third_party/third_party.gyp', 54 'conditions': [ 55 ['OS == "win"', { 56 'os_posix%': 0, 57 }, { 58 'os_posix%': 1, 59 }], 60 ['OS=="linux" or OS=="mac"', { 61 'clang%': 1, 62 'host_clang%': 1, 63 }, { 64 'clang%': 0, 65 'host_clang%': 0, 66 }], 67 # Set default gomadir. 68 ['OS=="win"', { 69 'gomadir%': 'c:\\goma\\goma-win', 70 }, { 71 'gomadir%': '<!(/bin/echo -n ${HOME}/goma)', 72 }], 73 ], 74 }, 75 'target_defaults': { 76 'default_configuration': 'Debug', 77 'configurations': { 78 'Debug': { 79 'cflags': [ 80 '-g', 81 '-O0', 82 '-fdata-sections', 83 '-ffunction-sections', 84 ], 85 'msvs_settings': { 86 'VCCLCompilerTool': { 87 'Optimization': '0', 88 'conditions': [ 89 ['component=="shared_library"', { 90 'RuntimeLibrary': '3', # /MDd 91 }, { 92 'RuntimeLibrary': '1', # /MTd 93 }], 94 ], 95 }, 96 'VCLinkerTool': { 97 'LinkIncremental': '2', 98 }, 99 }, 100 'xcode_settings': { 101 'GCC_OPTIMIZATION_LEVEL': '0', # -O0 102 }, 103 'conditions': [ 104 ['OS=="linux"', { 105 # Enable libstdc++ debugging to help catch problems early. 106 'defines': ['_GLIBCXX_DEBUG=1',], 107 }], 108 ], 109 }, 110 'Release': { 111 'cflags': [ 112 '-fno-strict-aliasing', 113 ], 114 'xcode_settings': { 115 'GCC_OPTIMIZATION_LEVEL': '3', # -O3 116 'GCC_STRICT_ALIASING': 'NO', 117 }, 118 'msvs_settings': { 119 'VCCLCompilerTool': { 120 'Optimization': '2', 121 'InlineFunctionExpansion': '2', 122 'EnableIntrinsicFunctions': 'true', 123 'FavorSizeOrSpeed': '0', 124 'StringPooling': 'true', 125 'conditions': [ 126 ['component=="shared_library"', { 127 'RuntimeLibrary': '2', #/MD 128 }, { 129 'RuntimeLibrary': '0', #/MT 130 }], 131 ], 132 }, 133 'VCLinkerTool': { 134 'LinkIncremental': '1', 135 'OptimizeReferences': '2', 136 'EnableCOMDATFolding': '2', 137 }, 138 }, 139 'conditions': [ 140 ['OS=="linux"', { 141 'cflags': [ 142 '-fdata-sections', 143 '-ffunction-sections', 144 '-O3', 145 '-O2', 146 ], 147 }], 148 ['OS=="android"', { 149 'cflags!': [ 150 '-O3', 151 '-Os', 152 ], 153 'cflags': [ 154 '-fdata-sections', 155 '-ffunction-sections', 156 '-O2', 157 ], 158 }], 159 ], # conditions 160 }, 161 'Debug_x64': { 162 'inherit_from': ['Debug'], 163 'msvs_configuration_platform': 'x64', 164 }, 165 'Release_x64': { 166 'inherit_from': ['Release'], 167 'msvs_configuration_platform': 'x64', 168 }, 169 }, 170 'cflags': [ 171 '-Wall', 172 '-W', 173 '-Wno-missing-field-initializers', 174 # Code might someday be made clean for -Wsign-compare, but for now 175 # this produces too much noise to be useful. 176 '-Wno-sign-compare', 177 '-Wno-unused-parameter', 178 '-pthread', 179 '-fno-exceptions', 180 '-fvisibility=hidden', 181 ], 182 'cflags_cc': [ 183 '-std=gnu++0x', 184 '-Wnon-virtual-dtor', 185 '-fno-rtti', 186 ], 187 'ldflags': [ 188 '-pthread', 189 ], 190 'defines': [ 191 # Don't use deprecated V8 APIs anywhere. 192 'V8_DEPRECATION_WARNINGS', 193 ], 194 'msvs_cygwin_dirs': ['<(DEPTH)/v8/third_party/cygwin'], 195 'msvs_configuration_attributes': { 196 'OutputDirectory': '<(DEPTH)\\build\\$(ConfigurationName)', 197 'IntermediateDirectory': '$(OutDir)\\obj\\$(ProjectName)', 198 'CharacterSet': '1', 199 }, 200 'msvs_disabled_warnings': [ 201 # #### 202 # This section is PDFium specific. 203 # #### 204 205 # C4800: forcing value to bool 'true' or 'false' (performance warning) 206 4800, 207 208 # #### 209 # This section should match Chromium's build/common.gypi. 210 # #### 211 212 # C4091: 'typedef ': ignored on left of 'X' when no variable is 213 # declared. 214 # This happens in a number of Windows headers. Dumb. 215 4091, 216 217 # C4127: conditional expression is constant 218 # This warning can in theory catch dead code and other problems, but 219 # triggers in far too many desirable cases where the conditional 220 # expression is either set by macros or corresponds some legitimate 221 # compile-time constant expression (due to constant template args, 222 # conditionals comparing the sizes of different types, etc.). Some of 223 # these can be worked around, but it's not worth it. 224 4127, 225 226 # C4351: new behavior: elements of array 'array' will be default 227 # initialized 228 # This is a silly "warning" that basically just alerts you that the 229 # compiler is going to actually follow the language spec like it's 230 # supposed to, instead of not following it like old buggy versions 231 # did. There's absolutely no reason to turn this on. 232 4351, 233 234 # C4355: 'this': used in base member initializer list 235 # It's commonly useful to pass |this| to objects in a class' 236 # initializer list. While this warning can catch real bugs, most of 237 # the time the constructors in question don't attempt to call methods 238 # on the passed-in pointer (until later), and annotating every legit 239 # usage of this is simply more hassle than the warning is worth. 240 4355, 241 242 # C4503: 'identifier': decorated name length exceeded, name was 243 # truncated 244 # This only means that some long error messages might have truncated 245 # identifiers in the presence of lots of templates. It has no effect 246 # on program correctness and there's no real reason to waste time 247 # trying to prevent it. 248 4503, 249 250 # Warning C4589 says: "Constructor of abstract class ignores 251 # initializer for virtual base class." Disable this warning because it 252 # is flaky in VS 2015 RTM. It triggers on compiler generated 253 # copy-constructors in some cases. 254 4589, 255 256 # C4611: interaction between 'function' and C++ object destruction is 257 # non-portable 258 # This warning is unavoidable when using e.g. setjmp/longjmp. MSDN 259 # suggests using exceptions instead of setjmp/longjmp for C++, but 260 # Chromium code compiles without exception support. We therefore have 261 # to use setjmp/longjmp for e.g. JPEG decode error handling, which 262 # means we have to turn off this warning (and be careful about how 263 # object destruction happens in such cases). 264 4611, 265 266 # TODO(thestig): These warnings are level 4. They will be slowly 267 # removed as code is fixed. 268 4100, # Unreferenced formal parameter 269 4121, # Alignment of a member was sensitive to packing 270 4244, # Conversion from 'type1' to 'type2', possible loss of data 271 4505, # Unreferenced local function has been removed 272 4510, # Default constructor could not be generated 273 4512, # Assignment operator could not be generated 274 4610, # Object can never be instantiated 275 4838, # Narrowing conversion. Doesn't seem to be very useful. 276 4995, # 'X': name was marked as #pragma deprecated 277 4996, # 'X': was declared deprecated (for GetVersionEx). 278 279 # These are variable shadowing warnings that are new in VS2015. We 280 # should work through these at some point -- they may be removed from 281 # the RTM release in the /W4 set. 282 4456, 4457, 4458, 4459, 283 284 # TODO(brucedawson): http://crbug.com/554200 4312 is a VS 285 # 2015 64-bit warning for integer to larger pointer 286 4312, 287 288 # #### 289 # Do not add PDFium specific entries here. Add them to the top. 290 # #### 291 ], 292 'msvs_settings': { 293 'VCCLCompilerTool': { 294 'MinimalRebuild': 'false', 295 'BufferSecurityCheck': 'true', 296 'EnableFunctionLevelLinking': 'true', 297 'RuntimeTypeInfo': 'false', 298 'WarningLevel': '3', 299 'DebugInformationFormat': '3', 300 'Detect64BitPortabilityProblems': 'false', 301 'conditions': [ 302 [ 'msvs_multi_core_compile', { 303 'AdditionalOptions': ['/MP'], 304 }], 305 ['component=="shared_library"', { 306 'ExceptionHandling': '1', # /EHsc 307 }, { 308 'ExceptionHandling': '0', 309 }], 310 ['target_arch=="x64"', { 311 # 64-bit warnings need to be resolved. 312 # https://code.google.com/p/pdfium/issues/detail?id=101 313 'WarnAsError': 'false', 314 }, { 315 'WarnAsError': 'true', 316 }], 317 ], 318 }, 319 'VCLibrarianTool': { 320 'AdditionalOptions': ['/ignore:4221'], 321 }, 322 'VCLinkerTool': { 323 'GenerateDebugInformation': 'true', 324 'LinkIncremental': '1', 325 # SubSystem values: 326 # 0 == not set 327 # 1 == /SUBSYSTEM:CONSOLE 328 # 2 == /SUBSYSTEM:WINDOWS 329 'SubSystem': '1', 330 }, 331 }, 332 'xcode_settings': { 333 'ALWAYS_SEARCH_USER_PATHS': 'NO', 334 'CLANG_CXX_LANGUAGE_STANDARD': 'gnu++11', 335 'GCC_CW_ASM_SYNTAX': 'NO', # No -fasm-blocks 336 'GCC_DYNAMIC_NO_PIC': 'NO', # No -mdynamic-no-pic 337 # (Equivalent to -fPIC) 338 'GCC_ENABLE_CPP_EXCEPTIONS': 'NO', # -fno-exceptions 339 'GCC_ENABLE_CPP_RTTI': 'NO', # -fno-rtti 340 'GCC_ENABLE_PASCAL_STRINGS': 'NO', # No -mpascal-strings 341 # GCC_INLINES_ARE_PRIVATE_EXTERN maps to -fvisibility-inlines-hidden 342 'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES', 343 'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden 344 'GCC_TREAT_WARNINGS_AS_ERRORS': 'NO', # -Werror 345 'GCC_WARN_NON_VIRTUAL_DESTRUCTOR': 'YES', # -Wnon-virtual-dtor 346 'SYMROOT': '<(DEPTH)/xcodebuild', 347 'USE_HEADERMAP': 'NO', 348 'OTHER_CFLAGS': [ 349 '-fno-strict-aliasing', 350 ], 351 'WARNING_CFLAGS': [ 352 '-Wall', 353 '-Wendif-labels', 354 '-W', 355 '-Wno-unused-parameter', 356 ], 357 }, 358 'variables': { 359 'clang_warning_flags': [], 360 }, 361 'includes': [ 'set_clang_warning_flags.gypi', ], 362 'conditions': [ 363 ['component=="shared_library"', { 364 'cflags': [ 365 '-fPIC', 366 ], 367 }], 368 ['asan==1', { 369 'defines': [ 370 'ADDRESS_SANITIZER', 371 'LEAK_SANITIZER', 372 ], 373 'cflags': [ 374 '-fsanitize=address', 375 '-gline-tables-only', 376 ], 377 'ldflags': [ 378 '-fsanitize=address', 379 ], 380 }], 381 ['sanitizer_coverage!=0', { 382 'cflags': [ 383 '-fsanitize-coverage=<(sanitizer_coverage)', 384 ], 385 }], 386 ['OS=="win"', { 387 'defines': [ 388 'NOMINMAX', 389 '_CRT_SECURE_NO_DEPRECATE', 390 '_CRT_NONSTDC_NO_DEPRECATE', 391 ], 392 'conditions': [ 393 ['component=="static_library"', { 394 'defines': [ 395 '_HAS_EXCEPTIONS=0', 396 ], 397 }], 398 ['use_goma==1', { 399 # goma doesn't support PDB yet. 400 'msvs_settings': { 401 'VCLinkerTool': { 402 'GenerateDebugInformation': 'true', 403 }, 404 'VCCLCompilerTool': { 405 'DebugInformationFormat': '1', 406 }, 407 }, 408 }], 409 ], 410 }], # OS=="win" 411 ['OS=="mac"', { 412 'target_conditions': [ 413 ['_type!="static_library"', { 414 'xcode_settings': {'OTHER_LDFLAGS': ['-Wl,-search_paths_first']}, 415 }], 416 ], # target_conditions 417 }], # OS=="mac" 418 ['v8_use_external_startup_data==1', { 419 'defines': [ 420 'V8_USE_EXTERNAL_STARTUP_DATA', 421 ], 422 }], # v8_use_external_startup_data==1 423 ['clang==1 or host_clang==1', { 424 # This is here so that all files get recompiled after a clang roll and 425 # when turning clang on or off. 426 # (defines are passed via the command line, and build systems rebuild 427 # things when their commandline changes). Nothing should ever read this 428 # define. 429 'defines': ['CR_CLANG_REVISION=<!(python <(DEPTH)/tools/clang/scripts/update.py --print-revision)'], 430 }], 431 ], 432 }, 433 'xcode_settings': { 434 # See comment in Chromium's common.gypi for why this is needed. 435 'SYMROOT': '<(DEPTH)/xcodebuild', 436 }, 437 'conditions': [ 438 ['OS=="linux" or OS=="mac"', { 439 'conditions': [ 440 ['clang==1', { 441 'make_global_settings': [ 442 ['CC', '<(clang_dir)/bin/clang'], 443 ['CXX', '<(clang_dir)/bin/clang++'], 444 ], 445 }], 446 ], 447 }], # OS=="linux" or OS=="mac" 448 ["use_goma==1", { 449 'make_global_settings': [ 450 ['CC_wrapper', '<(gomadir)/gomacc'], 451 ['CXX_wrapper', '<(gomadir)/gomacc'], 452 ], 453 }], # use_goma==1 454 ], 455 } 456