• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2017 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5# This file contains configs that need to be added or removed to all
6# SwiftShader libraries
7
8import("//build_overrides/build.gni")
9import("//build_overrides/spirv_tools.gni")
10import("//build_overrides/swiftshader.gni")
11
12if (!swiftshader_standalone) {
13  import("//build/config/sanitizers/sanitizers.gni")
14} else {
15  declare_args() {
16    is_ubsan_vptr = false
17  }
18}
19
20declare_args() {
21  # By default, build SwiftShader with optimizations enabled in debug
22  # for performance reasons. Set to false to build as unoptimized.
23  swiftshader_optimized_debug_build = true
24
25  # If enabled, debug builds on Windows will pop up a dialog when the
26  # SwiftShader DLL gets loaded, to facilitate attaching a debugger.
27  swiftshader_startup_dialog = false
28}
29
30configs_to_add = []
31configs_to_delete = []
32
33if (is_win) {
34  configs_to_delete += [ "//build/config/win:unicode" ]
35}
36
37if (is_debug && swiftshader_optimized_debug_build) {
38  configs_to_delete += [ "//build/config/compiler:default_optimization" ]
39  configs_to_add += [ "//build/config/compiler:optimize" ]
40}
41
42configs_to_delete += [ "//build/config/compiler:chromium_code" ]
43configs_to_add += [
44  "//build/config/compiler:no_chromium_code",
45  "$swiftshader_dir:swiftshader_config",
46]
47
48template("swiftshader_source_set") {
49  source_set(target_name) {
50    if (is_apple) {
51      # If a "build with ARC" config is present, remove it.
52      if (filter_include(configs, [ "//build/config/compiler:enable_arc" ]) !=
53          []) {
54        configs_to_delete += [ "//build/config/compiler:enable_arc" ]
55      }
56    }
57
58    configs -= configs_to_delete
59    configs += configs_to_add
60    forward_variables_from(invoker, "*", [ "configs" ])
61    if (defined(invoker.configs)) {
62      configs += invoker.configs
63    }
64  }
65}
66
67template("swiftshader_shared_library") {
68  shared_library(target_name) {
69    configs -= configs_to_delete
70    configs += configs_to_add
71    forward_variables_from(invoker, "*", [ "configs" ])
72    if (defined(invoker.configs)) {
73      configs += invoker.configs
74    }
75  }
76}
77
78template("swiftshader_static_library") {
79  static_library(target_name) {
80    configs -= configs_to_delete
81    configs += configs_to_add
82    forward_variables_from(invoker, "*", [ "configs" ])
83    if (defined(invoker.configs)) {
84      configs += invoker.configs
85    }
86  }
87}
88