Edit

kc3-lang/angle/BUILD.gn

Branch :

  • Show log

    Commit

  • Author : Jamie Madill
    Date : 2016-12-22 15:58:21
    Hash : 192745a7
    Message : Add varying packing validation for WebGL. This CL moves the varying packing from the D3D layer up to Program. This is necessary for WebGL validation, and gives us consistency for the various back-ends. There may be some additional cleanup work on the VaryingPacking class, because it does some work that is D3D- specific. WebGL requires strict varying packing. Instead of allowing success unconditionally, it's an explicit error to succeed to pack a set of varyings that the sample algorithm would fail to pack. Introduce a new packing mode option to the varying packing class to handle this different packing style, while keeping our old more relaxed packing method for ES code. BUG=angleproject:1675 Change-Id: I674ae685ba573cc2ad7d9dfb7441efa8cb2d55fc Reviewed-on: https://chromium-review.googlesource.com/423254 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org>

  • BUILD.gn
  • # Copyright 2014-2015 The Chromium Authors. All rights reserved.
    # Use of this source code is governed by a BSD-style license that can be
    # found in the LICENSE file.
    
    # import the use_x11 variable
    import("//build/config/dcheck_always_on.gni")
    import("//build/config/linux/pkg_config.gni")
    import("//build/config/ui.gni")
    import("//testing/libfuzzer/fuzzer_test.gni")
    import("//third_party/angle/gni/angle.gni")
    import("//ui/ozone/ozone.gni")
    
    if (ozone_platform_gbm) {
      pkg_config("libdrm") {
        packages = [ "libdrm" ]
      }
    }
    
    angle_git_is_present = exec_script("src/commit_id.py",
                                       [
                                         "check",
                                         rebase_path(".", root_build_dir),
                                       ],
                                       "value")
    
    angle_use_commit_id = angle_git_is_present == 1
    
    gles_gypi = exec_script("//build/gypi_to_gn.py",
                            [ rebase_path("src/libGLESv2.gypi") ],
                            "scope",
                            [ "src/libGLESv2.gypi" ])
    
    compiler_gypi = exec_script("//build/gypi_to_gn.py",
                                [ rebase_path("src/compiler.gypi") ],
                                "scope",
                                [ "src/compiler.gypi" ])
    
    # This config is exported to dependent targets (and also applied to internal
    # ones).
    config("external_config") {
      include_dirs = [ "include" ]
    }
    
    # This config is applied to internal Angle targets (not pushed to dependents).
    config("internal_config") {
      include_dirs = [
        "include",
        "src",
      ]
    }
    
    config("extra_warnings") {
      # Enable more default warnings on Windows.
      if (is_win) {
        cflags = [
          "/we4244",  # Conversion: possible loss of data.
          "/we4456",  # Variable shadowing.
          "/we4458",  # declaration hides class member.
        ]
      }
    }
    
    if (is_win) {
      copy("copy_compiler_dll") {
        sources = [
          "$windows_sdk_path/Redist/D3D/$target_cpu/d3dcompiler_47.dll",
        ]
        outputs = [
          "$root_out_dir/d3dcompiler_47.dll",
        ]
      }
    }
    
    angle_undefine_configs = [ "//build/config/compiler:default_include_dirs" ]
    
    # Holds the shared includes so we only need to list them once.
    source_set("includes") {
      sources = [
        "include/EGL/egl.h",
        "include/EGL/eglext.h",
        "include/EGL/eglplatform.h",
        "include/GLES2/gl2.h",
        "include/GLES2/gl2ext.h",
        "include/GLES2/gl2platform.h",
        "include/GLES3/gl3.h",
        "include/GLES3/gl31.h",
        "include/GLES3/gl32.h",
        "include/GLES3/gl3platform.h",
        "include/GLSLANG/ShaderLang.h",
        "include/KHR/khrplatform.h",
      ]
    }
    
    static_library("preprocessor") {
      sources = rebase_path(compiler_gypi.angle_preprocessor_sources, ".", "src")
    
      configs -= angle_undefine_configs
      configs += [ ":internal_config" ]
    
      public_deps = [
        ":angle_common",
      ]
    }
    
    config("translator_disable_pool_alloc") {
      defines = [ "ANGLE_TRANSLATOR_DISABLE_POOL_ALLOC" ]
    }
    
    config("debug_annotations_config") {
      if (is_debug) {
        defines = [ "ANGLE_ENABLE_DEBUG_ANNOTATIONS" ]
      }
    }
    
    config("angle_release_asserts_config") {
      if (dcheck_always_on) {
        defines = [ "ANGLE_ENABLE_RELEASE_ASSERTS" ]
      }
    }
    
    config("angle_common_config") {
      include_dirs = [ "src/common/third_party/numerics" ]
    }
    
    static_library("angle_common") {
      sources = rebase_path(gles_gypi.libangle_common_sources, ".", "src")
    
      configs -= angle_undefine_configs
      configs += [
        ":angle_common_config",
        ":debug_annotations_config",
        ":extra_warnings",
        ":internal_config",
      ]
    
      public_deps = [
        ":commit_id",
      ]
      public_configs = [
        ":angle_release_asserts_config",
        ":angle_common_config",
      ]
    }
    
    config("angle_image_util_config") {
      include_dirs = [
        "include",
        "src",
      ]
    }
    
    static_library("angle_image_util") {
      sources = rebase_path(gles_gypi.libangle_image_util_sources, ".", "src")
    
      configs -= angle_undefine_configs
      configs += [ ":internal_config" ]
    
      public_configs = [ ":angle_image_util_config" ]
    
      public_deps = [
        ":angle_common",
      ]
    }
    
    static_library("translator") {
      sources = rebase_path(compiler_gypi.angle_translator_sources, ".", "src")
      defines = []
    
      if (angle_enable_essl || use_libfuzzer) {
        sources +=
            rebase_path(compiler_gypi.angle_translator_essl_sources, ".", "src")
        defines += [ "ANGLE_ENABLE_ESSL" ]
      }
    
      if (angle_enable_glsl || use_libfuzzer) {
        sources +=
            rebase_path(compiler_gypi.angle_translator_glsl_sources, ".", "src")
        defines += [ "ANGLE_ENABLE_GLSL" ]
      }
    
      if (angle_enable_hlsl || use_libfuzzer) {
        sources +=
            rebase_path(compiler_gypi.angle_translator_hlsl_sources, ".", "src")
        defines += [ "ANGLE_ENABLE_HLSL" ]
      }
      configs -= angle_undefine_configs
      configs += [ ":internal_config" ]
      public_configs = [ ":external_config" ]
      if (use_libfuzzer) {
        all_dependent_configs = [ ":translator_disable_pool_alloc" ]
      }
    
      deps = [
        ":includes",
        ":preprocessor",
      ]
    
      public_deps = [
        ":angle_common",
      ]
    
      if (is_win) {
        # Necessary to suppress some system header xtree warnigns in Release.
        # For some reason this warning doesn't get triggered in Chromium
        cflags = [ "/wd4718" ]
      }
    }
    
    source_set("translator_fuzzer") {
      sources = [
        "src/compiler/fuzz/translator_fuzzer.cpp",
      ]
    
      include_dirs = [
        "include",
        "src",
      ]
    
      deps = [
        ":translator",
      ]
    }
    
    config("commit_id_config") {
      include_dirs = [ "$root_gen_dir/angle" ]
    }
    
    commit_id_output_file = "$root_gen_dir/angle/id/commit.h"
    if (angle_use_commit_id) {
      action("commit_id") {
        script = "src/commit_id.py"
        outputs = [
          commit_id_output_file,
        ]
    
        args = [
          "gen",
          rebase_path(".", root_build_dir),
          rebase_path(commit_id_output_file, root_build_dir),
        ]
    
        public_configs = [ ":commit_id_config" ]
      }
    } else {
      copy("commit_id") {
        sources = [
          "src/commit.h",
        ]
        outputs = [
          commit_id_output_file,
        ]
        public_configs = [ ":commit_id_config" ]
      }
    }
    
    config("libANGLE_config") {
      cflags = []
      defines = []
      if (angle_enable_d3d9) {
        defines += [ "ANGLE_ENABLE_D3D9" ]
      }
      if (angle_enable_d3d11) {
        defines += [ "ANGLE_ENABLE_D3D11" ]
      }
      if (angle_enable_gl) {
        defines += [ "ANGLE_ENABLE_OPENGL" ]
        if (use_x11) {
          defines += [ "ANGLE_USE_X11" ]
        }
      }
      if (angle_enable_vulkan) {
        defines += [ "ANGLE_ENABLE_VULKAN" ]
      }
      if (angle_enable_null) {
        defines += [ "ANGLE_ENABLE_NULL" ]
      }
      defines += [
        "GL_GLEXT_PROTOTYPES",
        "EGL_EGLEXT_PROTOTYPES",
        "LIBANGLE_IMPLEMENTATION",
      ]
    
      if (is_win) {
        defines += [ "GL_APICALL=" ]
      } else {
        defines += [ "GL_APICALL=__attribute__((visibility(\"default\")))" ]
      }
      if (is_win) {
        cflags += [ "/wd4530" ]  # C++ exception handler used, but unwind semantics are not enabled.
      }
    }
    
    static_library("libANGLE") {
      sources = rebase_path(gles_gypi.libangle_sources, ".", "src")
    
      include_dirs = []
      libs = []
      defines = []
      public_deps = [
        ":angle_common",
      ]
      deps = [
        ":angle_image_util",
        ":commit_id",
        ":includes",
        ":translator",
      ]
    
      # Shared D3D sources.
      if (angle_enable_d3d9 || angle_enable_d3d11) {
        sources += rebase_path(gles_gypi.libangle_d3d_shared_sources, ".", "src")
    
        defines += [ "ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES={ " + "\"d3dcompiler_47.dll\", \"d3dcompiler_46.dll\", \"d3dcompiler_43.dll\" }" ]
      }
    
      if (angle_enable_d3d9) {
        sources += rebase_path(gles_gypi.libangle_d3d9_sources, ".", "src")
        libs += [ "d3d9.lib" ]
      }
    
      if (angle_enable_d3d11) {
        sources += rebase_path(gles_gypi.libangle_d3d11_sources, ".", "src")
        sources += rebase_path(gles_gypi.libangle_d3d11_win32_sources, ".", "src")
        libs += [ "dxguid.lib" ]
      }
    
      if (angle_enable_gl) {
        sources += rebase_path(gles_gypi.libangle_gl_sources, ".", "src")
        include_dirs += [ "src/third_party/khronos" ]
    
        if (is_win) {
          sources += rebase_path(gles_gypi.libangle_gl_wgl_sources, ".", "src")
        }
        if (use_x11) {
          sources += rebase_path(gles_gypi.libangle_gl_glx_sources, ".", "src")
          deps += [ "src/third_party/libXNVCtrl:libXNVCtrl" ]
          libs += [
            "X11",
            "Xi",
            "Xext",
          ]
        }
        if (is_mac) {
          sources += rebase_path(gles_gypi.libangle_gl_cgl_sources, ".", "src")
          libs += [
            "Cocoa.framework",
            "IOSurface.framework",
            "OpenGL.framework",
            "QuartzCore.framework",
          ]
        }
        if (is_android) {
          sources += rebase_path(gles_gypi.libangle_gl_egl_sources, ".", "src")
          sources += rebase_path(gles_gypi.libangle_gl_egl_dl_sources, ".", "src")
          sources +=
              rebase_path(gles_gypi.libangle_gl_egl_android_sources, ".", "src")
          libs += [
            "android",
            "log",
          ]
        }
        if (ozone_platform_gbm) {
          configs += [ ":libdrm" ]
          defines += [ "ANGLE_USE_OZONE" ]
          deps += [ "//third_party/minigbm" ]
          sources += rebase_path(gles_gypi.libangle_gl_egl_sources, ".", "src")
          sources += rebase_path(gles_gypi.libangle_gl_egl_dl_sources, ".", "src")
          sources += rebase_path(gles_gypi.libangle_gl_ozone_sources, ".", "src")
        }
      }
    
      if (angle_enable_vulkan) {
        sources += rebase_path(gles_gypi.libangle_vulkan_sources, ".", "src")
        deps += [ "//third_party/angle/src/vulkan_support:angle_vulkan" ]
      }
    
      if (angle_enable_null) {
        sources += rebase_path(gles_gypi.libangle_null_sources, ".", "src")
      }
    
      if (is_debug) {
        defines += [ "ANGLE_GENERATE_SHADER_DEBUG_INFO" ]
      }
    
      configs -= angle_undefine_configs
    
      configs += [
        ":commit_id_config",
        ":debug_annotations_config",
        ":extra_warnings",
        ":libANGLE_config",
        ":internal_config",
      ]
    
      if (is_win) {
        data_deps = [
          ":copy_compiler_dll",
        ]
      }
    }
    
    config("shared_library_public_config") {
      if (is_mac && !is_component_build) {
        # Executable targets that depend on the shared libraries below need to have
        # the rpath setup in non-component build configurations.
        ldflags = [
          "-rpath",
          "@executable_path/",
        ]
      }
    }
    
    shared_library("libGLESv2") {
      sources = rebase_path(gles_gypi.libglesv2_sources, ".", "src")
    
      if (is_win) {
        ldflags =
            [ "/DEF:" + rebase_path("src/libGLESv2/libGLESv2.def", root_build_dir) ]
      }
    
      if (is_mac && !is_component_build) {
        ldflags = [
          "-install_name",
          "@rpath/${target_name}.dylib",
        ]
        public_configs = [ ":shared_library_public_config" ]
      }
    
      configs -= angle_undefine_configs
      configs += [
        ":internal_config",
        ":commit_id_config",
        ":debug_annotations_config",
        ":libANGLE_config",
      ]
    
      defines = [ "LIBGLESV2_IMPLEMENTATION" ]
    
      deps = [
        ":includes",
        ":libANGLE",
      ]
    }
    
    shared_library("libEGL") {
      sources = rebase_path(gles_gypi.libegl_sources, ".", "src")
    
      if (is_win) {
        ldflags = [ "/DEF:" + rebase_path("src/libEGL/libEGL.def", root_build_dir) ]
      }
    
      if (is_mac && !is_component_build) {
        ldflags = [
          "-install_name",
          "@rpath/${target_name}.dylib",
        ]
        public_configs = [ ":shared_library_public_config" ]
      }
    
      configs -= angle_undefine_configs
      configs += [
        ":commit_id_config",
        ":debug_annotations_config",
        ":extra_warnings",
        ":internal_config",
      ]
    
      defines = [ "LIBEGL_IMPLEMENTATION" ]
      if (is_win) {
        defines += [ "EGLAPI=" ]
      } else {
        defines += [ "EGLAPI=__attribute__((visibility(\"default\")))" ]
      }
    
      deps = [
        ":includes",
        ":libGLESv2",
      ]
    }
    
    util_gypi = exec_script("//build/gypi_to_gn.py",
                            [ rebase_path("util/util.gyp") ],
                            "scope",
                            [ "util/util.gyp" ])
    
    config("angle_util_config") {
      include_dirs = [ "util" ]
      if (is_linux && use_x11) {
        libs = [ "X11" ]
      }
    }
    
    shared_library("angle_util") {
      sources = rebase_path(util_gypi.util_sources, ".", "util")
    
      if (is_win) {
        sources += rebase_path(util_gypi.util_win32_sources, ".", "util")
      }
    
      if (is_linux) {
        sources += rebase_path(util_gypi.util_linux_sources, ".", "util")
        libs = [
          "rt",
          "dl",
        ]
      }
    
      if (is_mac) {
        sources += rebase_path(util_gypi.util_osx_sources, ".", "util")
        libs = [
          "AppKit.framework",
          "QuartzCore.framework",
        ]
      }
    
      if (use_x11) {
        sources += rebase_path(util_gypi.util_x11_sources, ".", "util")
      }
    
      if (is_android) {
        # To prevent linux sources filtering on android
        set_sources_assignment_filter([])
        sources += rebase_path(util_gypi.util_linux_sources, ".", "util")
        sources += rebase_path(util_gypi.util_android_sources, ".", "util")
        libs = [
          "android",
          "log",
        ]
      }
    
      if (use_ozone) {
        sources += rebase_path(util_gypi.util_ozone_sources, ".", "util")
      }
    
      defines = [
        "GL_GLEXT_PROTOTYPES",
        "EGL_EGLEXT_PROTOTYPES",
        "LIBANGLE_UTIL_IMPLEMENTATION",
      ]
    
      configs += [
        ":debug_annotations_config",
        ":extra_warnings",
      ]
    
      public_configs = [
        ":angle_util_config",
        ":internal_config",
      ]
      if (is_mac && !is_component_build) {
        ldflags = [
          "-install_name",
          "@rpath/lib${target_name}.dylib",
        ]
        public_configs += [ ":shared_library_public_config" ]
      }
    
      deps = [
        ":angle_common",
        ":libEGL",
        ":libGLESv2",
      ]
    }