OSDN Git Service

Fix Visual Studio 2017 compilation.
[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 config("swiftshader_config") {
16   defines = [ "STRICT_CONFORMANCE" ]  # Disables OpenGL ES 3.0
17
18   if (is_win) {
19     cflags = [
20       "/GS",  # Detects some buffer overruns
21       "/Zc:wchar_t",
22       "/EHsc",
23       "/nologo",
24       "/Gd",  # Default calling convention
25     ]
26
27     defines += [
28       "_CRT_SECURE_NO_DEPRECATE",
29       "NOMINMAX",
30       "_WINDLL",
31     ]
32
33     if (is_debug) {
34       cflags += [ "/RTC1" ]  # Run-Time Error Checks
35     } else {
36       defines += [ "ANGLE_DISABLE_TRACE" ]
37     }
38   } else {
39     cflags = [
40       "-std=c++11",
41       "-Wall",
42       "-fexceptions",
43       "-fno-operator-names",
44     ]
45
46     defines += [
47       "__STDC_CONSTANT_MACROS",
48       "__STDC_LIMIT_MACROS",
49     ]
50
51     if (is_debug) {
52       cflags += [
53         "-g",
54         "-g3",
55       ]
56     } else {  # Release
57       # All Release builds use function/data sections to make the shared libraries smaller
58       cflags += [
59         "-ffunction-sections",
60         "-fdata-sections",
61         "-fomit-frame-pointer",
62         "-O2",
63         "-Os",
64       ]
65
66       defines += [
67         "ANGLE_DISABLE_TRACE",
68         "NDEBUG",
69       ]
70     }
71
72     if (target_cpu == "x64") {  # 64 bit version
73       cflags += [
74         "-m64",
75         "-fPIC",
76         "-march=core2",
77       ]
78     } else {  # 32 bit version
79       cflags += [
80         "-m32",
81         "-msse2",
82         "-march=i686",
83       ]
84     }
85
86     if (is_linux) {
87       ldflags = [
88         "-Wl,--hash-style=both",
89         "-Wl,--gc-sections",
90       ]
91     }
92   }
93 }
94
95 group("swiftshader") {
96   data_deps = [
97     "src/OpenGL/libGLESv2:swiftshader_libGLESv2",
98     "src/OpenGL/libEGL:swiftshader_libEGL",
99   ]
100 }
101
102 group("swiftshader_tests") {
103   testonly = true
104
105   data_deps = [
106     "tests/unittests:swiftshader_unittests",
107   ]
108 }