chromium/tools/binary_size/libsupersize/viewer/caspian/BUILD.gn

# Copyright 2019 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//testing/test.gni")

# Enable wasm target that depends on foo.patch being applied.
if (!defined(is_wasm)) {
  is_wasm = current_os == "wasm"
}

assert(is_linux || is_chromeos || is_wasm)

source_set("caspian-lib") {
  sources = [
    "diff.cc",
    "diff.h",
    "file_format.cc",
    "file_format.h",
    "function_signature.cc",
    "function_signature.h",
    "grouped_path.cc",
    "grouped_path.h",
    "lens.cc",
    "lens.h",
    "model.cc",
    "model.h",
    "tree_builder.cc",
    "tree_builder.h",
  ]
  deps = [
    "//third_party/re2:re2",
    "//third_party/zlib:zlib",
    "//third_party/zlib/google:compression_utils_portable",
  ]
  public_deps = [ "//third_party/jsoncpp:jsoncpp" ]
  configs -= [ "//build/config/compiler:default_optimization" ]
  configs += [ "//build/config/compiler:optimize_speed" ]
}

test("caspian_unittests") {
  sources = [
    "diff_test.cc",
    "function_signature_test.cc",
    "grouped_path_test.cc",
    "lens_test.cc",
    "tree_builder_test.cc",
  ]
  deps = [
    ":caspian-lib",
    "//testing/gtest",
    "//testing/gtest:gtest_main",
    "//third_party/re2:re2",
  ]
}

executable("caspian_cli") {
  sources = [ "cli.cc" ]
  deps = [ ":caspian-lib" ]
  cflags = [ "-Wall" ]
}

if (is_wasm) {
  executable("caspian_web") {
    sources = [ "caspian_web.cc" ]
    deps = [
      ":caspian-lib",
      "//third_party/re2:re2",
    ]
    ldflags = [
      "-s",
      "EXPORTED_FUNCTIONS=['_BuildTree','_GetMetadata','_LoadBeforeSizeFile','_LoadSizeFile','_Open','_QueryAncestryById','_QueryProperty','_free','_malloc']",
      "-s",
      "EXPORTED_RUNTIME_METHODS=['ccall','cwrap','UTF8ToString']",
    ]
  }
}