blob: 0ef68d9d8721c9550a00f17a1c4a13f3c6ba54d7 [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 Capensd51e2162017-06-05 13:59:55 -040015import("//build/config/compiler/compiler.gni")
16
Alexis Hetu91f10e32016-06-07 19:53:42 -040017config("swiftshader_config") {
Alexis Hetu0def1022017-08-16 17:15:48 -040018 defines = []
Alexis Hetu2ddef882017-03-14 15:11:15 -040019
Alexis Hetu03b67af2016-08-31 17:25:40 -040020 if (is_win) {
21 cflags = [
Alexis Hetud6d10f92016-11-22 13:47:04 -050022 "/GS", # Detects some buffer overruns
Alexis Hetu03b67af2016-08-31 17:25:40 -040023 "/Zc:wchar_t",
Alexis Hetu03b67af2016-08-31 17:25:40 -040024 "/EHsc",
25 "/nologo",
Alexis Hetud6d10f92016-11-22 13:47:04 -050026 "/Gd", # Default calling convention
Alexis Hetu2ddef882017-03-14 15:11:15 -040027 ]
28
29 defines += [
30 "_CRT_SECURE_NO_DEPRECATE",
31 "NOMINMAX",
32 "_WINDLL",
Nicolas Capens506cc5e2017-07-24 11:30:55 -040033 "NO_SANITIZE_FUNCTION=",
Alexis Hetu03b67af2016-08-31 17:25:40 -040034 ]
Alexis Hetuc55dd842017-08-08 08:31:13 -040035
Robert Liaoe8d42ae2017-08-14 10:51:58 -070036 if (!is_debug) {
Alexis Hetuc55dd842017-08-08 08:31:13 -040037 defines += [ "ANGLE_DISABLE_TRACE" ]
38 }
Alexis Hetu03b67af2016-08-31 17:25:40 -040039 } else {
Alexis Hetua11d03e2017-01-27 11:38:59 -050040 cflags = [
41 "-std=c++11",
Alexis Hetu2c0546d2017-05-24 11:16:26 -040042 "-fno-exceptions",
Alexis Hetua11d03e2017-01-27 11:38:59 -050043 "-fno-operator-names",
Alexis Hetu2ddef882017-03-14 15:11:15 -040044 ]
45
46 defines += [
47 "__STDC_CONSTANT_MACROS",
48 "__STDC_LIMIT_MACROS",
Nicolas Capens506cc5e2017-07-24 11:30:55 -040049 "NO_SANITIZE_FUNCTION=__attribute__((no_sanitize(\"function\")))",
Alexis Hetua11d03e2017-01-27 11:38:59 -050050 ]
Alexis Hetu91f10e32016-06-07 19:53:42 -040051
Alexis Hetuc55dd842017-08-08 08:31:13 -040052 if (is_debug) {
53 cflags += [
54 "-g",
55 "-g3",
56 ]
57 } else { # Release
58 # All Release builds use function/data sections to make the shared libraries smaller
59 cflags += [
60 "-ffunction-sections",
61 "-fdata-sections",
62 "-fomit-frame-pointer",
63 "-Os",
64 ]
65
66 defines += [
67 "ANGLE_DISABLE_TRACE",
68 "NDEBUG",
69 ]
70 }
71
Alexis Hetud6d10f92016-11-22 13:47:04 -050072 if (target_cpu == "x64") { # 64 bit version
Alexis Hetu91f10e32016-06-07 19:53:42 -040073 cflags += [
74 "-m64",
75 "-fPIC",
Alexis Hetua11d03e2017-01-27 11:38:59 -050076 "-march=core2",
Alexis Hetu91f10e32016-06-07 19:53:42 -040077 ]
Alexis Hetud6d10f92016-11-22 13:47:04 -050078 } else { # 32 bit version
Alexis Hetua11d03e2017-01-27 11:38:59 -050079 cflags += [
80 "-m32",
81 "-msse2",
82 "-march=i686",
83 ]
Alexis Hetu91f10e32016-06-07 19:53:42 -040084 }
Alexis Hetua11d03e2017-01-27 11:38:59 -050085
Alexis Hetub1031c82017-01-30 13:46:08 -050086 if (is_linux) {
87 ldflags = [
88 "-Wl,--hash-style=both",
89 "-Wl,--gc-sections",
90 ]
Alexis Hetu9441b072017-08-02 08:40:37 -040091
Nicolas Capens0f7d4272017-06-05 13:24:09 -040092 # A bug in the gold linker prevents using ICF on 32-bit (crbug.com/729532)
93 if (use_gold && target_cpu == "x86") {
Alexis Hetu9441b072017-08-02 08:40:37 -040094 ldflags += [ "-Wl,--icf=none" ]
Nicolas Capens0f7d4272017-06-05 13:24:09 -040095 }
Alexis Hetub1031c82017-01-30 13:46:08 -050096 }
Alexis Hetu91f10e32016-06-07 19:53:42 -040097 }
98}
99
Alexis Hetu68f564d2016-07-06 17:43:22 -0400100group("swiftshader") {
Alexis Hetu996663b2016-09-21 13:47:42 -0400101 data_deps = [
102 "src/OpenGL/libGLESv2:swiftshader_libGLESv2",
103 "src/OpenGL/libEGL:swiftshader_libEGL",
104 ]
Alexis Hetua6e99c02016-11-16 13:53:57 -0500105}
106
107group("swiftshader_tests") {
108 testonly = true
109
110 data_deps = [
111 "tests/unittests:swiftshader_unittests",
112 ]
Alexis Hetud6d10f92016-11-22 13:47:04 -0500113}