1# Copyright 2016 Google Inc. 2# 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5 6declare_args() { 7} 8 9angle_root = "../externals/angle2" 10 11import("../third_party.gni") 12 13third_party("angle2") { 14 public_include_dirs = [ "$angle_root/include" ] 15 deps = [ 16 ":libEGL", 17 ":libGLESv2", 18 ] 19} 20 21compiler_gypi = exec_script("//gn/gypi_to_gn.py", 22 [ rebase_path("$angle_root/src/compiler.gypi") ], 23 "scope", 24 []) 25 26gles_gypi = exec_script("//gn/gypi_to_gn.py", 27 [ rebase_path("$angle_root/src/libGLESv2.gypi") ], 28 "scope", 29 []) 30 31config("common") { 32 defines = [ 33 "ANGLE_ENABLE_ESSL", 34 "ANGLE_ENABLE_GLSL", 35 "ANGLE_ENABLE_HLSL", 36 "ANGLE_ENABLE_OPENGL", 37 "EGL_EGLEXT_PROTOTYPES", 38 "GL_GLEXT_PROTOTYPES", 39 ] 40 include_dirs = [ 41 "$root_gen_dir/angle2", 42 "$angle_root/include", 43 "$angle_root/src", 44 "$angle_root/src/common/third_party/numerics", 45 "$angle_root/src/third_party/khronos", 46 ] 47 48 assert(is_linux || is_win) # TODO: is_mac? 49 if (is_linux) { 50 defines += [ 51 "ANGLE_USE_X11", 52 "GL_APICALL=__attribute__((visibility(\"default\")))", 53 "EGLAPI=__attribute__((visibility(\"default\")))", 54 ] 55 } else if (is_win) { 56 defines += [ 57 "ANGLE_ENABLE_D3D11", 58 "ANGLE_ENABLE_D3D9", 59 "GL_APICALL=", 60 "EGLAPI=", 61 ] 62 } 63} 64 65copy("commit_id") { 66 sources = [ 67 "$angle_root/src/commit.h", 68 ] 69 outputs = [ 70 "$root_gen_dir/angle2/id/commit.h", 71 ] 72} 73 74shared_library("libGLESv2") { 75 configs += [ ":common" ] 76 configs -= [ "//gn:warnings" ] 77 defines = [ 78 "LIBANGLE_IMPLEMENTATION", 79 "LIBGLESV2_IMPLEMENTATION", 80 ] 81 deps = [ 82 ":commit_id", 83 ] 84 libs = [] 85 sources = rebase_path( 86 compiler_gypi.angle_preprocessor_sources + 87 compiler_gypi.angle_translator_sources + 88 compiler_gypi.angle_translator_essl_sources + 89 compiler_gypi.angle_translator_glsl_sources + 90 compiler_gypi.angle_translator_hlsl_sources + 91 gles_gypi.libangle_sources + gles_gypi.libangle_common_sources + 92 gles_gypi.libangle_image_util_sources + 93 gles_gypi.libglesv2_sources + gles_gypi.libangle_gl_sources, 94 ".", 95 "$angle_root/src") 96 if (!is_win) { 97 sources -= [ "$angle_root/src/libGLESv2/libGLESv2.def" ] 98 } 99 100 if (is_linux) { 101 libs += [ 102 "X11", 103 "Xi", 104 "Xext", 105 ] 106 sources += 107 rebase_path(gles_gypi.libangle_gl_glx_sources, ".", "$angle_root/src") + 108 [ "$angle_root/src/third_party/libXNVCtrl/NVCtrl.c" ] 109 } else if (is_win) { 110 defines += [ 111 # TODO: ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES 112 ] 113 sources += rebase_path(gles_gypi.libangle_gl_wgl_sources + 114 gles_gypi.libangle_d3d_shared_sources + 115 gles_gypi.libangle_d3d9_sources + 116 gles_gypi.libangle_d3d11_sources + 117 gles_gypi.libangle_d3d11_win32_sources, 118 ".", 119 "$angle_root/src") 120 libs += [ 121 "d3d9.lib", 122 "dxguid.lib", 123 "gdi32.lib", 124 "user32.lib", 125 ] 126 deps += [ 127 # TODO: copy_compiler_dll? 128 ] 129 } 130} 131 132shared_library("libEGL") { 133 configs += [ ":common" ] 134 configs -= [ "//gn:warnings" ] 135 defines = [ "LIBEGL_IMPLEMENTATION" ] 136 deps = [ 137 ":libGLESv2", 138 ] 139 sources = rebase_path(gles_gypi.libegl_sources, ".", "$angle_root/src") 140 if (!is_win) { 141 sources -= [ "$angle_root/src/libEGL/libEGL.def" ] 142 } 143} 144