Edit

kc3-lang/angle/BUILD.gn

Branch :

  • Show log

    Commit

  • Author : Daniel Bratell
    Date : 2015-02-25 14:34:49
    Hash : 73941deb
    Message : Disable the HLSL code in Angle if it is not being used. We're only using the HLSL code in Windows so it's not necessary to compile and distribute it on other platforms. This adds a defined ANGLE_ENABLE_HLSL that can be checked in files that are used by non-HLSL code as well. Mostly the HLSL code is just not include by the build system. Details of the space savings (heavily truncated) Total change: -165717 bytes =========================== -606 - Source: angle/src/common/utilities.cpp -627 - Source: angle/src/compiler/translator/FlagStd140Structs.cpp -695 - Source: /usr/include/c++/4.8/bits/stl_algo.h -710 - Source: angle/src/compiler/translator/TranslatorHLSL.cpp -713 - Source: angle/src/compiler/translator/IntermNode.h -863 - Source: /usr/include/c++/4.8/bits/stl_map.h -935 - Source: angle/src/compiler/translator/blocklayout.cpp -1515 - Source: angle/src/compiler/translator/BuiltInFunctionEmulator.cpp -1655 - Source: angle/src/compiler/translator/UnfoldShortCircuit.cpp -2375 - Source: /usr/include/c++/4.8/bits/vector.tcc -3135 - Source: angle/src/compiler/translator/RewriteElseBlocks.cpp -4656 - Source: angle/src/compiler/translator/UtilsHLSL.cpp -5265 - Source: angle/src/compiler/translator/BuiltInFunctionEmulatorHLSL.cpp -6505 - Source: /usr/include/c++/4.8/bits/stl_tree.h -11480 - Source: angle/src/compiler/translator/UniformHLSL.cpp -13580 - Source: angle/src/compiler/translator/StructureHLSL.cpp -18964 - Source: ?? (constant strings and a few vtbls) -89332 - Source: angle/src/compiler/translator/OutputHLSL.cpp Change-Id: I23ccc98abd0a21f847dd34f9482800b3ba679d56 Reviewed-on: https://chromium-review.googlesource.com/251528 Tested-by: bratell at Opera <bratell@opera.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>

  • BUILD.gn
  • # Copyright 2014 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.
    
    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",
      ]
    }
    
    angle_enable_d3d9 = false
    angle_enable_d3d11 = false
    angle_enable_gl = false
    
    if (is_win) {
      angle_enable_d3d9 = true
      angle_enable_d3d11 = true
      angle_enable_gl = true
    
      import("//build/config/win/visual_studio_version.gni")
      copy("copy_compiler_dll") {
        sources = [ "$windows_sdk_path/Redist/D3D/$cpu_arch/d3dcompiler_47.dll" ]
        outputs = [ "$root_build_dir/d3dcompiler_47.dll" ]
      }
    
    }  # is_win
    
    angle_enable_hlsl = false
    
    if (angle_enable_d3d9 || angle_enable_d3d11) {
      angle_enable_hlsl = true
    }
    
    component("translator") {
      sources = [
        "src/compiler/translator/ShaderLang.cpp",
        "src/compiler/translator/ShaderVars.cpp",
      ]
    
      defines = [ "ANGLE_TRANSLATOR_IMPLEMENTATION" ]
    
      if (angle_enable_hlsl) {
        sources += rebase_path(compiler_gypi.angle_translator_lib_hlsl_sources, ".", "src")
        defines += [ "ANGLE_ENABLE_HLSL" ]
      }
    
      configs -= [ "//build/config/compiler:chromium_code" ]
      configs += [
        ":internal_config",
        "//build/config/compiler:no_chromium_code",
      ]
    
      public_deps = [
        ":translator_lib",
      ]
    }
    
    # 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/gl3ext.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 -= [ "//build/config/compiler:chromium_code" ]
      configs += [
        ":internal_config",
        "//build/config/compiler:no_chromium_code",
      ]
    }
    
    config("translator_static_config") {
      defines = [ "ANGLE_TRANSLATOR_STATIC" ]
    }
    
    static_library("angle_common") {
      sources = rebase_path(gles_gypi.libangle_common_sources, ".", "src")
      configs -= [ "//build/config/compiler:chromium_code" ]
      configs += [
        ":internal_config",
      ]
    }
    
    static_library("translator_lib") {
      sources = rebase_path(compiler_gypi.angle_translator_lib_sources, ".", "src")
    
      if (angle_enable_hlsl) {
        sources += rebase_path(compiler_gypi.angle_translator_lib_hlsl_sources, ".", "src")
        defines = [ "ANGLE_ENABLE_HLSL" ]
      }
      configs -= [ "//build/config/compiler:chromium_code" ]
      configs += [
        ":internal_config",
        ":translator_static_config",
        "//build/config/compiler:no_chromium_code",
      ]
      public_configs = [ ":external_config" ]
    
      deps = [
        ":includes",
        ":preprocessor",
      ]
    
      public_deps = [
        ":angle_common",
      ]
    }
    
    static_library("translator_static") {
      sources = [
        "src/compiler/translator/ShaderLang.cpp",
        "src/compiler/translator/ShaderVars.cpp",
      ]
    
      if (angle_enable_hlsl) {
        defines = [ "ANGLE_ENABLE_HLSL" ]
      }
    
      configs -= [ "//build/config/compiler:chromium_code" ]
      configs += [
        ":internal_config",
        "//build/config/compiler:no_chromium_code",
      ]
      public_configs = [ ":translator_static_config" ]
    
      public_deps = [
        ":translator_lib",
      ]
    }
    
    config("commit_id_config") {
      include_dirs = [ "$root_gen_dir/angle" ]
    }
    
    action("commit_id") {
      script = "src/commit_id.py"
    
      output_file = "$root_gen_dir/angle/id/commit.h"
      outputs = [ output_file ]
    
      args = [
        "gen",
        rebase_path(".", root_build_dir),
        rebase_path(output_file, root_build_dir),
      ]
    
      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" ]
      }
      defines += [
        "GL_APICALL=",
        "GL_GLEXT_PROTOTYPES=",
        "EGLAPI=",
      ]
      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 = [
        "LIBANGLE_IMPLEMENTATION",
      ]
    
      # 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 (is_debug) {
        defines += [
          "ANGLE_GENERATE_SHADER_DEBUG_INFO",
          "ANGLE_ENABLE_DEBUG_ANNOTATIONS",
        ]
      }
    
      configs -= [ "//build/config/compiler:chromium_code" ]
      configs += [
        ":commit_id_config",
        ":libANGLE_config",
        ":internal_config",
        "//build/config/compiler:no_chromium_code",
      ]
    
      deps = [
        ":commit_id",
        ":includes",
        ":translator",
        ":angle_common",
      ]
    
      if (is_win) {
        deps += [ ":copy_compiler_dll" ]
      }
    }
    
    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) ]
      }
    
      configs -= [ "//build/config/compiler:chromium_code" ]
      configs += [
        ":internal_config",
        ":commit_id_config",
        ":libANGLE_config",
        "//build/config/compiler:no_chromium_code",
      ]
    
      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) ]
      }
    
      configs -= [ "//build/config/compiler:chromium_code" ]
      configs += [
        ":internal_config",
        ":commit_id_config",
        ":libANGLE_config",
        "//build/config/compiler:no_chromium_code",
      ]
    
      defines = [
        "LIBEGL_IMPLEMENTATION",
      ]
    
      deps = [
        ":includes",
        ":libGLESv2",
      ]
    }