Alexis Hetu | 91f10e3 | 2016-06-07 19:53:42 -0400 | [diff] [blame] | 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 | |
Nicolas Capens | 282aa41 | 2020-11-16 11:37:29 -0500 | [diff] [blame] | 15 | import("src/Reactor/reactor.gni") |
Nicolas Capens | d51e216 | 2017-06-05 13:59:55 -0400 | [diff] [blame] | 16 | |
Alexis Hetu | 91f10e3 | 2016-06-07 19:53:42 -0400 | [diff] [blame] | 17 | config("swiftshader_config") { |
Geoff Lang | c710de9 | 2021-09-23 10:10:03 -0400 | [diff] [blame] | 18 | cflags = [] |
Alexis Hetu | 0def102 | 2017-08-16 17:15:48 -0400 | [diff] [blame] | 19 | defines = [] |
André Kempe | 34d436e | 2021-08-11 17:27:38 +0100 | [diff] [blame] | 20 | asmflags = [] |
Alexis Hetu | 2ddef88 | 2017-03-14 15:11:15 -0400 | [diff] [blame] | 21 | |
Geoff Lang | c710de9 | 2021-09-23 10:10:03 -0400 | [diff] [blame] | 22 | if (is_clang) { |
| 23 | cflags += [ "-Wno-shadow" ] |
| 24 | } |
| 25 | |
Nicolas Capens | 77ebb7f | 2021-11-24 11:06:46 -0500 | [diff] [blame] | 26 | if (is_debug) { |
| 27 | if (swiftshader_startup_dialog) { |
| 28 | defines += [ "DEBUGGER_WAIT_DIALOG" ] |
| 29 | } |
| 30 | } else { |
Nico Weber | 766eb91 | 2021-07-08 14:13:38 -0400 | [diff] [blame] | 31 | defines += [ "ANGLE_DISABLE_TRACE" ] |
| 32 | } |
| 33 | |
Nico Weber | ba18c78 | 2021-07-10 15:26:15 -0400 | [diff] [blame] | 34 | if (!is_win || is_clang) { |
| 35 | defines += |
| 36 | [ "NO_SANITIZE_FUNCTION=__attribute__((no_sanitize(\"function\")))" ] |
| 37 | } else { |
| 38 | defines += [ "NO_SANITIZE_FUNCTION=" ] |
| 39 | } |
Nico Weber | b45ad7a | 2021-07-08 11:18:12 -0400 | [diff] [blame] | 40 | |
Nico Weber | ba18c78 | 2021-07-10 15:26:15 -0400 | [diff] [blame] | 41 | 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 Hetu | c55dd84 | 2017-08-08 08:31:13 -0400 | [diff] [blame] | 45 | |
Jamie Madill | 9746f8b | 2019-09-05 13:17:09 -0400 | [diff] [blame] | 46 | # Diable some MSVC warnings. |
| 47 | if (!is_clang) { |
| 48 | cflags += [ |
Nico Weber | b45ad7a | 2021-07-08 11:18:12 -0400 | [diff] [blame] | 49 | "/wd4065", # switch statement contains 'default' but no 'case' labels |
| 50 | "/wd4309", # Truncation of constant value. See PixelRoutine.cpp casts |
| 51 | # of signed shorts. |
Jamie Madill | 9746f8b | 2019-09-05 13:17:09 -0400 | [diff] [blame] | 52 | ] |
| 53 | } |
Nicolas Capens | b3e5c44 | 2021-01-20 06:16:24 +0000 | [diff] [blame] | 54 | |
| 55 | cflags_cc = [ "/std:c++17" ] |
Alexis Hetu | 03b67af | 2016-08-31 17:25:40 -0400 | [diff] [blame] | 56 | } else { |
Nicolas Capens | b3e5c44 | 2021-01-20 06:16:24 +0000 | [diff] [blame] | 57 | cflags_cc = [ "-std=c++17" ] |
Nicolas Capens | 1cdfcb6 | 2021-10-01 00:08:31 -0400 | [diff] [blame] | 58 | cflags_objcc = [ "-std=c++17" ] |
Nico Weber | b45ad7a | 2021-07-08 11:18:12 -0400 | [diff] [blame] | 59 | |
Nico Weber | b45ad7a | 2021-07-08 11:18:12 -0400 | [diff] [blame] | 60 | if (!is_debug) { |
Nico Weber | 6f0ce12 | 2021-07-08 13:41:17 -0400 | [diff] [blame] | 61 | cflags += [ "-Os" ] |
Alexis Hetu | c55dd84 | 2017-08-08 08:31:13 -0400 | [diff] [blame] | 62 | } |
Alexis Hetu | 91f10e3 | 2016-06-07 19:53:42 -0400 | [diff] [blame] | 63 | } |
André Kempe | 34d436e | 2021-08-11 17:27:38 +0100 | [diff] [blame] | 64 | |
| 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é Kempe | dbaf11f | 2021-12-09 08:44:42 +0000 | [diff] [blame] | 73 | } else if (arm_control_flow_integrity == "pac") { |
| 74 | cflags += [ "-mbranch-protection=pac-ret" ] |
| 75 | asmflags += [ "-mbranch-protection=pac-ret" ] |
André Kempe | 34d436e | 2021-08-11 17:27:38 +0100 | [diff] [blame] | 76 | } else { |
| 77 | assert(arm_control_flow_integrity == "none", |
| 78 | "Invalid branch protection option!") |
| 79 | } |
| 80 | } |
| 81 | } |
| 82 | } |
Alexis Hetu | 91f10e3 | 2016-06-07 19:53:42 -0400 | [diff] [blame] | 83 | } |
| 84 | |
Alexis Hetu | 68f564d | 2016-07-06 17:43:22 -0400 | [diff] [blame] | 85 | group("swiftshader") { |
Alexis Hetu | 996663b | 2016-09-21 13:47:42 -0400 | [diff] [blame] | 86 | data_deps = [ |
Alexis Hetu | 996663b | 2016-09-21 13:47:42 -0400 | [diff] [blame] | 87 | "src/OpenGL/libEGL:swiftshader_libEGL", |
Nico Weber | b45ad7a | 2021-07-08 11:18:12 -0400 | [diff] [blame] | 88 | "src/OpenGL/libGLESv2:swiftshader_libGLESv2", |
Alexis Hetu | 996663b | 2016-09-21 13:47:42 -0400 | [diff] [blame] | 89 | ] |
Alexis Hetu | a6e99c0 | 2016-11-16 13:53:57 -0500 | [diff] [blame] | 90 | } |
| 91 | |
Jamie Madill | bbd8c42 | 2019-08-28 17:08:17 -0400 | [diff] [blame] | 92 | if (build_with_chromium) { |
Nico Weber | b45ad7a | 2021-07-08 11:18:12 -0400 | [diff] [blame] | 93 | group("swiftshader_tests") { |
| 94 | testonly = true |
Alexis Hetu | a6e99c0 | 2016-11-16 13:53:57 -0500 | [diff] [blame] | 95 | |
Nico Weber | b45ad7a | 2021-07-08 11:18:12 -0400 | [diff] [blame] | 96 | data_deps = [ |
| 97 | "tests/GLESUnitTests:swiftshader_unittests", |
| 98 | "tests/SystemUnitTests:swiftshader_system_unittests", |
| 99 | ] |
Nicolas Capens | 282aa41 | 2020-11-16 11:37:29 -0500 | [diff] [blame] | 100 | |
Nico Weber | b45ad7a | 2021-07-08 11:18:12 -0400 | [diff] [blame] | 101 | if (supports_llvm) { |
| 102 | data_deps += |
| 103 | [ "tests/ReactorUnitTests:swiftshader_reactor_llvm_unittests" ] |
Jamie Madill | bbd8c42 | 2019-08-28 17:08:17 -0400 | [diff] [blame] | 104 | } |
Nico Weber | b45ad7a | 2021-07-08 11:18:12 -0400 | [diff] [blame] | 105 | |
| 106 | if (supports_subzero) { |
| 107 | data_deps += |
| 108 | [ "tests/ReactorUnitTests:swiftshader_reactor_subzero_unittests" ] |
| 109 | } |
| 110 | } |
David 'Digit' Turner | c9fa9fe | 2019-08-13 19:05:01 +0200 | [diff] [blame] | 111 | } |