• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2016 The SwiftShader Authors. All Rights Reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#    http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15import("//build/config/c++/c++.gni")
16import("//build/config/compiler/compiler.gni")
17import("//build/config/mips.gni")
18
19config("swiftshader_config") {
20  defines = []
21
22  if (is_win) {
23    cflags = [
24      "/GS",  # Detects some buffer overruns
25      "/Zc:wchar_t",
26      "/EHs-c-",  # Disable C++ exceptions
27      "/nologo",
28      "/Gd",  # Default calling convention
29      # Disable MSVC warnings about std::aligned_storage being broken before VS 2017 15.8
30      "/D_ENABLE_EXTENDED_ALIGNED_STORAGE",
31    ]
32
33    if (!use_custom_libcxx) {
34      # Disable EH usage in STL headers.
35      # libc++ uses a predefined macro to control whether to use exceptions, so
36      # defining this macro is unnecessary. Defining _HAS_EXCEPTIONS to 0 also
37      # breaks libc++ because it depends on MSVC headers that only provide
38      # certain declarations if _HAS_EXCEPTIONS is 1.
39      defines += [
40        "_HAS_EXCEPTIONS=0",
41      ]
42    }
43
44    defines += [
45      "_CRT_SECURE_NO_DEPRECATE",
46      "NOMINMAX",
47      "_WINDLL",
48      "NO_SANITIZE_FUNCTION=",
49    ]
50
51    if (!is_debug) {
52      defines += [ "ANGLE_DISABLE_TRACE" ]
53    }
54
55    # Diable some MSVC warnings.
56    if (!is_clang) {
57      cflags += [
58        "/wd4065", # switch statement contains 'default' but no 'case' labels
59        "/wd4309", # Truncation of constant value. See PixelRoutine.cpp casts of signed shorts.
60      ]
61    }
62  } else {
63    cflags = [
64      "-std=c++14",
65      "-fno-exceptions",
66      "-fno-operator-names",
67    ]
68
69    defines += [
70      "__STDC_CONSTANT_MACROS",
71      "__STDC_LIMIT_MACROS",
72      "NO_SANITIZE_FUNCTION=__attribute__((no_sanitize(\"function\")))",
73    ]
74
75    if (is_debug) {
76      cflags += [
77        "-g",
78        "-g3",
79      ]
80    } else {  # Release
81      # All Release builds use function/data sections to make the shared libraries smaller
82      cflags += [
83        "-ffunction-sections",
84        "-fdata-sections",
85        "-fomit-frame-pointer",
86        "-Os",
87      ]
88
89      defines += [
90        "ANGLE_DISABLE_TRACE",
91        "NDEBUG",
92      ]
93    }
94
95    if (current_cpu == "x64") {  # 64 bit version
96      cflags += [
97        "-m64",
98        "-fPIC",
99        "-march=x86-64",
100        "-mtune=generic",
101      ]
102    } else if (current_cpu == "x86") {  # 32 bit version
103      cflags += [
104        "-m32",
105        "-msse2",
106        "-mfpmath=sse",
107        "-march=pentium4",
108        "-mtune=generic",
109      ]
110    } else if (target_cpu == "mipsel" && current_cpu == target_cpu) {
111      cflags += [
112        "-EL",
113        "-fPIC",
114        "-mhard-float",
115        "-mfp32",
116        "-mxgot",
117      ]
118      if (mips_arch_variant == "r1") {
119        cflags += [
120          "-march=mips32",
121        ]
122      } else {
123        cflags += [
124          "-march=mips32r2",
125        ]
126      }
127    } else if (target_cpu == "mips64el" && current_cpu == target_cpu) {
128      cflags += [
129        "-EL",
130        "-arch=mips64r2",
131        "-mabi=64",
132        "-fPIC",
133        "-mxgot",
134      ]
135    }
136
137    if (is_linux) {
138      ldflags = [ "-Wl,--gc-sections" ]
139
140      if (current_cpu == "mipsel") {
141        ldflags += [
142          "-Wl,--hash-style=sysv",
143        ]
144        if (mips_arch_variant == "r1") {
145          ldflags += [
146            "-mips32",
147          ]
148        } else {
149          ldflags += [
150            "-mips32r2",
151          ]
152        }
153      } else if (current_cpu == "mips64el") {
154        ldflags += [
155          "-Wl,--hash-style=sysv",
156          "-mips64r2",
157        ]
158      } else {
159        ldflags += [ "-Wl,--hash-style=both" ]
160      }
161
162      # A bug in the gold linker prevents using ICF on 32-bit (crbug.com/729532)
163      if (use_gold && (current_cpu == "x86" || current_cpu == "mipsel")) {
164        ldflags += [ "-Wl,--icf=none" ]
165      }
166    }
167  }
168}
169
170source_set("vertex_routine_fuzzer") {
171  sources = [
172    "tests/fuzzers/VertexRoutineFuzzer.cpp"
173  ]
174  if (is_win) {
175    cflags = [
176      "/wd4201",  # nameless struct/union
177      "/wd4065",  # switch statement contains 'default' but no 'case' labels
178      "/wd5030",  # attribute is not recognized
179    ]
180  }
181  include_dirs = [
182    "src/",
183  ]
184  deps = [
185    "src/OpenGL/libGLESv2:swiftshader_libGLESv2_static",
186  ]
187}
188
189group("swiftshader") {
190  data_deps = [
191    "src/OpenGL/libGLESv2:swiftshader_libGLESv2",
192    "src/OpenGL/libEGL:swiftshader_libEGL",
193  ]
194}
195
196if (build_with_chromium) {
197    group("swiftshader_tests") {
198      testonly = true
199
200      data_deps = [
201        "tests/GLESUnitTests:swiftshader_unittests",
202        "tests/SystemUnitTests:swiftshader_system_unittests",
203      ]
204    }
205}
206