OSDN Git Service

Fix symbol visibility for preemption.
[android-x86/external-swiftshader.git] / src / OpenGL / libEGL / 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/toolchain/toolchain.gni")
16
17 # Need a separate config to ensure the warnings are added to the end.
18 config("swiftshader_libEGL_private_config") {
19   defines = [ "EGL_EGLEXT_PROTOTYPES" ]
20
21   if (is_win) {
22     cflags = [
23       "/wd4201",  # nameless struct/union
24       "/wd4065",  # switch statement contains 'default' but no 'case' labels
25       "/wd5030",  # attribute is not recognized
26     ]
27
28     defines += [
29       "EGLAPI=",
30       "LIBEGL_EXPORTS",
31     ]
32   } else {
33     cflags = [ "-Wno-sign-compare" ]
34     if (!is_clang) {
35       cflags += [ "-Wno-unused-but-set-variable" ]
36     }
37
38     defines += [
39       "LOG_TAG=\"swiftshader_libEGL\"",
40       "EGLAPI=__attribute__((visibility(\"default\")))",
41     ]
42   }
43 }
44
45 shared_library("swiftshader_libEGL") {
46   if (!is_mac) {
47     output_name = "libEGL"
48     output_dir = "$root_out_dir/swiftshader"
49   }
50
51   deps = [
52     "//build/config:exe_and_shlib_deps",
53   ]
54
55   sources = [
56     "../common/Object.cpp",
57     "Config.cpp",
58     "Display.cpp",
59     "EGLSurface.cpp",
60     "libEGL.cpp",
61     "libEGL.def",
62     "libEGL.rc",
63     "main.cpp",
64     "resource.h",
65   ]
66
67   if (is_debug) {
68     sources += [ "../common/debug.cpp" ]
69   }
70
71   if (is_mac) {
72     sources += [ "OSXUtils.mm" ]
73     libs = [
74       "Quartz.framework",
75       "Cocoa.framework",
76     ]
77   } else if (is_win) {
78     configs -= [ "//build/config/win:unicode" ]
79     ldflags = [ "/DEF:" + rebase_path("libGLESv2.def", root_build_dir) ]
80   } else if (is_linux) {
81     sources += [
82       "../../Main/libX11.cpp",
83     ]
84     ldflags =
85         [ "-Wl,--version-script=" + rebase_path("exports.map", root_build_dir) ]
86   }
87
88   if (use_thin_lto) {
89     # https://crbug.com/686980
90     # This target relies on the linker to be smart and garbage collect unused symbols.
91     # It is not the case for LLD + ThinLTO, so we have to use this ugly workaround.
92     cflags = [
93       "-Xclang",
94       "-fno-lto-unit",
95       "-fno-whole-program-vtables",
96       "-fno-sanitize=cfi",
97     ]
98   }
99
100   configs -= [ "//build/config/compiler:chromium_code" ]
101   configs += [
102     "//build/config/compiler:no_chromium_code",
103     "//third_party/swiftshader:swiftshader_config",
104     ":swiftshader_libEGL_private_config",
105   ]
106
107   include_dirs = [
108     "../../../include",
109     "../..",
110     "..",
111   ]
112 }