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

import("//build/config/linux/pkg_config.gni")
import("//build/config/ui.gni")

# These packages should _only_ be expected when building for a target.
# assert(current_toolchain == default_toolchain)

if (use_atk) {
  pkg_config("atspi2") {
    packages = [ "atspi-2" ]
    atspi_version = exec_script(pkg_config_script,
                                common_pkg_config_args + pkg_config_args + [
                                      "atspi-2",
                                      "--version-as-components",
                                    ],
                                "value")
    major = atspi_version[0]
    minor = atspi_version[1]
    micro = atspi_version[2]

    # These aren't necessarily used if atspi is not old enough to require them.
    # Also, gn considers variables unused if the only use of them is
    # short-circuited away, so for example if major == 2 and minor == 48, micro
    # would be unused.
    not_needed([
                 "major",
                 "minor",
                 "micro",
               ])

    # ATSPI 2.49.90 now defines these for us and it's an error for us to
    # redefine them on the compiler command line.
    # See ATSPI 927344a34cd5bf81fc64da4968241735ecb4f03b
    if (major < 2 || (major == 2 && minor < 49) ||
        (major == 2 && minor == 49 && micro < 90)) {
      defines = [
        "ATSPI_MAJOR_VERSION=$major",
        "ATSPI_MINOR_VERSION=$minor",
        "ATSPI_MICRO_VERSION=$micro",
      ]
    }
  }
}