1# Copyright 2020 The ANGLE Project Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import("../../../gni/angle.gni")
6
7declare_args() {
8  # Determines if we build the capture_replay_tests. Off by default.
9  angle_build_capture_replay_tests = false
10
11  # Set the trace directory. Default is traces
12  angle_capture_replay_test_trace_dir = "traces"
13
14  angle_capture_replay_composite_file_id = 1
15}
16
17if (angle_build_capture_replay_tests) {
18  assert(angle_with_capture_by_default, "Must build with capture by default.")
19
20  angle_trace_fixture("angle_capture_replay_tests_fixture") {
21    gl_header = "angle_trace_gl.h"
22    public_deps = [
23      "$angle_root:libEGL",
24      "$angle_root/util:angle_util",
25    ]
26  }
27
28  # TODO (nguyenmh): http://anglebug.com/4758:
29  # turn angle_executable into angle_test when adding android support
30  import(
31      "${angle_capture_replay_test_trace_dir}/traces${angle_capture_replay_composite_file_id}.gni")
32
33  # Build each trace into a module. Use a short name to work around file path limits on Windows.
34  _trace_counter = 1
35  _traces = []
36  foreach(_trace_data, trace_data) {
37    _trace = _trace_data[0]
38    _target = "cr_trace_" + _trace_counter
39    _trace_counter += 1
40    angle_trace(_target) {
41      trace_name = _trace
42      trace_dir = angle_capture_replay_test_trace_dir
43      trace_ctx = _trace_data[1]
44      sources = _trace_data[2]
45      angledata = _trace_data[3]
46      fixture = ":angle_capture_replay_tests_fixture"
47      output_name = _trace
48    }
49
50    _traces += [ ":${_target}" ]
51  }
52
53  angle_executable("capture_replay_tests") {
54    testonly = true
55    sources = [
56      "${angle_capture_replay_test_trace_dir}/CompositeTests${angle_capture_replay_composite_file_id}.cpp",
57      "${angle_capture_replay_test_trace_dir}/CompositeTests${angle_capture_replay_composite_file_id}.h",
58      "CaptureReplayTests.cpp",
59    ]
60    deps = [
61             ":angle_capture_replay_tests_fixture",
62             "$angle_root:angle_common",
63             "$angle_root:angle_compression",
64           ] + _traces
65    configs += [
66      "$angle_root:library_name_config",
67      "$angle_root:libANGLE_config",
68    ]
69    defines = []
70
71    if ((is_linux || is_chromeos) && !is_component_build) {
72      # Set rpath to find shared libs in a non-component build.
73      configs += [ "//build/config/gcc:rpath_for_built_shared_libraries" ]
74    }
75
76    suppressed_configs += [ "$angle_root:constructor_and_destructor_warnings" ]
77
78    # Disable optimization to avoid optimizing huge files.
79    _trace_folder_relative_path = "./" + angle_capture_replay_test_trace_dir
80    _data_path = rebase_path(_trace_folder_relative_path, root_out_dir)
81    defines = [
82      "ANGLE_CAPTURE_REPLAY_TEST_DATA_DIR=\"${_data_path}\"",
83      "ANGLE_CAPTURE_REPLAY_COMPOSITE_TESTS_HEADER=" +
84          angle_capture_replay_test_trace_dir +
85          "/CompositeTests${angle_capture_replay_composite_file_id}.h",
86      "ANGLE_REPLAY_EXPORT=",
87    ]
88    include_dirs = [ "." ]
89  }
90} else {
91  group("capture_replay_tests") {
92  }
93}
94