OSDN Git Service

Disable surface and swapchain support for Android
[android-x86/external-swiftshader.git] / BUILD.gn
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
15 import("//build/config/c++/c++.gni")
16 import("//build/config/compiler/compiler.gni")
17 import("//build/config/mips.gni")
18
19 config("swiftshader_config") {
20   defines = []
21
22   if (is_win) {
23     cflags = [
24       "/GS",  # Detects some buffer overruns
25       "/Zc:wchar_t",
26       "/EHs-c-",  # Disable C++ exceptions
27       "/nologo",
28       "/Gd",  # Default calling convention
29     ]
30
31     if (!use_custom_libcxx) {
32       # Disable EH usage in STL headers.
33       # libc++ uses a predefined macro to control whether to use exceptions, so
34       # defining this macro is unnecessary. Defining _HAS_EXCEPTIONS to 0 also
35       # breaks libc++ because it depends on MSVC headers that only provide
36       # certain declarations if _HAS_EXCEPTIONS is 1.
37       defines += [
38         "_HAS_EXCEPTIONS=0",
39       ]
40     }
41
42     defines += [
43       "_CRT_SECURE_NO_DEPRECATE",
44       "NOMINMAX",
45       "_WINDLL",
46       "NO_SANITIZE_FUNCTION=",
47     ]
48
49     if (!is_debug) {
50       defines += [ "ANGLE_DISABLE_TRACE" ]
51     }
52   } else {
53     cflags = [
54       "-std=c++11",
55       "-fno-exceptions",
56       "-fno-operator-names",
57     ]
58
59     defines += [
60       "__STDC_CONSTANT_MACROS",
61       "__STDC_LIMIT_MACROS",
62       "NO_SANITIZE_FUNCTION=__attribute__((no_sanitize(\"function\")))",
63     ]
64
65     if (is_debug) {
66       cflags += [
67         "-g",
68         "-g3",
69       ]
70     } else {  # Release
71       # All Release builds use function/data sections to make the shared libraries smaller
72       cflags += [
73         "-ffunction-sections",
74         "-fdata-sections",
75         "-fomit-frame-pointer",
76         "-Os",
77       ]
78
79       defines += [
80         "ANGLE_DISABLE_TRACE",
81         "NDEBUG",
82       ]
83     }
84
85     if (target_cpu == "x64") {  # 64 bit version
86       cflags += [
87         "-m64",
88         "-fPIC",
89         "-march=x86-64",
90         "-mtune=generic",
91       ]
92     } else if (target_cpu == "x86") {  # 32 bit version
93       cflags += [
94         "-m32",
95         "-msse2",
96         "-mfpmath=sse",
97         "-march=pentium4",
98         "-mtune=generic",
99       ]
100     } else if (target_cpu == "mipsel" && current_cpu == target_cpu) {
101       cflags += [
102         "-march=mipsel",
103         "-fPIC",
104         "-mhard-float",
105         "-mfp32",
106       ]
107       if (mips_arch_variant == "r1") {
108         cflags += [
109           "-mcpu=mips32",
110         ]
111       } else {
112         cflags += [
113           "-mcpu=mips32r2",
114         ]
115       }
116     } else if (target_cpu == "mips64el" && current_cpu == target_cpu) {
117       cflags += [
118         "-march=mips64el",
119         "-mcpu=mips64r2",
120         "-mabi=64",
121         "-fPIC",
122       ]
123     }
124
125     if (is_linux) {
126       ldflags = [ "-Wl,--gc-sections" ]
127
128       if (target_cpu == "mipsel") {
129         ldflags += [
130           "-Wl,--hash-style=sysv",
131         ]
132         if (mips_arch_variant == "r1") {
133           ldflags += [
134             "-mips32",
135           ]
136         } else {
137           ldflags += [
138             "-mips32r2",
139           ]
140         }
141       } else if (target_cpu == "mips64el") {
142         ldflags += [
143           "-Wl,--hash-style=sysv",
144           "-mips64r2",
145         ]
146       } else {
147         ldflags += [ "-Wl,--hash-style=both" ]
148       }
149
150       # A bug in the gold linker prevents using ICF on 32-bit (crbug.com/729532)
151       if (use_gold && (target_cpu == "x86" || target_cpu == "mipsel")) {
152         ldflags += [ "-Wl,--icf=none" ]
153       }
154     }
155   }
156 }
157
158 source_set("vertex_routine_fuzzer") {
159   sources = [
160     "tests/fuzzers/VertexRoutineFuzzer.cpp"
161   ]
162   if (is_win) {
163     cflags = [
164       "/wd4201",  # nameless struct/union
165       "/wd4065",  # switch statement contains 'default' but no 'case' labels
166       "/wd5030",  # attribute is not recognized
167     ]
168   }
169   include_dirs = [
170     "src/",
171   ]
172   deps = [
173     "src/OpenGL/libGLESv2:swiftshader_libGLESv2_static",
174   ]
175 }
176
177 group("swiftshader") {
178   data_deps = [
179     "src/OpenGL/libGLESv2:swiftshader_libGLESv2",
180     "src/OpenGL/libEGL:swiftshader_libEGL",
181   ]
182 }
183
184 group("swiftshader_tests") {
185   testonly = true
186
187   data_deps = [
188     "tests/GLESUnitTests:swiftshader_unittests",
189   ]
190 }