# 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.

import("//build/config/sanitizers/sanitizers.gni")
import("//build_overrides/v8.gni")
import("../pdfium.gni")

group("samples") {
  testonly = true
  deps = [
    ":pdfium_test",
    ":pdfium_diff",
  ]
}

config("pdfium_samples_config") {
  defines = [
    "PNG_PREFIX",
    "PNGPREFIX_H",
    "PNG_USE_READ_MACROS",
  ]
  include_dirs = [ ".." ]
  if (pdf_enable_v8) {
    defines += [ "PDF_ENABLE_V8", ]
  }
  if (pdf_enable_xfa) {
    defines += [ "PDF_ENABLE_XFA", ]
  }
}

executable("pdfium_test") {
  testonly = true
  sources = [
    "pdfium_test.cc",
    "image_diff_png.cc",
    "image_diff_png.h",
  ]
  deps = [
    "//build/config/sanitizers:deps",
    "//third_party/pdfium:pdfium",
    "//third_party/pdfium:test_support",

    # Regardless of whether the library ships against system freetype,
    # always link this binary against the bundled one for consistency
    # of results across platforms.
    "//third_party/pdfium/third_party:fx_freetype",
  ]
  if (!pdf_enable_xfa) {
    deps += [ "../third_party:fx_lpng" ]
  }
  if (pdf_enable_v8) {
    deps += [ "//v8:v8_libplatform" ]
    include_dirs = [
      "//v8",
      "//v8/include",
    ]
    configs += [ "//v8:external_startup_data" ]
  }
  configs += [ ":pdfium_samples_config" ]
}

executable("pdfium_diff") {
  testonly = true
  sources = [
    "image_diff.cc",
    "image_diff_png.cc",
    "image_diff_png.h",
  ]
  deps = [
    "//build/config/sanitizers:deps",
    "//third_party/pdfium",
  ]
  if (!pdf_enable_xfa) {
    deps += [ "../third_party:fx_lpng" ]
  }
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [
    ":pdfium_samples_config",
    "//build/config/compiler:no_chromium_code",
  ]
}