# Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

config("gtest_private_config") {
  visibility = [ ":*" ]
  include_dirs = [ "googletest" ]
  cflags_cc = [ "-std=c++17" ]
}

config("gtest_private_config_rtti") {
  visibility = [ ":*" ]
  include_dirs = [ "googletest" ]
  cflags = [ "-frtti" ]
  cflags_objcc = [ "-frtti" ]
  cflags_cc = [
    "-std=c++17",
    "-frtti",
  ]
}

config("gtest_private_config_rtti_main") {
  cflags_cc = [ "-std=c++17" ]
}

config("gtest_private_config_main") {
  cflags_cc = [ "-std=c++17" ]
}

config("gtest_config") {
  include_dirs = [ "googletest/include" ]
  cflags_cc = [
    "-Wno-float-equal",
    "-Wno-sign-compare",
    "-Wno-reorder-init-list",
  ]
  if (is_mingw) {
    cflags_cc += [
      "-Wno-unused-const-variable",
      "-Wno-unused-private-field",
    ]
  }
}

sources_files = [
  "googletest/include/gtest/gtest-death-test.h",
  "googletest/include/gtest/gtest-matchers.h",
  "googletest/include/gtest/gtest-message.h",
  "googletest/include/gtest/gtest-param-test.h",
  "googletest/include/gtest/gtest-printers.h",
  "googletest/include/gtest/gtest-test-part.h",
  "googletest/include/gtest/gtest-typed-test.h",
  "googletest/include/gtest/gtest_pred_impl.h",
  "googletest/include/gtest/gtest_prod.h",
  "googletest/include/gtest/hwext/gtest-ext.h",
  "googletest/include/gtest/hwext/gtest-filter.h",
  "googletest/include/gtest/hwext/gtest-multithread.h",
  "googletest/include/gtest/hwext/gtest-tag.h",
  "googletest/include/gtest/hwext/utils.h",
  "googletest/include/gtest/internal/custom/gtest-port.h",
  "googletest/include/gtest/internal/custom/gtest-printers.h",
  "googletest/include/gtest/internal/custom/gtest.h",
  "googletest/include/gtest/internal/gtest-death-test-internal.h",
  "googletest/include/gtest/internal/gtest-filepath.h",
  "googletest/include/gtest/internal/gtest-internal.h",
  "googletest/include/gtest/internal/gtest-param-util.h",
  "googletest/include/gtest/internal/gtest-port-arch.h",
  "googletest/include/gtest/internal/gtest-port.h",
  "googletest/include/gtest/internal/gtest-string.h",
  "googletest/include/gtest/internal/gtest-type-util.h",
  "googletest/src/gtest-all.cc",
  "googletest/src/gtest-assertion-result.cc",
  "googletest/src/gtest-death-test.cc",
  "googletest/src/gtest-filepath.cc",
  "googletest/src/gtest-internal-inl.h",
  "googletest/src/gtest-matchers.cc",
  "googletest/src/gtest-port.cc",
  "googletest/src/gtest-printers.cc",
  "googletest/src/gtest-test-part.cc",
  "googletest/src/gtest-typed-test.cc",
  "googletest/src/gtest.cc",
  "googletest/src/hwext/gtest-ext.cc",
  "googletest/src/hwext/gtest-filter.cc",
  "googletest/src/hwext/gtest-multithread.cpp",
  "googletest/src/hwext/gtest-tag.cc",
  "googletest/src/hwext/gtest-utils.cc",
]

static_library("gtest") {
  testonly = true
  public = [
    "googletest/include/gtest/gtest-spi.h",
    "googletest/include/gtest/gtest.h",
  ]
  sources = sources_files
  sources -= [ "googletest/src/gtest-all.cc" ]
  public_configs = [ ":gtest_config" ]
  configs += [ ":gtest_private_config" ]
  configs -= [ "//build/config/coverage:default_coverage" ]
}

static_library("gtest_rtti") {
  testonly = true
  public = [
    "googletest/include/gtest/gtest-spi.h",
    "googletest/include/gtest/gtest.h",
  ]
  sources = sources_files
  sources -= [ "googletest/src/gtest-all.cc" ]
  public_configs = [ ":gtest_config" ]
  configs += [ ":gtest_private_config_rtti" ]
  configs -= [ "//build/config/coverage:default_coverage" ]
}

