# Copyright 2014 PDFium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

group("third_party") {
  deps = [
    ":bigint",
    ":fx_freetype",
    ":pdfium_base",
  ]
}

static_library("bigint") {
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [
    "//build/config/compiler:no_chromium_code",
    "//third_party/pdfium:pdfium_config",
  ]
  sources = [
    "bigint/BigInteger.hh",
    "bigint/BigIntegerLibrary.hh",
    "bigint/BigIntegerUtils.hh",
    "bigint/BigUnsigned.hh",
    "bigint/NumberlikeArray.hh",
    "bigint/BigUnsignedInABase.hh",
    "bigint/BigInteger.cc",
    "bigint/BigIntegerUtils.cc",
    "bigint/BigUnsigned.cc",
    "bigint/BigUnsignedInABase.cc",
  ]
}

source_set("fx_freetype") {
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [
    "//build/config/compiler:no_chromium_code",
    "//third_party/pdfium:pdfium_config",
  ]
  defines = [ "FT2_BUILD_LIBRARY" ]
  sources = [
    "freetype/include/freetype.h",
    "freetype/include/ft2build.h",
    "freetype/include/ftmm.h",
    "freetype/include/ftotval.h",
    "freetype/include/ftoutln.h",
    "freetype/include/tttables.h",
    "freetype/include/internal/ftobjs.h",
    "freetype/include/internal/ftstream.h",
    "freetype/include/internal/tttypes.h",
    "freetype/src/cff/cffobjs.h",
    "freetype/src/cff/cfftypes.h",
    "freetype/src/cff/cff.c",
    "freetype/src/base/ftbase.c",
    "freetype/src/base/ftbitmap.c",
    "freetype/src/base/ftglyph.c",
    "freetype/src/base/ftinit.c",
    "freetype/src/base/ftlcdfil.c",
    "freetype/src/base/ftmm.c",
    "freetype/src/base/ftsystem.c",
    "freetype/src/psaux/psaux.c",
    "freetype/src/pshinter/pshinter.c",
    "freetype/src/psnames/psmodule.c",
    "freetype/src/raster/raster.c",
    "freetype/src/sfnt/sfnt.c",
    "freetype/src/smooth/smooth.c",
    "freetype/src/truetype/truetype.c",
    "freetype/src/type1/type1.c",
    "freetype/src/cid/type1cid.c",
  ]
}

source_set("fx_agg") {
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [
    "//build/config/compiler:no_chromium_code",
    "//third_party/pdfium:pdfium_config",
  ]
  sources = [
    "agg23/agg_basics.h",
    "agg23/agg_clip_liang_barsky.h",
    "agg23/agg_conv_dash.h",
    "agg23/agg_conv_stroke.h",
    "agg23/agg_curves.cpp",
    "agg23/agg_curves.h",
    "agg23/agg_path_storage.cpp",
    "agg23/agg_path_storage.h",
    "agg23/agg_rasterizer_scanline_aa.cpp",
    "agg23/agg_rasterizer_scanline_aa.h",
    "agg23/agg_renderer_scanline.h",
    "agg23/agg_rendering_buffer.h",
    "agg23/agg_scanline_u.h",
    "agg23/agg_vcgen_dash.cpp",
    "agg23/agg_vcgen_stroke.cpp",
  ]
}

config("fx_lcms2_warnings") {
  if (is_clang) {
    # cmslut.cc is sloppy with aggregate initialization. Version 2.7 of this
    # library doesn't appear to have this problem.
    cflags = [ "-Wno-missing-braces" ]
  }
}

source_set("fx_lcms2") {
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [
    "//build/config/compiler:no_chromium_code",
    "//third_party/pdfium:pdfium_config",
    ":fx_lcms2_warnings",
  ]
  sources = [
    "lcms2-2.6/include/lcms2.h",
    "lcms2-2.6/include/lcms2_plugin.h",
    "lcms2-2.6/src/cmscam02.c",
    "lcms2-2.6/src/cmscgats.c",
    "lcms2-2.6/src/cmscnvrt.c",
    "lcms2-2.6/src/cmserr.c",
    "lcms2-2.6/src/cmsgamma.c",
    "lcms2-2.6/src/cmsgmt.c",
    "lcms2-2.6/src/cmshalf.c",
    "lcms2-2.6/src/cmsintrp.c",
    "lcms2-2.6/src/cmsio0.c",
    "lcms2-2.6/src/cmsio1.c",
    "lcms2-2.6/src/cmslut.c",
    "lcms2-2.6/src/cmsmd5.c",
    "lcms2-2.6/src/cmsmtrx.c",
    "lcms2-2.6/src/cmsnamed.c",
    "lcms2-2.6/src/cmsopt.c",
    "lcms2-2.6/src/cmspack.c",
    "lcms2-2.6/src/cmspcs.c",
    "lcms2-2.6/src/cmsplugin.c",
    "lcms2-2.6/src/cmsps2.c",
    "lcms2-2.6/src/cmssamp.c",
    "lcms2-2.6/src/cmssm.c",
    "lcms2-2.6/src/cmstypes.c",
    "lcms2-2.6/src/cmsvirt.c",
    "lcms2-2.6/src/cmswtpnt.c",
    "lcms2-2.6/src/cmsxform.c",
  ]
}

