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 | d51e216 | 2017-06-05 13:59:55 -0400 | [diff] [blame] | 15 | import("//build/config/compiler/compiler.gni") |
| 16 | |
Alexis Hetu | 91f10e3 | 2016-06-07 19:53:42 -0400 | [diff] [blame] | 17 | config("swiftshader_config") { |
Alexis Hetu | 2ddef88 | 2017-03-14 15:11:15 -0400 | [diff] [blame] | 18 | defines = [ "STRICT_CONFORMANCE" ] # Disables OpenGL ES 3.0 |
| 19 | |
Alexis Hetu | 03b67af | 2016-08-31 17:25:40 -0400 | [diff] [blame] | 20 | if (is_win) { |
| 21 | cflags = [ |
Alexis Hetu | d6d10f9 | 2016-11-22 13:47:04 -0500 | [diff] [blame] | 22 | "/GS", # Detects some buffer overruns |
Alexis Hetu | 03b67af | 2016-08-31 17:25:40 -0400 | [diff] [blame] | 23 | "/Zc:wchar_t", |
Alexis Hetu | 03b67af | 2016-08-31 17:25:40 -0400 | [diff] [blame] | 24 | "/EHsc", |
| 25 | "/nologo", |
Alexis Hetu | d6d10f9 | 2016-11-22 13:47:04 -0500 | [diff] [blame] | 26 | "/Gd", # Default calling convention |
Alexis Hetu | 2ddef88 | 2017-03-14 15:11:15 -0400 | [diff] [blame] | 27 | ] |
| 28 | |
| 29 | defines += [ |
| 30 | "_CRT_SECURE_NO_DEPRECATE", |
| 31 | "NOMINMAX", |
| 32 | "_WINDLL", |
Alexis Hetu | 03b67af | 2016-08-31 17:25:40 -0400 | [diff] [blame] | 33 | ] |
| 34 | |
| 35 | if (is_debug) { |
Alexis Hetu | d6d10f9 | 2016-11-22 13:47:04 -0500 | [diff] [blame] | 36 | cflags += [ "/RTC1" ] # Run-Time Error Checks |
Alexis Hetu | 03b67af | 2016-08-31 17:25:40 -0400 | [diff] [blame] | 37 | } else { |
Alexis Hetu | 2ddef88 | 2017-03-14 15:11:15 -0400 | [diff] [blame] | 38 | defines += [ "ANGLE_DISABLE_TRACE" ] |
Alexis Hetu | 03b67af | 2016-08-31 17:25:40 -0400 | [diff] [blame] | 39 | } |
| 40 | } else { |
Alexis Hetu | a11d03e | 2017-01-27 11:38:59 -0500 | [diff] [blame] | 41 | cflags = [ |
| 42 | "-std=c++11", |
| 43 | "-Wall", |
Alexis Hetu | 2c0546d | 2017-05-24 11:16:26 -0400 | [diff] [blame] | 44 | "-fno-exceptions", |
Alexis Hetu | a11d03e | 2017-01-27 11:38:59 -0500 | [diff] [blame] | 45 | "-fno-operator-names", |
Alexis Hetu | 2ddef88 | 2017-03-14 15:11:15 -0400 | [diff] [blame] | 46 | ] |
| 47 | |
| 48 | defines += [ |
| 49 | "__STDC_CONSTANT_MACROS", |
| 50 | "__STDC_LIMIT_MACROS", |
Alexis Hetu | a11d03e | 2017-01-27 11:38:59 -0500 | [diff] [blame] | 51 | ] |
Alexis Hetu | 91f10e3 | 2016-06-07 19:53:42 -0400 | [diff] [blame] | 52 | |
| 53 | if (is_debug) { |
Alexis Hetu | a11d03e | 2017-01-27 11:38:59 -0500 | [diff] [blame] | 54 | cflags += [ |
| 55 | "-g", |
| 56 | "-g3", |
| 57 | ] |
Alexis Hetu | d6d10f9 | 2016-11-22 13:47:04 -0500 | [diff] [blame] | 58 | } else { # Release |
Alexis Hetu | 91f10e3 | 2016-06-07 19:53:42 -0400 | [diff] [blame] | 59 | # All Release builds use function/data sections to make the shared libraries smaller |
| 60 | cflags += [ |
| 61 | "-ffunction-sections", |
| 62 | "-fdata-sections", |
Alexis Hetu | 91f10e3 | 2016-06-07 19:53:42 -0400 | [diff] [blame] | 63 | "-fomit-frame-pointer", |
Alexis Hetu | a11d03e | 2017-01-27 11:38:59 -0500 | [diff] [blame] | 64 | "-Os", |
Alexis Hetu | 91f10e3 | 2016-06-07 19:53:42 -0400 | [diff] [blame] | 65 | ] |
Alexis Hetu | 2ddef88 | 2017-03-14 15:11:15 -0400 | [diff] [blame] | 66 | |
| 67 | defines += [ |
| 68 | "ANGLE_DISABLE_TRACE", |
| 69 | "NDEBUG", |
| 70 | ] |
Alexis Hetu | 91f10e3 | 2016-06-07 19:53:42 -0400 | [diff] [blame] | 71 | } |
| 72 | |
Alexis Hetu | d6d10f9 | 2016-11-22 13:47:04 -0500 | [diff] [blame] | 73 | if (target_cpu == "x64") { # 64 bit version |
Alexis Hetu | 91f10e3 | 2016-06-07 19:53:42 -0400 | [diff] [blame] | 74 | cflags += [ |
| 75 | "-m64", |
| 76 | "-fPIC", |
Alexis Hetu | a11d03e | 2017-01-27 11:38:59 -0500 | [diff] [blame] | 77 | "-march=core2", |
Alexis Hetu | 91f10e3 | 2016-06-07 19:53:42 -0400 | [diff] [blame] | 78 | ] |
Alexis Hetu | d6d10f9 | 2016-11-22 13:47:04 -0500 | [diff] [blame] | 79 | } else { # 32 bit version |
Alexis Hetu | a11d03e | 2017-01-27 11:38:59 -0500 | [diff] [blame] | 80 | cflags += [ |
| 81 | "-m32", |
| 82 | "-msse2", |
| 83 | "-march=i686", |
| 84 | ] |
Alexis Hetu | 91f10e3 | 2016-06-07 19:53:42 -0400 | [diff] [blame] | 85 | } |
Alexis Hetu | a11d03e | 2017-01-27 11:38:59 -0500 | [diff] [blame] | 86 | |
Alexis Hetu | b1031c8 | 2017-01-30 13:46:08 -0500 | [diff] [blame] | 87 | if (is_linux) { |
| 88 | ldflags = [ |
| 89 | "-Wl,--hash-style=both", |
| 90 | "-Wl,--gc-sections", |
| 91 | ] |
Nicolas Capens | 0f7d427 | 2017-06-05 13:24:09 -0400 | [diff] [blame] | 92 | # A bug in the gold linker prevents using ICF on 32-bit (crbug.com/729532) |
| 93 | if (use_gold && target_cpu == "x86") { |
| 94 | ldflags += [ |
| 95 | "-Wl,--icf=none", |
| 96 | ] |
| 97 | } |
Alexis Hetu | b1031c8 | 2017-01-30 13:46:08 -0500 | [diff] [blame] | 98 | } |
Alexis Hetu | 91f10e3 | 2016-06-07 19:53:42 -0400 | [diff] [blame] | 99 | } |
| 100 | } |
| 101 | |
Alexis Hetu | 68f564d | 2016-07-06 17:43:22 -0400 | [diff] [blame] | 102 | group("swiftshader") { |
Alexis Hetu | 996663b | 2016-09-21 13:47:42 -0400 | [diff] [blame] | 103 | data_deps = [ |
| 104 | "src/OpenGL/libGLESv2:swiftshader_libGLESv2", |
| 105 | "src/OpenGL/libEGL:swiftshader_libEGL", |
| 106 | ] |
Alexis Hetu | a6e99c0 | 2016-11-16 13:53:57 -0500 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | group("swiftshader_tests") { |
| 110 | testonly = true |
| 111 | |
| 112 | data_deps = [ |
| 113 | "tests/unittests:swiftshader_unittests", |
| 114 | ] |
Alexis Hetu | d6d10f9 | 2016-11-22 13:47:04 -0500 | [diff] [blame] | 115 | } |