xref: /aosp_15_r20/external/swiftshader/BUILD.gn (revision 03ce13f70fcc45d86ee91b7ee4cab1936a95046e)
1# Copyright 2016 The SwiftShader Authors. All Rights Reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#    http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15import("src/Reactor/reactor.gni")
16
17config("swiftshader_config") {
18  cflags = []
19  defines = []
20  asmflags = []
21
22  if (is_clang) {
23    cflags += [ "-Wno-shadow" ]
24  }
25
26  if (is_debug) {
27    if (swiftshader_startup_dialog) {
28      defines += [ "DEBUGGER_WAIT_DIALOG" ]
29    }
30  }
31  if (is_win) {
32    # Disable MSVC warnings about std::aligned_storage being broken before
33    # VS 2017 15.8
34    defines += [ "_ENABLE_EXTENDED_ALIGNED_STORAGE" ]
35
36    # Diable some MSVC warnings.
37    if (!is_clang) {
38      cflags += [
39        "/wd4065",  # switch statement contains 'default' but no 'case' labels
40        "/wd4309",  # Truncation of constant value. See PixelRoutine.cpp casts
41                    # of signed shorts.
42      ]
43    }
44  } else if (!is_debug) {
45    cflags += [ "-Os" ]
46  }
47
48  if (build_with_chromium) {
49    if (is_clang) {
50      if (current_cpu == "arm64") {
51        import("//build/config/arm.gni")
52
53        if (arm_control_flow_integrity == "standard") {
54          cflags += [ "-mbranch-protection=standard" ]
55          asmflags += [ "-mbranch-protection=standard" ]
56        } else if (arm_control_flow_integrity == "pac") {
57          cflags += [ "-mbranch-protection=pac-ret" ]
58          asmflags += [ "-mbranch-protection=pac-ret" ]
59        } else {
60          assert(arm_control_flow_integrity == "none",
61                 "Invalid branch protection option!")
62        }
63      }
64    }
65  }
66}
67
68group("swiftshader") {
69  data_deps = [
70    "src/Vulkan:icd_file",
71    "src/Vulkan:swiftshader_libvulkan",
72  ]
73}
74
75if (build_with_chromium) {
76  group("swiftshader_tests") {
77    testonly = true
78
79    data_deps = [ "tests/SystemUnitTests:swiftshader_system_unittests" ]
80
81    if (supports_llvm) {
82      data_deps +=
83          [ "tests/ReactorUnitTests:swiftshader_reactor_llvm_unittests" ]
84    }
85
86    if (supports_subzero) {
87      data_deps +=
88          [ "tests/ReactorUnitTests:swiftshader_reactor_subzero_unittests" ]
89    }
90  }
91}
92