source_set("fx_libjpeg") {
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [
    "//build/config/compiler:no_chromium_code",
    "//third_party/pdfium:pdfium_config",
  ]
  sources = [
    "libjpeg/cderror.h",
    "libjpeg/cdjpeg.h",
    "libjpeg/fpdfapi_jcapimin.c",
    "libjpeg/fpdfapi_jcapistd.c",
    "libjpeg/fpdfapi_jccoefct.c",
    "libjpeg/fpdfapi_jccolor.c",
    "libjpeg/fpdfapi_jcdctmgr.c",
    "libjpeg/fpdfapi_jchuff.c",
    "libjpeg/fpdfapi_jcinit.c",
    "libjpeg/fpdfapi_jcmainct.c",
    "libjpeg/fpdfapi_jcmarker.c",
    "libjpeg/fpdfapi_jcmaster.c",
    "libjpeg/fpdfapi_jcomapi.c",
    "libjpeg/fpdfapi_jcparam.c",
    "libjpeg/fpdfapi_jcphuff.c",
    "libjpeg/fpdfapi_jcprepct.c",
    "libjpeg/fpdfapi_jcsample.c",
    "libjpeg/fpdfapi_jctrans.c",
    "libjpeg/fpdfapi_jdapimin.c",
    "libjpeg/fpdfapi_jdapistd.c",
    "libjpeg/fpdfapi_jdcoefct.c",
    "libjpeg/fpdfapi_jdcolor.c",
    "libjpeg/fpdfapi_jddctmgr.c",
    "libjpeg/fpdfapi_jdhuff.c",
    "libjpeg/fpdfapi_jdinput.c",
    "libjpeg/fpdfapi_jdmainct.c",
    "libjpeg/fpdfapi_jdmarker.c",
    "libjpeg/fpdfapi_jdmaster.c",
    "libjpeg/fpdfapi_jdmerge.c",
    "libjpeg/fpdfapi_jdphuff.c",
    "libjpeg/fpdfapi_jdpostct.c",
    "libjpeg/fpdfapi_jdsample.c",
    "libjpeg/fpdfapi_jdtrans.c",
    "libjpeg/fpdfapi_jerror.c",
    "libjpeg/fpdfapi_jfdctfst.c",
    "libjpeg/fpdfapi_jfdctint.c",
    "libjpeg/fpdfapi_jidctfst.c",
    "libjpeg/fpdfapi_jidctint.c",
    "libjpeg/fpdfapi_jidctred.c",
    "libjpeg/fpdfapi_jmemmgr.c",
    "libjpeg/fpdfapi_jmemnobs.c",
    "libjpeg/fpdfapi_jutils.c",
    "libjpeg/jchuff.h",
    "libjpeg/jconfig.h",
    "libjpeg/jdct.h",
    "libjpeg/jdhuff.h",
    "libjpeg/jerror.h",
    "libjpeg/jinclude.h",
    "libjpeg/jmemsys.h",
    "libjpeg/jmorecfg.h",
    "libjpeg/jpegint.h",
    "libjpeg/jpeglib.h",
    "libjpeg/jversion.h",
    "libjpeg/makefile",
    "libjpeg/transupp.h",
  ]
}

source_set("fx_libopenjpeg") {
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [
    "//build/config/compiler:no_chromium_code",
    "//third_party/pdfium:pdfium_config",
  ]
  sources = [
    "libopenjpeg20/bio.c",
    "libopenjpeg20/cio.c",
    "libopenjpeg20/dwt.c",
    "libopenjpeg20/event.c",
    "libopenjpeg20/function_list.c",
    "libopenjpeg20/image.c",
    "libopenjpeg20/invert.c",
    "libopenjpeg20/j2k.c",
    "libopenjpeg20/jp2.c",
    "libopenjpeg20/mct.c",
    "libopenjpeg20/mqc.c",
    "libopenjpeg20/openjpeg.c",
    "libopenjpeg20/opj_clock.c",
    "libopenjpeg20/pi.c",
    "libopenjpeg20/raw.c",
    "libopenjpeg20/t1.c",
    "libopenjpeg20/t2.c",
    "libopenjpeg20/tcd.c",
    "libopenjpeg20/tgt.c",
  ]
}

