blob: ae605162a2d4b04177f6205bb1aa0aa4cfdad631 [file] [log] [blame]
# Copyright 2014 The Chromium 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/symlink.gni")
# There are three machines involved with building and running tests:
# * the build host, where GN, ninja, and the build tools run
# * the test host, where the swarming task runs
# * the test target, where the test collateral runs
#
# image_diff runs on the test host.
#
# Normally all three machines can be built for using the same toolchain, but
# cross-compilation is an important exception. A few of these are:
# * Linux build host + Windows test host + Windows test target
# * Linux build host + Linux test host + Android test target
#
# Since the concept of a 'test host' toolchain is very rarely needed, GN does
# not provide it. Instead, determine it here.
if (target_os == "win" && host_os != "win") {
# When targeting Windows from not Windows, use the test target toolchain.
imagediff_toolchain = default_toolchain
} else if (target_os != host_os) {
# In common cross-compilation scenarios, the build host matches the test host.
# TODO: In chrome/android-on-mac cross builds, image_diff would still have to
# be built for Linux and this line is wrong.
imagediff_toolchain = host_toolchain
} else {
# When not cross-compiling, use the test target toolchain.
imagediff_toolchain = default_toolchain
}
# If the current toolchain is the test host toolchain, build the tool.
if (current_toolchain == imagediff_toolchain) {
executable("imagediff") {
output_name = "image_diff" # Different than dir name for historical reasons.
sources = [
"image_diff.cc",
"image_diff_png.cc",
"image_diff_png.h",
]
configs += [ "//build/config/compiler:wexit_time_destructors" ]
deps = [
"//base",
"//build/win:default_exe_manifest",
"//third_party/libpng",
"//third_party/zlib",
]
}
# Otherwise, if the current toolchain is the test target toolchain, make a
# symlink to the test host toolchain output so the tests can find it.
#
# Note that Windows does not follow links when searching for DLLs, so
# image_diff.exe from component builds won't run via symlink. Fortunately,
# Windows builds use the default_toolchain and so avoid making the link.
} else if (current_toolchain == default_toolchain &&
default_toolchain != imagediff_toolchain) {
binary_symlink("imagediff") {
binary_label = ":$target_name($imagediff_toolchain)"
binary_output_name = "image_diff"
# For Windows builds, the test host and test target are both Windows and so
# binary_symlink needs to use the Windows binary suffix.
if (target_os == "win") {
binary_output_name += ".exe"
}
}
}