static_library("gtest_rtti_main") {  #Add gtest entry with RTTI compilation
                                     # option
  testonly = true
  sources = [ "googletest/src/gtest_main.cc" ]
  public_configs = [ ":gtest_config" ]
  deps = [ ":gtest_rtti" ]
  configs += [ ":gtest_private_config_rtti_main" ]
  configs -= [ "//build/config/coverage:default_coverage" ]
}

static_library("gtest_main") {
  testonly = true
  sources = [ "googletest/src/gtest_main.cc" ]
  public_configs = [ ":gtest_config" ]
  deps = [ ":gtest" ]
  configs += [ ":gtest_private_config_main" ]
  configs -= [ "//build/config/coverage:default_coverage" ]
}

config("gmock_private_config") {
  visibility = [ ":*" ]
  include_dirs = [ "googlemock" ]
}

config("gmock_private_config_rtti") {
  visibility = [ ":*" ]
  include_dirs = [ "googlemock/include" ]
  cflags = [ "-frtti" ]
  cflags_objcc = [ "-frtti" ]
  cflags_cc = [ "-frtti" ]
}

config("gmock_private_config_main") {
  cflags_cc = [ "-std=c++17" ]
}

config("gmock_config") {
  include_dirs = [ "googlemock/include" ]

  cflags_cc = [
    # The MOCK_METHODn() macros do not specify "override", which triggers this
    # warning in users: "error: 'Method' overrides a member function but is not
    # marked 'override' [-Werror,-Winconsistent-missing-override]". Suppress
    # these warnings until https://github.com/google/googletest/issues/533 is
    # fixed.
    "-Wno-inconsistent-missing-override",
  ]
}

gmock_sources_files = [
  "googlemock/include/gmock/gmock-actions.h",
  "googlemock/include/gmock/gmock-cardinalities.h",
  "googlemock/include/gmock/gmock-function-mocker.h",
  "googlemock/include/gmock/gmock-matchers.h",
  "googlemock/include/gmock/gmock-more-actions.h",
  "googlemock/include/gmock/gmock-more-matchers.h",
  "googlemock/include/gmock/gmock-nice-strict.h",
  "googlemock/include/gmock/gmock-spec-builders.h",
  "googlemock/include/gmock/internal/custom/gmock-generated-actions.h",
  "googlemock/include/gmock/internal/custom/gmock-matchers.h",
  "googlemock/include/gmock/internal/custom/gmock-port.h",
  "googlemock/include/gmock/internal/gmock-internal-utils.h",
  "googlemock/include/gmock/internal/gmock-port.h",
  "googlemock/include/gmock/internal/gmock-pp.h",
  "googlemock/src/gmock-all.cc",
  "googlemock/src/gmock-cardinalities.cc",
  "googlemock/src/gmock-internal-utils.cc",
  "googlemock/src/gmock-matchers.cc",
  "googlemock/src/gmock-spec-builders.cc",
  "googlemock/src/gmock.cc",
]

static_library("gmock") {
  testonly = true
  public = [ "googlemock/include/gmock/gmock.h" ]
  sources = gmock_sources_files
  sources -= [ "googlemock/src/gmock-all.cc" ]
  public_configs = [ ":gmock_config" ]
  configs += [ ":gmock_private_config" ]
  configs -= [ "//build/config/coverage:default_coverage" ]
  deps = [ ":gtest" ]
}

static_library("gmock_rtti") {
  testonly = true
  public = [ "googlemock/include/gmock/gmock.h" ]
  sources = gmock_sources_files
  sources -= [ "googlemock/src/gmock-all.cc" ]
  public_configs = [ ":gmock_config" ]
  configs += [ ":gmock_private_config_rtti" ]
  configs -= [ "//build/config/coverage:default_coverage" ]
  deps = [ ":gtest_rtti" ]
}

static_library("gmock_main") {
  testonly = true
  sources = [ "googlemock/src/gmock_main.cc" ]
  public_configs = [ ":gmock_config", ":gtest_config" ]
  deps = [
    ":gmock",
    ":gtest",
  ]
  configs += [ ":gmock_private_config_main" ]
  configs -= [ "//build/config/coverage:default_coverage" ]
}