source_set("fx_lpng") {
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [
    "//build/config/compiler:no_chromium_code",
    "//third_party/pdfium:pdfium_config",
  ]
  sources = [
    "lpng_v163/png.h",
    "lpng_v163/png.c",
    "lpng_v163/pngerror.c",
    "lpng_v163/pngget.c",
    "lpng_v163/pngmem.c",
    "lpng_v163/pngpread.c",
    "lpng_v163/pngread.c",
    "lpng_v163/pngrio.c",
    "lpng_v163/pngrtran.c",
    "lpng_v163/pngrutil.c",
    "lpng_v163/pngset.c",
    "lpng_v163/pngtrans.c",
    "lpng_v163/pngwio.c",
    "lpng_v163/pngwrite.c",
    "lpng_v163/pngwtran.c",
    "lpng_v163/pngwutil.c",
  ]
}

source_set("fx_tiff") {
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [
    "//build/config/compiler:no_chromium_code",
    "//third_party/pdfium:pdfium_config",
  ]
  sources = [
    "tiff_v403/tiffiop.h",
    "tiff_v403/tif_aux.c",
    "tiff_v403/tif_close.c",
    "tiff_v403/tif_codec.c",
    "tiff_v403/tif_color.c",
    "tiff_v403/tif_compress.c",
    "tiff_v403/tif_dir.c",
    "tiff_v403/tif_dirinfo.c",
    "tiff_v403/tif_dirread.c",
    "tiff_v403/tif_dirwrite.c",
    "tiff_v403/tif_dumpmode.c",
    "tiff_v403/tif_error.c",
    "tiff_v403/tif_extension.c",
    "tiff_v403/tif_fax3.c",
    "tiff_v403/tif_fax3sm.c",
    "tiff_v403/tif_flush.c",
    "tiff_v403/tif_getimage.c",
    "tiff_v403/tif_jpeg.c",
    "tiff_v403/tif_luv.c",
    "tiff_v403/tif_lzw.c",
    "tiff_v403/tif_next.c",
    "tiff_v403/tif_ojpeg.c",
    "tiff_v403/tif_open.c",
    "tiff_v403/tif_packbits.c",
    "tiff_v403/tif_pixarlog.c",
    "tiff_v403/tif_predict.c",
    "tiff_v403/tif_print.c",
    "tiff_v403/tif_read.c",
    "tiff_v403/tif_strip.c",
    "tiff_v403/tif_swab.c",
    "tiff_v403/tif_thunder.c",
    "tiff_v403/tif_tile.c",
    "tiff_v403/tif_version.c",
    "tiff_v403/tif_warning.c",
    "tiff_v403/tif_write.c",
    "tiff_v403/tif_zip.c",
  ]
}

source_set("fx_zlib") {
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [
    "//build/config/compiler:no_chromium_code",
    "//third_party/pdfium:pdfium_config",
  ]
  sources = [
    "zlib_v128/adler32.c",
    "zlib_v128/compress.c",
    "zlib_v128/crc32.c",
    "zlib_v128/deflate.c",
    "zlib_v128/gzclose.c",
    "zlib_v128/gzlib.c",
    "zlib_v128/gzread.c",
    "zlib_v128/gzwrite.c",
    "zlib_v128/infback.c",
    "zlib_v128/inffast.c",
    "zlib_v128/inflate.c",
    "zlib_v128/inftrees.c",
    "zlib_v128/trees.c",
    "zlib_v128/uncompr.c",
    "zlib_v128/zutil.c",
  ]
}

source_set("pdfium_base") {
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [
    "//build/config/compiler:no_chromium_code",
    "//third_party/pdfium:pdfium_config",
  ]
  sources = [
    "base/logging.h",
    "base/macros.h",
    "base/nonstd_unique_ptr.h",
    "base/numerics/safe_conversions.h",
    "base/numerics/safe_conversions_impl.h",
    "base/numerics/safe_math.h",
    "base/numerics/safe_math_impl.h",
    "base/stl_util.h",
    "base/template_util.h",
  ]
}