OSDN Git Service

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