Commit 89a33901 authored by Jon Kunkee's avatar Jon Kunkee Committed by Commit Bot

[imagediff] During cross builds, build for swarm host

Specific tools need to run on the test-initiating machines instead of
the build host or the build target. Since GN does not provide a third
toolchain designation for this, it needs to be calculated in the
exceptional cases that need it.

This CL adds this logic for imagediff.

Bug: 893460
Change-Id: I07f7a39971f47517550fc4edc0922f4b15eb87e5
Reviewed-on: https://chromium-review.googlesource.com/c/1489484
Commit-Queue: Nico Weber <thakis@chromium.org>
Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Reviewed-by: default avatarDirk Pranke <dpranke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#636602}
parent b1598cb6
...@@ -207,7 +207,7 @@ group("gn_all") { ...@@ -207,7 +207,7 @@ group("gn_all") {
"//third_party/blink/renderer/platform/heap:blink_heap_unittests", "//third_party/blink/renderer/platform/heap:blink_heap_unittests",
"//third_party/catapult/telemetry:bitmaptools($host_toolchain)", "//third_party/catapult/telemetry:bitmaptools($host_toolchain)",
"//third_party/smhasher:pmurhash", "//third_party/smhasher:pmurhash",
"//tools/imagediff($host_toolchain)", "//tools/imagediff",
"//ui/display:display_unittests", "//ui/display:display_unittests",
"//ui/events:events_unittests", "//ui/events:events_unittests",
"//ui/latency:latency_unittests", "//ui/latency:latency_unittests",
......
...@@ -4,7 +4,35 @@ ...@@ -4,7 +4,35 @@
import("//build/symlink.gni") import("//build/symlink.gni")
if (current_toolchain == host_toolchain) { # 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.
image_diff_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") { executable("imagediff") {
output_name = "image_diff" # Different than dir name for historical reasons. output_name = "image_diff" # Different than dir name for historical reasons.
sources = [ sources = [
...@@ -22,13 +50,21 @@ if (current_toolchain == host_toolchain) { ...@@ -22,13 +50,21 @@ if (current_toolchain == host_toolchain) {
"//third_party/zlib", "//third_party/zlib",
] ]
} }
} else { # 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_symlink("imagediff") {
binary_label = ":$target_name($host_toolchain)" binary_label = ":$target_name($imagediff_toolchain)"
binary_output_name = "image_diff" binary_output_name = "image_diff"
# The 'executable' target does this automatically. # For Windows builds, the test host and test target are both Windows and so
if (is_win) { # binary_symlink needs to use the Windows binary suffix.
if (target_os == "win") {
binary_output_name += ".exe" binary_output_name += ".exe"
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment