Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / angle / BUILD.gn
1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 if (is_win) {
6   # Only needed on Windows.
7   gles_gypi = exec_script(
8       "//build/gypi_to_gn.py",
9       [ rebase_path("src/libGLESv2.gypi") ],
10       "scope",
11       [ "src/libGLESv2.gypi" ])
12
13   egl_gypi = exec_script(
14       "//build/gypi_to_gn.py",
15       [ rebase_path("src/libEGL.gypi") ],
16       "scope",
17       [ "src/libEGL.gypi" ])
18 }
19
20 compiler_gypi = exec_script(
21     "//build/gypi_to_gn.py",
22     [ rebase_path("src/compiler.gypi") ],
23     "scope",
24     [ "src/compiler.gypi" ])
25
26 # This config is exported to dependent targets (and also applied to internal
27 # ones).
28 config("external_config") {
29   include_dirs = [
30     "include",
31   ]
32 }
33
34 # This config is applied to internal Angle targets (not pushed to dependents).
35 config("internal_config") {
36   include_dirs = [
37     "include",
38     "src",
39   ]
40 }
41
42 component("translator") {
43   sources = [
44     "src/compiler/translator/ShaderLang.cpp",
45     "src/compiler/translator/ShaderVars.cpp",
46   ]
47
48   defines = [ "ANGLE_TRANSLATOR_IMPLEMENTATION" ]
49
50   configs -= [ "//build/config/compiler:chromium_code" ]
51   configs += [
52     ":internal_config",
53     "//build/config/compiler:no_chromium_code",
54   ]
55
56   deps = [
57     ":translator_lib",
58   ]
59   forward_dependent_configs_from = [ ":translator_lib" ]
60 }
61
62 # Holds the shared includes so we only need to list them once.
63 source_set("includes") {
64   sources = [
65     "include/EGL/egl.h",
66     "include/EGL/eglext.h",
67     "include/EGL/eglplatform.h",
68     "include/GLES2/gl2.h",
69     "include/GLES2/gl2ext.h",
70     "include/GLES2/gl2platform.h",
71     "include/GLES3/gl3.h",
72     "include/GLES3/gl3ext.h",
73     "include/GLES3/gl3platform.h",
74     "include/GLSLANG/ShaderLang.h",
75     "include/KHR/khrplatform.h",
76   ]
77 }
78
79 static_library("preprocessor") {
80   sources = rebase_path(compiler_gypi.angle_preprocessor_sources, ".", "src")
81
82   configs -= [ "//build/config/compiler:chromium_code" ]
83   configs += [
84     ":internal_config",
85     "//build/config/compiler:no_chromium_code",
86   ]
87 }
88
89 config("translator_static_config") {
90   defines = [ "ANGLE_TRANSLATOR_STATIC" ]
91 }
92
93 static_library("translator_lib") {
94   sources = rebase_path(compiler_gypi.angle_translator_lib_sources, ".", "src")
95
96   configs -= [ "//build/config/compiler:chromium_code" ]
97   configs += [
98     ":internal_config",
99     ":translator_static_config",
100     "//build/config/compiler:no_chromium_code",
101   ]
102   direct_dependent_configs = [ ":external_config" ]
103
104   deps = [
105     ":includes",
106     ":preprocessor",
107   ]
108 }
109
110 static_library("translator_static") {
111   sources = [
112     "src/compiler/translator/ShaderLang.cpp",
113     "src/compiler/translator/ShaderVars.cpp",
114   ]
115
116   configs -= [ "//build/config/compiler:chromium_code" ]
117   configs += [
118     ":internal_config",
119     "//build/config/compiler:no_chromium_code",
120   ]
121   direct_dependent_configs = [ ":translator_static_config" ]
122
123   deps = [
124     ":translator_lib",
125   ]
126   forward_dependent_configs_from = [ ":translator_lib" ]
127 }
128
129 config("commit_id_config") {
130   include_dirs = [ "$root_gen_dir/angle" ]
131 }
132
133 action("commit_id") {
134   script = "src/commit_id.py"
135
136   output_file = "$root_gen_dir/angle/id/commit.h"
137   outputs = [ output_file ]
138
139   args = [
140     "gen",
141     rebase_path(".", root_build_dir),
142     rebase_path(output_file, root_build_dir),
143   ]
144
145   direct_dependent_configs = [ ":commit_id_config" ]
146 }
147
148 if (is_win) {
149   angle_enable_d3d9 = true
150   angle_enable_d3d11 = true
151
152   shared_library("libGLESv2") {
153     sources = rebase_path(gles_gypi.angle_libglesv2_sources, ".", "src")
154
155     defines = [
156       "ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES={ " +
157         "\"d3dcompiler_46.dll\", \"d3dcompiler_43.dll\" }",
158       "GL_APICALL=",
159       "GL_GLEXT_PROTOTYPES=",
160       "EGLAPI=",
161     ]
162     libs = []
163
164     # Shared D3dD sources.
165     if (angle_enable_d3d9 || angle_enable_d3d11) {
166       sources += rebase_path(gles_gypi.angle_d3d_shared_sources, ".", "src")
167     }
168
169     if (angle_enable_d3d9) {
170       sources += rebase_path(gles_gypi.angle_d3d9_sources, ".", "src")
171       defines += [ "ANGLE_ENABLE_D3D9" ]
172       libs += [ "d3d9.lib" ]
173     }
174
175     if (angle_enable_d3d11) {
176       sources += rebase_path(gles_gypi.angle_d3d11_sources, ".", "src")
177       defines += [ "ANGLE_ENABLE_D3D11" ]
178       libs += [ "dxguid.lib" ]
179     }
180
181     if (is_debug) {
182       defines += [ "ANGLE_ENABLE_PERF" ]
183       libs += [ "d3d9.lib" ]
184     }
185
186     configs -= [ "//build/config/compiler:chromium_code" ]
187     configs += [
188       ":internal_config",
189       "//build/config/compiler:no_chromium_code",
190     ]
191
192     include_dirs = [ "src/libGLESv2" ]
193
194     deps = [
195       ":commit_id",
196       ":includes",
197       ":translator",
198       #":copy_compiler_dll",  TODO(GYP)
199     ]
200   }
201
202   shared_library("libEGL") {
203     sources = rebase_path(egl_gypi.angle_libegl_sources, ".", "src")
204
205     defines = [
206       "GL_APICALL=",
207       "GL_GLEXT_PROTOTYPES=",
208       "EGLAPI=",
209     ]
210
211     configs -= [ "//build/config/compiler:chromium_code" ]
212     configs += [
213       ":internal_config",
214       "//build/config/compiler:no_chromium_code",
215     ]
216
217     if (is_debug) {
218       defines += [ "ANGLE_ENABLE_PERF" ]
219     }
220
221     include_dirs = [ "src/libGLESv2" ]
222     libs = [ "d3d9.lib" ]
223
224     deps = [
225       ":commit_id",
226       ":includes",
227       ":libGLESv2",
228     ]
229   }
230 }  # is_win