aboutsummaryrefslogtreecommitdiffhomepage
path: root/third_party/angle2/BUILD.gn
blob: b6bec35c743191267d15e62c7115655b0745c3a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# Copyright 2016 Google Inc.
#
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

declare_args() {
}

angle_root = "../externals/angle2"

import("../third_party.gni")

third_party("angle2") {
  public_include_dirs = [ "$angle_root/include" ]
  deps = [
    ":libEGL",
    ":libGLESv2",
  ]
}

compiler_gypi = exec_script("//gn/gypi_to_gn.py",
                            [ rebase_path("$angle_root/src/compiler.gypi") ],
                            "scope",
                            [])

gles_gypi = exec_script("//gn/gypi_to_gn.py",
                        [ rebase_path("$angle_root/src/libGLESv2.gypi") ],
                        "scope",
                        [])

config("common") {
  defines = [
    "ANGLE_ENABLE_ESSL",
    "ANGLE_ENABLE_GLSL",
    "ANGLE_ENABLE_HLSL",
    "ANGLE_ENABLE_OPENGL",
    "EGL_EGLEXT_PROTOTYPES",
    "GL_GLEXT_PROTOTYPES",
  ]
  include_dirs = [
    "$root_gen_dir/angle2",
    "$angle_root/include",
    "$angle_root/src",
    "$angle_root/src/common/third_party/numerics",
    "$angle_root/src/third_party/khronos",
  ]

  assert(is_linux || is_win)  # TODO: is_mac?
  if (is_linux) {
    defines += [
      "ANGLE_USE_X11",
      "GL_APICALL=__attribute__((visibility(\"default\")))",
      "EGLAPI=__attribute__((visibility(\"default\")))",
    ]
  } else if (is_win) {
    defines += [
      "ANGLE_ENABLE_D3D11",
      "ANGLE_ENABLE_D3D9",
      "GL_APICALL=",
      "EGLAPI=",
    ]
  }
}

copy("commit_id") {
  sources = [
    "$angle_root/src/commit.h",
  ]
  outputs = [
    "$root_gen_dir/angle2/id/commit.h",
  ]
}

shared_library("libGLESv2") {
  configs += [ ":common" ]
  configs -= [ "//gn:warnings" ]
  defines = [
    "LIBANGLE_IMPLEMENTATION",
    "LIBGLESV2_IMPLEMENTATION",
  ]
  deps = [
    ":commit_id",
  ]
  libs = []
  sources = rebase_path(
          compiler_gypi.angle_preprocessor_sources +
              compiler_gypi.angle_translator_sources +
              compiler_gypi.angle_translator_essl_sources +
              compiler_gypi.angle_translator_glsl_sources +
              compiler_gypi.angle_translator_hlsl_sources +
              gles_gypi.libangle_sources + gles_gypi.libangle_common_sources +
              gles_gypi.libangle_image_util_sources +
              gles_gypi.libglesv2_sources + gles_gypi.libangle_gl_sources,
          ".",
          "$angle_root/src")
  if (!is_win) {
    sources -= [ "$angle_root/src/libGLESv2/libGLESv2.def" ]
  }

  if (is_linux) {
    libs += [
      "X11",
      "Xi",
      "Xext",
    ]
    sources +=
        rebase_path(gles_gypi.libangle_gl_glx_sources, ".", "$angle_root/src") +
        [ "$angle_root/src/third_party/libXNVCtrl/NVCtrl.c" ]
  } else if (is_win) {
    defines += [
      # TODO: ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES
    ]
    sources += rebase_path(gles_gypi.libangle_gl_wgl_sources +
                               gles_gypi.libangle_d3d_shared_sources +
                               gles_gypi.libangle_d3d9_sources +
                               gles_gypi.libangle_d3d11_sources +
                               gles_gypi.libangle_d3d11_win32_sources,
                           ".",
                           "$angle_root/src")
    libs += [
      "d3d9.lib",
      "dxguid.lib",
      "gdi32.lib",
      "user32.lib",
    ]
    deps += [
      # TODO: copy_compiler_dll?
    ]
  }
}

shared_library("libEGL") {
  configs += [ ":common" ]
  configs -= [ "//gn:warnings" ]
  defines = [ "LIBEGL_IMPLEMENTATION" ]
  deps = [
    ":libGLESv2",
  ]
  sources = rebase_path(gles_gypi.libegl_sources, ".", "$angle_root/src")
  if (!is_win) {
    sources -= [ "$angle_root/src/libEGL/libEGL.def" ]
  }
}