blob: 83affe0c68462f882870a95a7df4e2f12c18879a [file] [log] [blame]
Alexis Hetu91f10e32016-06-07 19:53:42 -04001# 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
Nicolas Capens282aa412020-11-16 11:37:29 -050015import("src/Reactor/reactor.gni")
Nicolas Capensd51e2162017-06-05 13:59:55 -040016
Alexis Hetu91f10e32016-06-07 19:53:42 -040017config("swiftshader_config") {
Geoff Langc710de92021-09-23 10:10:03 -040018 cflags = []
Alexis Hetu0def1022017-08-16 17:15:48 -040019 defines = []
André Kempe34d436e2021-08-11 17:27:38 +010020 asmflags = []
Alexis Hetu2ddef882017-03-14 15:11:15 -040021
Geoff Langc710de92021-09-23 10:10:03 -040022 if (is_clang) {
23 cflags += [ "-Wno-shadow" ]
24 }
25
Nicolas Capens77ebb7f2021-11-24 11:06:46 -050026 if (is_debug) {
27 if (swiftshader_startup_dialog) {
28 defines += [ "DEBUGGER_WAIT_DIALOG" ]
29 }
30 } else {
Nico Weber766eb912021-07-08 14:13:38 -040031 defines += [ "ANGLE_DISABLE_TRACE" ]
32 }
33
Nico Weberba18c782021-07-10 15:26:15 -040034 if (!is_win || is_clang) {
35 defines +=
36 [ "NO_SANITIZE_FUNCTION=__attribute__((no_sanitize(\"function\")))" ]
37 } else {
38 defines += [ "NO_SANITIZE_FUNCTION=" ]
39 }
Nico Weberb45ad7a2021-07-08 11:18:12 -040040
Nico Weberba18c782021-07-10 15:26:15 -040041 if (is_win) {
42 # Disable MSVC warnings about std::aligned_storage being broken before
43 # VS 2017 15.8
44 defines += [ "_ENABLE_EXTENDED_ALIGNED_STORAGE" ]
Alexis Hetuc55dd842017-08-08 08:31:13 -040045
Jamie Madill9746f8b2019-09-05 13:17:09 -040046 # Diable some MSVC warnings.
47 if (!is_clang) {
48 cflags += [
Nico Weberb45ad7a2021-07-08 11:18:12 -040049 "/wd4065", # switch statement contains 'default' but no 'case' labels
50 "/wd4309", # Truncation of constant value. See PixelRoutine.cpp casts
51 # of signed shorts.
Jamie Madill9746f8b2019-09-05 13:17:09 -040052 ]
53 }
Nicolas Capensb3e5c442021-01-20 06:16:24 +000054
55 cflags_cc = [ "/std:c++17" ]
Alexis Hetu03b67af2016-08-31 17:25:40 -040056 } else {
Nicolas Capensb3e5c442021-01-20 06:16:24 +000057 cflags_cc = [ "-std=c++17" ]
Nicolas Capens1cdfcb62021-10-01 00:08:31 -040058 cflags_objcc = [ "-std=c++17" ]
Nico Weberb45ad7a2021-07-08 11:18:12 -040059
Nico Weberb45ad7a2021-07-08 11:18:12 -040060 if (!is_debug) {
Nico Weber6f0ce122021-07-08 13:41:17 -040061 cflags += [ "-Os" ]
Alexis Hetuc55dd842017-08-08 08:31:13 -040062 }
Alexis Hetu91f10e32016-06-07 19:53:42 -040063 }
André Kempe34d436e2021-08-11 17:27:38 +010064
65 if (build_with_chromium) {
66 if (is_clang) {
67 if (current_cpu == "arm64") {
68 import("//build/config/arm.gni")
69
70 if (arm_control_flow_integrity == "standard") {
71 cflags += [ "-mbranch-protection=standard" ]
72 asmflags += [ "-mbranch-protection=standard" ]
André Kempedbaf11f2021-12-09 08:44:42 +000073 } else if (arm_control_flow_integrity == "pac") {
74 cflags += [ "-mbranch-protection=pac-ret" ]
75 asmflags += [ "-mbranch-protection=pac-ret" ]
André Kempe34d436e2021-08-11 17:27:38 +010076 } else {
77 assert(arm_control_flow_integrity == "none",
78 "Invalid branch protection option!")
79 }
80 }
81 }
82 }
Alexis Hetu91f10e32016-06-07 19:53:42 -040083}
84
Alexis Hetu68f564d2016-07-06 17:43:22 -040085group("swiftshader") {
Alexis Hetu996663b2016-09-21 13:47:42 -040086 data_deps = [
Alexis Hetu1d450ae2022-04-07 23:04:23 -040087 "src/Vulkan:icd_file",
88 "src/Vulkan:swiftshader_libvulkan",
Alexis Hetu996663b2016-09-21 13:47:42 -040089 ]
Alexis Hetua6e99c02016-11-16 13:53:57 -050090}
91
Jamie Madillbbd8c422019-08-28 17:08:17 -040092if (build_with_chromium) {
Nico Weberb45ad7a2021-07-08 11:18:12 -040093 group("swiftshader_tests") {
94 testonly = true
Alexis Hetua6e99c02016-11-16 13:53:57 -050095
Alexis Hetu1d450ae2022-04-07 23:04:23 -040096 data_deps = [ "tests/SystemUnitTests:swiftshader_system_unittests" ]
Nicolas Capens282aa412020-11-16 11:37:29 -050097
Nico Weberb45ad7a2021-07-08 11:18:12 -040098 if (supports_llvm) {
99 data_deps +=
100 [ "tests/ReactorUnitTests:swiftshader_reactor_llvm_unittests" ]
Jamie Madillbbd8c422019-08-28 17:08:17 -0400101 }
Nico Weberb45ad7a2021-07-08 11:18:12 -0400102
103 if (supports_subzero) {
104 data_deps +=
105 [ "tests/ReactorUnitTests:swiftshader_reactor_subzero_unittests" ]
106 }
107 }
David 'Digit' Turnerc9fa9fe2019-08-13 19:05:01 +0200108}