Home | History | Annotate | Download | only in third_party
      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 import("//build/config/arm.gni")
      6 import("//build_overrides/build.gni")
      7 import("../pdfium.gni")
      8 
      9 group("third_party") {
     10   deps = [
     11     ":bigint",
     12     ":fx_freetype",
     13     ":pdfium_base",
     14   ]
     15 }
     16 
     17 config("pdfium_third_party_config") {
     18   configs = [ "..:pdfium_common_config" ]
     19 }
     20 
     21 static_library("bigint") {
     22   configs -= [ "//build/config/compiler:chromium_code" ]
     23   configs += [
     24     "//build/config/compiler:no_chromium_code",
     25     ":pdfium_third_party_config",
     26   ]
     27   sources = [
     28     "bigint/BigInteger.cc",
     29     "bigint/BigInteger.hh",
     30     "bigint/BigIntegerLibrary.hh",
     31     "bigint/BigIntegerUtils.cc",
     32     "bigint/BigIntegerUtils.hh",
     33     "bigint/BigUnsigned.cc",
     34     "bigint/BigUnsigned.hh",
     35     "bigint/BigUnsignedInABase.cc",
     36     "bigint/BigUnsignedInABase.hh",
     37     "bigint/NumberlikeArray.hh",
     38   ]
     39 }
     40 
     41 config("fx_freetype_warnings") {
     42   visibility = [ ":*" ]
     43   if (is_clang) {
     44     # open_face_PS_from_sfnt_stream() and open_face_from_buffer() in
     45     # ftbase.h are unused.
     46     cflags = [ "-Wno-unused-function" ]
     47   }
     48 }
     49 
     50 # Tests may link against this even if the production library doesn't,
     51 # so it needs to be separate from it.
     52 static_library("fx_freetype") {
     53   configs -= [ "//build/config/compiler:chromium_code" ]
     54   configs += [
     55     "//build/config/compiler:no_chromium_code",
     56     ":pdfium_third_party_config",
     57 
     58     # Must be after no_chromium_code for warning flags to be ordered correctly.
     59     ":fx_freetype_warnings",
     60   ]
     61   defines = [ "FT2_BUILD_LIBRARY" ]
     62   sources = [
     63     "freetype/include/freetype/freetype.h",
     64     "freetype/include/freetype/ftmm.h",
     65     "freetype/include/freetype/ftotval.h",
     66     "freetype/include/freetype/ftoutln.h",
     67     "freetype/include/freetype/internal/ftobjs.h",
     68     "freetype/include/freetype/internal/ftstream.h",
     69     "freetype/include/freetype/internal/tttypes.h",
     70     "freetype/include/freetype/tttables.h",
     71     "freetype/include/ft2build.h",
     72     "freetype/src/base/ftbase.c",
     73     "freetype/src/base/ftbase.h",
     74     "freetype/src/base/ftbitmap.c",
     75     "freetype/src/base/ftglyph.c",
     76     "freetype/src/base/ftinit.c",
     77     "freetype/src/base/ftlcdfil.c",
     78     "freetype/src/base/ftmm.c",
     79     "freetype/src/base/ftsystem.c",
     80     "freetype/src/cff/cff.c",
     81     "freetype/src/cff/cffobjs.h",
     82     "freetype/src/cff/cfftypes.h",
     83     "freetype/src/cid/type1cid.c",
     84     "freetype/src/psaux/psaux.c",
     85     "freetype/src/pshinter/pshinter.c",
     86     "freetype/src/psnames/psmodule.c",
     87     "freetype/src/raster/raster.c",
     88     "freetype/src/sfnt/sfnt.c",
     89     "freetype/src/smooth/smooth.c",
     90     "freetype/src/truetype/truetype.c",
     91     "freetype/src/type1/type1.c",
     92   ]
     93   if (pdf_use_skia || pdf_use_skia_paths) {
     94     sources += [
     95       "freetype/src/base/ftfntfmt.c",
     96       "freetype/src/base/ftfstype.c",
     97       "freetype/src/base/fttype1.c",
     98     ]
     99   }
    100 }
    101 
    102 if (!pdf_use_skia && !pdf_use_skia_paths) {
    103   config("fx_agg_warnings") {
    104     visibility = [ ":*" ]
    105     if (is_clang) {
    106       # calc_butt_cap() in agg_vcgen_stroke.cpp is unused.
    107       cflags = [ "-Wno-unused-function" ]
    108     }
    109   }
    110 
    111   static_library("fx_agg") {
    112     configs -= [ "//build/config/compiler:chromium_code" ]
    113     configs += [
    114       "//build/config/compiler:no_chromium_code",
    115       ":pdfium_third_party_config",
    116 
    117       # Must be after no_chromium_code for warning flags to be ordered correctly.
    118       ":fx_agg_warnings",
    119     ]
    120     sources = [
    121       "agg23/agg_basics.h",
    122       "agg23/agg_clip_liang_barsky.h",
    123       "agg23/agg_conv_dash.h",
    124       "agg23/agg_conv_stroke.h",
    125       "agg23/agg_curves.cpp",
    126       "agg23/agg_curves.h",
    127       "agg23/agg_path_storage.cpp",
    128       "agg23/agg_path_storage.h",
    129       "agg23/agg_rasterizer_scanline_aa.cpp",
    130       "agg23/agg_rasterizer_scanline_aa.h",
    131       "agg23/agg_renderer_scanline.h",
    132       "agg23/agg_rendering_buffer.h",
    133       "agg23/agg_scanline_u.h",
    134       "agg23/agg_vcgen_dash.cpp",
    135       "agg23/agg_vcgen_stroke.cpp",
    136     ]
    137     deps = [
    138       "..:fxcrt",
    139     ]
    140   }
    141 }
    142 
    143 config("fx_lcms2_warnings") {
    144   visibility = [ ":*" ]
    145   if (is_clang) {
    146     cflags = [
    147       # cmslut.cc is sloppy with aggregate initialization. Version 2.7 of this
    148       # library doesn't appear to have this problem.
    149       "-Wno-missing-braces",
    150 
    151       # FindPrev() in cmsplugin.c is unused.
    152       "-Wno-unused-function",
    153     ]
    154   }
    155 }
    156 
    157 static_library("fx_lcms2") {
    158   configs -= [ "//build/config/compiler:chromium_code" ]
    159   configs += [
    160     "//build/config/compiler:no_chromium_code",
    161     ":pdfium_third_party_config",
    162 
    163     # Must be after no_chromium_code for warning flags to be ordered correctly.
    164     ":fx_lcms2_warnings",
    165   ]
    166   sources = [
    167     "lcms2-2.6/include/lcms2.h",
    168     "lcms2-2.6/include/lcms2_plugin.h",
    169     "lcms2-2.6/src/cmscam02.c",
    170     "lcms2-2.6/src/cmscgats.c",
    171     "lcms2-2.6/src/cmscnvrt.c",
    172     "lcms2-2.6/src/cmserr.c",
    173     "lcms2-2.6/src/cmsgamma.c",
    174     "lcms2-2.6/src/cmsgmt.c",
    175     "lcms2-2.6/src/cmshalf.c",
    176     "lcms2-2.6/src/cmsintrp.c",
    177     "lcms2-2.6/src/cmsio0.c",
    178     "lcms2-2.6/src/cmsio1.c",
    179     "lcms2-2.6/src/cmslut.c",
    180     "lcms2-2.6/src/cmsmd5.c",
    181     "lcms2-2.6/src/cmsmtrx.c",
    182     "lcms2-2.6/src/cmsnamed.c",
    183     "lcms2-2.6/src/cmsopt.c",
    184     "lcms2-2.6/src/cmspack.c",
    185     "lcms2-2.6/src/cmspcs.c",
    186     "lcms2-2.6/src/cmsplugin.c",
    187     "lcms2-2.6/src/cmsps2.c",
    188     "lcms2-2.6/src/cmssamp.c",
    189     "lcms2-2.6/src/cmssm.c",
    190     "lcms2-2.6/src/cmstypes.c",
    191     "lcms2-2.6/src/cmsvirt.c",
    192     "lcms2-2.6/src/cmswtpnt.c",
    193     "lcms2-2.6/src/cmsxform.c",
    194   ]
    195 }
    196 
    197 # This is only used for standalone builds.
    198 config("jpeg_warnings") {
    199   visibility = [ ":*" ]
    200   if (is_clang) {
    201     cflags = [ "-Wno-shift-negative-value" ]
    202   }
    203 }
    204 
    205 static_library("jpeg") {
    206   configs -= [ "//build/config/compiler:chromium_code" ]
    207   configs += [
    208     "//build/config/compiler:no_chromium_code",
    209     ":pdfium_third_party_config",
    210 
    211     # Must be after no_chromium_code for warning flags to be ordered correctly.
    212     ":jpeg_warnings",
    213   ]
    214   sources = [
    215     "libjpeg/cderror.h",
    216     "libjpeg/cdjpeg.h",
    217     "libjpeg/fpdfapi_jcapimin.c",
    218     "libjpeg/fpdfapi_jcapistd.c",
    219     "libjpeg/fpdfapi_jccoefct.c",
    220     "libjpeg/fpdfapi_jccolor.c",
    221     "libjpeg/fpdfapi_jcdctmgr.c",
    222     "libjpeg/fpdfapi_jchuff.c",
    223     "libjpeg/fpdfapi_jcinit.c",
    224     "libjpeg/fpdfapi_jcmainct.c",
    225     "libjpeg/fpdfapi_jcmarker.c",
    226     "libjpeg/fpdfapi_jcmaster.c",
    227     "libjpeg/fpdfapi_jcomapi.c",
    228     "libjpeg/fpdfapi_jcparam.c",
    229     "libjpeg/fpdfapi_jcphuff.c",
    230     "libjpeg/fpdfapi_jcprepct.c",
    231     "libjpeg/fpdfapi_jcsample.c",
    232     "libjpeg/fpdfapi_jctrans.c",
    233     "libjpeg/fpdfapi_jdapimin.c",
    234     "libjpeg/fpdfapi_jdapistd.c",
    235     "libjpeg/fpdfapi_jdcoefct.c",
    236     "libjpeg/fpdfapi_jdcolor.c",
    237     "libjpeg/fpdfapi_jddctmgr.c",
    238     "libjpeg/fpdfapi_jdhuff.c",
    239     "libjpeg/fpdfapi_jdinput.c",
    240     "libjpeg/fpdfapi_jdmainct.c",
    241     "libjpeg/fpdfapi_jdmarker.c",
    242     "libjpeg/fpdfapi_jdmaster.c",
    243     "libjpeg/fpdfapi_jdmerge.c",
    244     "libjpeg/fpdfapi_jdphuff.c",
    245     "libjpeg/fpdfapi_jdpostct.c",
    246     "libjpeg/fpdfapi_jdsample.c",
    247     "libjpeg/fpdfapi_jdtrans.c",
    248     "libjpeg/fpdfapi_jerror.c",
    249     "libjpeg/fpdfapi_jfdctfst.c",
    250     "libjpeg/fpdfapi_jfdctint.c",
    251     "libjpeg/fpdfapi_jidctfst.c",
    252     "libjpeg/fpdfapi_jidctint.c",
    253     "libjpeg/fpdfapi_jidctred.c",
    254     "libjpeg/fpdfapi_jmemmgr.c",
    255     "libjpeg/fpdfapi_jmemnobs.c",
    256     "libjpeg/fpdfapi_jutils.c",
    257     "libjpeg/jchuff.h",
    258     "libjpeg/jconfig.h",
    259     "libjpeg/jdct.h",
    260     "libjpeg/jdhuff.h",
    261     "libjpeg/jerror.h",
    262     "libjpeg/jinclude.h",
    263     "libjpeg/jmemsys.h",
    264     "libjpeg/jmorecfg.h",
    265     "libjpeg/jpegint.h",
    266     "libjpeg/jpeglib.h",
    267     "libjpeg/jversion.h",
    268     "libjpeg/makefile",
    269     "libjpeg/transupp.h",
    270   ]
    271   deps = [
    272     "..:fxcrt",
    273   ]
    274 }
    275 
    276 config("fx_libopenjpeg_warnings") {
    277   visibility = [ ":*" ]
    278   if (is_win) {
    279     cflags = [
    280       # Signed/unsigned comparisons.
    281       "/wd4018",
    282     ]
    283   }
    284 }
    285 
    286 static_library("fx_libopenjpeg") {
    287   configs -= [ "//build/config/compiler:chromium_code" ]
    288   configs += [
    289     "//build/config/compiler:no_chromium_code",
    290     ":pdfium_third_party_config",
    291 
    292     # Must be after no_chromium_code for warning flags to be ordered correctly.
    293     ":fx_libopenjpeg_warnings",
    294   ]
    295   sources = [
    296     "libopenjpeg20/bio.c",
    297     "libopenjpeg20/cio.c",
    298     "libopenjpeg20/dwt.c",
    299     "libopenjpeg20/event.c",
    300     "libopenjpeg20/function_list.c",
    301     "libopenjpeg20/image.c",
    302     "libopenjpeg20/invert.c",
    303     "libopenjpeg20/j2k.c",
    304     "libopenjpeg20/jp2.c",
    305     "libopenjpeg20/mct.c",
    306     "libopenjpeg20/mqc.c",
    307     "libopenjpeg20/openjpeg.c",
    308     "libopenjpeg20/opj_clock.c",
    309     "libopenjpeg20/pi.c",
    310     "libopenjpeg20/raw.c",
    311     "libopenjpeg20/t1.c",
    312     "libopenjpeg20/t2.c",
    313     "libopenjpeg20/tcd.c",
    314     "libopenjpeg20/tgt.c",
    315   ]
    316 }
    317 
    318 static_library("fx_lpng") {
    319   configs -= [ "//build/config/compiler:chromium_code" ]
    320   configs += [
    321     "//build/config/compiler:no_chromium_code",
    322     ":pdfium_third_party_config",
    323   ]
    324   sources = [
    325     "libpng16/png.c",
    326     "libpng16/png.h",
    327     "libpng16/pngconf.h",
    328     "libpng16/pngdebug.h",
    329     "libpng16/pngerror.c",
    330     "libpng16/pngget.c",
    331     "libpng16/pnginfo.h",
    332     "libpng16/pnglibconf.h",
    333     "libpng16/pngmem.c",
    334     "libpng16/pngpread.c",
    335     "libpng16/pngprefix.h",
    336     "libpng16/pngpriv.h",
    337     "libpng16/pngread.c",
    338     "libpng16/pngrio.c",
    339     "libpng16/pngrtran.c",
    340     "libpng16/pngrutil.c",
    341     "libpng16/pngset.c",
    342     "libpng16/pngstruct.h",
    343     "libpng16/pngtrans.c",
    344     "libpng16/pngwio.c",
    345     "libpng16/pngwrite.c",
    346     "libpng16/pngwtran.c",
    347     "libpng16/pngwutil.c",
    348   ]
    349 
    350   defines = []
    351   cflags = []
    352 
    353   if (current_cpu == "x86" || current_cpu == "x64") {
    354     sources += [
    355       "libpng16/contrib/intel/filter_sse2_intrinsics.c",
    356       "libpng16/contrib/intel/intel_init.c",
    357     ]
    358     defines += [ "PNG_INTEL_SSE_OPT=1" ]
    359   } else if ((current_cpu == "arm" || current_cpu == "arm64") && arm_use_neon) {
    360     sources += [
    361       "libpng16/arm/arm_init.c",
    362       "libpng16/arm/filter_neon_intrinsics.c",
    363     ]
    364     defines += [
    365       "PNG_ARM_NEON_OPT=2",
    366       "PNG_ARM_NEON_IMPLEMENTATION=1",
    367     ]
    368   }
    369 
    370   if (is_win) {
    371     # Unary minus applied to unsigned type.
    372     cflags += [ "/wd4146" ]
    373   }
    374 }
    375 
    376 if (pdf_enable_xfa) {
    377   static_library("fx_tiff") {
    378     configs -= [ "//build/config/compiler:chromium_code" ]
    379     configs += [
    380       "//build/config/compiler:no_chromium_code",
    381       ":pdfium_third_party_config",
    382     ]
    383     if (is_win) {
    384       # Need to undefine the macro since it is redefined in
    385       # tif_ojpeg.c and tif_jpeg.c.
    386       configs -= [ "//build/config/win:lean_and_mean" ]
    387     }
    388     deps = [
    389       "//third_party:jpeg",
    390     ]
    391     sources = [
    392       "libtiff/tif_aux.c",
    393       "libtiff/tif_close.c",
    394       "libtiff/tif_codec.c",
    395       "libtiff/tif_color.c",
    396       "libtiff/tif_compress.c",
    397       "libtiff/tif_dir.c",
    398       "libtiff/tif_dirinfo.c",
    399       "libtiff/tif_dirread.c",
    400       "libtiff/tif_dirwrite.c",
    401       "libtiff/tif_dumpmode.c",
    402       "libtiff/tif_error.c",
    403       "libtiff/tif_extension.c",
    404       "libtiff/tif_fax3.c",
    405       "libtiff/tif_fax3sm.c",
    406       "libtiff/tif_flush.c",
    407       "libtiff/tif_getimage.c",
    408       "libtiff/tif_jpeg.c",
    409       "libtiff/tif_luv.c",
    410       "libtiff/tif_lzw.c",
    411       "libtiff/tif_next.c",
    412       "libtiff/tif_ojpeg.c",
    413       "libtiff/tif_open.c",
    414       "libtiff/tif_packbits.c",
    415       "libtiff/tif_pixarlog.c",
    416       "libtiff/tif_predict.c",
    417       "libtiff/tif_print.c",
    418       "libtiff/tif_read.c",
    419       "libtiff/tif_strip.c",
    420       "libtiff/tif_swab.c",
    421       "libtiff/tif_thunder.c",
    422       "libtiff/tif_tile.c",
    423       "libtiff/tif_version.c",
    424       "libtiff/tif_warning.c",
    425       "libtiff/tif_write.c",
    426       "libtiff/tif_zip.c",
    427       "libtiff/tiffiop.h",
    428       "libtiff/tiffvers.h",
    429     ]
    430   }
    431 }
    432 
    433 # TODO(dsinclair): Remove if fixed upstream. https://crbug.com/507712
    434 config("fx_zlib_warnings") {
    435   visibility = [ ":*" ]
    436   if (is_clang) {
    437     cflags = [ "-Wno-shift-negative-value" ]
    438   }
    439 }
    440 
    441 static_library("fx_zlib") {
    442   configs -= [ "//build/config/compiler:chromium_code" ]
    443   configs += [
    444     "//build/config/compiler:no_chromium_code",
    445     ":pdfium_third_party_config",
    446 
    447     # Must be after no_chromium_code for warning flags to be ordered correctly.
    448     ":fx_zlib_warnings",
    449   ]
    450   sources = [
    451     "zlib_v128/adler32.c",
    452     "zlib_v128/compress.c",
    453     "zlib_v128/crc32.c",
    454     "zlib_v128/deflate.c",
    455     "zlib_v128/gzclose.c",
    456     "zlib_v128/gzlib.c",
    457     "zlib_v128/gzread.c",
    458     "zlib_v128/gzwrite.c",
    459     "zlib_v128/infback.c",
    460     "zlib_v128/inffast.c",
    461     "zlib_v128/inflate.c",
    462     "zlib_v128/inftrees.c",
    463     "zlib_v128/trees.c",
    464     "zlib_v128/uncompr.c",
    465     "zlib_v128/zutil.c",
    466   ]
    467 }
    468 
    469 # Can not be a static library due to lack of .cc files.
    470 source_set("pdfium_base") {
    471   configs -= [ "//build/config/compiler:chromium_code" ]
    472   configs += [
    473     "//build/config/compiler:no_chromium_code",
    474     ":pdfium_third_party_config",
    475   ]
    476   sources = [
    477     "base/logging.h",
    478     "base/macros.h",
    479     "base/numerics/safe_conversions.h",
    480     "base/numerics/safe_conversions_impl.h",
    481     "base/numerics/safe_math.h",
    482     "base/numerics/safe_math_impl.h",
    483     "base/ptr_util.h",
    484     "base/stl_util.h",
    485   ]
    486 }
    487