OSDN Git Service

Allow SwiftShader to compile on Fuchsia
[android-x86/external-swiftshader.git] / src / OpenGL / libGLESv2 / 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("../../swiftshader.gni")
16
17 # Need a separate config to ensure the warnings are added to the end.
18 config("swiftshader_libGLESv2_private_config") {
19   defines = [
20     "GL_API=",
21     "GL_GLEXT_PROTOTYPES",
22   ]
23
24   if (is_win) {
25     cflags = [
26       "/wd4201",  # nameless struct/union
27       "/wd4324",  # structure was padded due to alignment specifier
28       "/wd5030",  # attribute is not recognized
29     ]
30
31     defines += [
32       "GL_APICALL=",
33       "GLAPI=",
34     ]
35
36     if (is_clang) {
37       defines += [
38         "__STDC_CONSTANT_MACROS",
39         "__STDC_LIMIT_MACROS",
40       ]
41     }
42   } else {
43     cflags = [ "-Wno-sign-compare" ]
44     if (!is_clang) {
45       cflags += [ "-Wno-unused-but-set-variable" ]
46     }
47
48     defines += [
49       "__STDC_CONSTANT_MACROS",
50       "__STDC_LIMIT_MACROS",
51       "GL_APICALL=__attribute__((visibility(\"default\"))) __attribute__((no_sanitize(\"function\")))",
52       "GLAPI=GL_APICALL",
53     ]
54   }
55 }
56
57 swiftshader_static_library("swiftshader_libGLESv2_static") {
58   deps = [
59     "../../OpenGL/compiler:swiftshader_opengl_compiler",
60     "../../Reactor:swiftshader_reactor",
61     "../../Renderer:swiftshader_renderer",
62   ]
63
64   sources = [
65     "Buffer.cpp",
66     "Context.cpp",
67     "Device.cpp",
68     "Fence.cpp",
69     "Framebuffer.cpp",
70     "IndexDataManager.cpp",
71     "Program.cpp",
72     "Query.cpp",
73     "Renderbuffer.cpp",
74     "ResourceManager.cpp",
75     "Shader.cpp",
76     "Texture.cpp",
77     "TransformFeedback.cpp",
78     "VertexArray.cpp",
79     "VertexDataManager.cpp",
80     "libGLESv2.cpp",
81     "libGLESv3.cpp",
82     "main.cpp",
83     "resource.h",
84     "utilities.cpp",
85   ]
86
87   configs = [ ":swiftshader_libGLESv2_private_config" ]
88
89   include_dirs = [
90     "../../../include",
91     "../..",
92     "..",
93   ]
94 }
95
96 swiftshader_shared_library("swiftshader_libGLESv2") {
97   if (!is_mac && !is_fuchsia) {
98     output_name = "libGLESv2"
99     output_dir = "$root_out_dir/swiftshader"
100   }
101
102   deps = [
103     ":swiftshader_libGLESv2_static",
104     "//build/config:exe_and_shlib_deps",
105   ]
106
107   sources = [
108     "entry_points.cpp",
109     "libGLESv2.def",
110     "libGLESv2.rc",
111   ]
112
113   if (is_win) {
114     ldflags = [ "/DEF:" + rebase_path("libGLESv2.def", root_build_dir) ]
115   } else if (is_mac) {
116     libs = [
117       "CoreFoundation.framework",
118       "IOSurface.framework",
119     ]
120     ldflags = [ "-Wl,-install_name,@rpath/libswiftshader_libGLESv2.dylib" ]
121   } else if (is_linux) {
122     ldflags =
123         [ "-Wl,--version-script=" + rebase_path("libGLESv2.lds", root_build_dir) ]
124   }
125
126   configs = [ ":swiftshader_libGLESv2_private_config" ]
127
128   include_dirs = [
129     "../../../include",
130     "../..",
131     "..",
132   ]
133 }