# Copyright 2017 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import("//build/fuchsia/sdk.gni")
import("//flutter/common/config.gni")
import("//flutter/testing/testing.gni")

declare_args() {
  flutter_use_fontconfig = false
}

if (flutter_use_fontconfig) {
  assert(is_linux)
}

config("txt_config") {
  visibility = [ ":*" ]
  include_dirs = [ "src" ]
}

config("allow_posix_names") {
  if (is_win && is_clang) {
    # POSIX names of many functions are marked deprecated by default;
    # disable that since they are used for cross-platform compatibility.
    defines = [ "_CRT_NONSTDC_NO_DEPRECATE" ]
  }
}

source_set("txt") {
  defines = []
  if (flutter_use_fontconfig) {
    defines += [ "FLUTTER_USE_FONTCONFIG" ]
  }

  sources = [
    "src/skia/paragraph_builder_skia.cc",
    "src/skia/paragraph_builder_skia.h",
    "src/skia/paragraph_skia.cc",
    "src/skia/paragraph_skia.h",
    "src/txt/asset_font_manager.cc",
    "src/txt/asset_font_manager.h",
    "src/txt/font_asset_provider.cc",
    "src/txt/font_asset_provider.h",
    "src/txt/font_collection.cc",
    "src/txt/font_collection.h",
    "src/txt/font_features.cc",
    "src/txt/font_features.h",
    "src/txt/font_style.h",
    "src/txt/font_weight.h",
    "src/txt/line_metrics.h",
    "src/txt/paragraph.h",
    "src/txt/paragraph_builder.cc",
    "src/txt/paragraph_builder.h",
    "src/txt/paragraph_style.cc",
    "src/txt/paragraph_style.h",
    "src/txt/placeholder_run.cc",
    "src/txt/placeholder_run.h",
    "src/txt/platform.h",
    "src/txt/run_metrics.h",
    "src/txt/test_font_manager.cc",
    "src/txt/test_font_manager.h",
    "src/txt/text_baseline.h",
    "src/txt/text_decoration.cc",
    "src/txt/text_decoration.h",
    "src/txt/text_shadow.cc",
    "src/txt/text_shadow.h",
    "src/txt/text_style.cc",
    "src/txt/text_style.h",
    "src/txt/typeface_font_asset_provider.cc",
    "src/txt/typeface_font_asset_provider.h",
  ]

  public_configs = [ ":txt_config" ]

  public_deps = [
    "//flutter/display_list",
    "//flutter/fml",
    "//third_party/harfbuzz",
    "//third_party/icu",
    "//third_party/skia",
  ]

  deps = [
    "//third_party/skia",
    "//third_party/skia/modules/skparagraph",
  ]

  if (flutter_use_fontconfig) {
    deps += [ "//third_party/fontconfig" ]
  }

  if (is_mac || is_ios) {
    sources += [ "src/txt/platform_mac.mm" ]
    deps += [ "//flutter/fml" ]
  } else if (is_android) {
    sources += [ "src/txt/platform_android.cc" ]
  } else if (is_linux) {
    sources += [ "src/txt/platform_linux.cc" ]
  } else if (is_fuchsia) {
    sources += [ "src/txt/platform_fuchsia.cc" ]
    deps += [ "$fuchsia_sdk_root/fidl:fuchsia.fonts" ]
  } else if (is_win) {
    sources += [ "src/txt/platform_windows.cc" ]
  } else {
    sources += [ "src/txt/platform.cc" ]
  }
}

if (enable_unittests) {
  test_fixtures("txt_fixtures") {
    fixtures = [ "third_party/fonts/Roboto-Regular.ttf" ]
  }

  executable("txt_benchmarks") {
    testonly = true

    sources = [
      "benchmarks/skparagraph_benchmarks.cc",
      "benchmarks/txt_run_all_benchmarks.cc",
      "tests/txt_test_utils.cc",
      "tests/txt_test_utils.h",
    ]

    deps = [
      ":txt",
      ":txt_fixtures",
      "//flutter/fml",
      "//flutter/testing:testing_lib",
      "//third_party/benchmark",
      "//third_party/skia/modules/skparagraph",
    ]
  }

  executable("txt_unittests") {
    testonly = true

    sources = [ "tests/txt_run_all_unittests.cc" ]

    configs += [ ":allow_posix_names" ]

    deps = [
      ":txt_fixtures",
      "//flutter/fml",
      "//flutter/testing:testing_lib",
    ]

    # This is needed for //third_party/googletest for linking zircon symbols.
    if (is_fuchsia) {
      libs =
          [ "${fuchsia_sdk_path}/arch/${target_cpu}/sysroot/lib/libzircon.so" ]
    }
  }
}
