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/base", 45 "$angle_root/src/third_party/khronos", 46 ] 47 cflags_cc = [] 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 "GL_API=__attribute__((visibility(\"default\")))", 54 "EGLAPI=__attribute__((visibility(\"default\")))", 55 ] 56 cflags_cc += [ "-std=c++14" ] 57 } else if (is_win) { 58 defines += [ 59 "ANGLE_ENABLE_D3D11", 60 "ANGLE_ENABLE_D3D9", 61 "GL_APICALL=", 62 "GL_API=", 63 "EGLAPI=", 64 ] 65 66 # Allow noexcept, even though we build without exceptions 67 cflags_cc += [ "/wd4577" ] 68 if (is_clang) { 69 # utilities.cpp includes an 'unsigned long' <= UINT_MAX check 70 cflags_cc += [ "-Wno-tautological-constant-compare" ] 71 } 72 } 73} 74 75copy("commit_id") { 76 sources = [ 77 "$angle_root/src/commit.h", 78 ] 79 outputs = [ 80 "$root_gen_dir/angle2/id/commit.h", 81 ] 82} 83 84shared_library("libGLESv2") { 85 configs += [ ":common" ] 86 configs -= [ "//gn:warnings" ] 87 defines = [ 88 "LIBANGLE_IMPLEMENTATION", 89 "LIBGLESV2_IMPLEMENTATION", 90 ] 91 deps = [ 92 ":commit_id", 93 ] 94 libs = [] 95 sources = rebase_path( 96 compiler_gypi.angle_preprocessor_sources + 97 compiler_gypi.angle_translator_sources + 98 compiler_gypi.angle_translator_essl_sources + 99 compiler_gypi.angle_translator_glsl_sources + 100 compiler_gypi.angle_translator_hlsl_sources + 101 gles_gypi.libangle_sources + gles_gypi.libangle_common_sources + 102 gles_gypi.libangle_image_util_sources + 103 gles_gypi.libglesv2_sources + gles_gypi.libangle_gl_sources, 104 ".", 105 "$angle_root/src") 106 if (!is_win) { 107 sources -= [ "$angle_root/src/libGLESv2/libGLESv2.def" ] 108 } 109 110 if (is_linux) { 111 libs += [ 112 "X11", 113 "Xi", 114 "Xext", 115 ] 116 sources += 117 rebase_path(gles_gypi.libangle_gl_glx_sources, ".", "$angle_root/src") + 118 [ "$angle_root/src/third_party/libXNVCtrl/NVCtrl.c" ] 119 } else if (is_win) { 120 defines += [ 121 # TODO: ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES 122 ] 123 sources += rebase_path(gles_gypi.libangle_gl_wgl_sources + 124 gles_gypi.libangle_d3d_shared_sources + 125 gles_gypi.libangle_d3d9_sources + 126 gles_gypi.libangle_d3d11_sources + 127 gles_gypi.libangle_d3d11_win32_sources, 128 ".", 129 "$angle_root/src") 130 libs += [ 131 "d3d9.lib", 132 "dxguid.lib", 133 "gdi32.lib", 134 "user32.lib", 135 ] 136 deps += [ 137 # TODO: copy_compiler_dll? 138 ] 139 } 140} 141 142shared_library("libEGL") { 143 configs += [ ":common" ] 144 configs -= [ "//gn:warnings" ] 145 defines = [ "LIBEGL_IMPLEMENTATION" ] 146 deps = [ 147 ":libGLESv2", 148 ] 149 sources = rebase_path(gles_gypi.libegl_sources, ".", "$angle_root/src") 150 if (!is_win) { 151 sources -= [ "$angle_root/src/libEGL/libEGL.def" ] 152 } 153} 154