blob: 4ea872ff97371224be2143a52d7f54617bb42f8e [file] [log] [blame]
Alexis Hetu91f10e32016-06-07 19:53:42 -04001# 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
Nicolas Capensd51e2162017-06-05 13:59:55 -040015import("//build/config/compiler/compiler.gni")
16
Alexis Hetu91f10e32016-06-07 19:53:42 -040017config("swiftshader_config") {
Alexis Hetu2ddef882017-03-14 15:11:15 -040018 defines = [ "STRICT_CONFORMANCE" ] # Disables OpenGL ES 3.0
19
Alexis Hetu03b67af2016-08-31 17:25:40 -040020 if (is_win) {
21 cflags = [
Alexis Hetud6d10f92016-11-22 13:47:04 -050022 "/GS", # Detects some buffer overruns
Alexis Hetu03b67af2016-08-31 17:25:40 -040023 "/Zc:wchar_t",
Alexis Hetu03b67af2016-08-31 17:25:40 -040024 "/EHsc",
25 "/nologo",
Alexis Hetud6d10f92016-11-22 13:47:04 -050026 "/Gd", # Default calling convention
Alexis Hetu2ddef882017-03-14 15:11:15 -040027 ]
28
29 defines += [
30 "_CRT_SECURE_NO_DEPRECATE",
31 "NOMINMAX",
32 "_WINDLL",
Nicolas Capens506cc5e2017-07-24 11:30:55 -040033 "NO_SANITIZE_FUNCTION=",
Alexis Hetu03b67af2016-08-31 17:25:40 -040034 ]
35
36 if (is_debug) {
Alexis Hetud6d10f92016-11-22 13:47:04 -050037 cflags += [ "/RTC1" ] # Run-Time Error Checks
Alexis Hetu03b67af2016-08-31 17:25:40 -040038 } else {
Alexis Hetu2ddef882017-03-14 15:11:15 -040039 defines += [ "ANGLE_DISABLE_TRACE" ]
Alexis Hetu03b67af2016-08-31 17:25:40 -040040 }
41 } else {
Alexis Hetua11d03e2017-01-27 11:38:59 -050042 cflags = [
43 "-std=c++11",
44 "-Wall",
Alexis Hetu2c0546d2017-05-24 11:16:26 -040045 "-fno-exceptions",
Alexis Hetua11d03e2017-01-27 11:38:59 -050046 "-fno-operator-names",
Alexis Hetu2ddef882017-03-14 15:11:15 -040047 ]
48
49 defines += [
50 "__STDC_CONSTANT_MACROS",
51 "__STDC_LIMIT_MACROS",
Nicolas Capens506cc5e2017-07-24 11:30:55 -040052 "NO_SANITIZE_FUNCTION=__attribute__((no_sanitize(\"function\")))",
Alexis Hetua11d03e2017-01-27 11:38:59 -050053 ]
Alexis Hetu91f10e32016-06-07 19:53:42 -040054
55 if (is_debug) {
Alexis Hetua11d03e2017-01-27 11:38:59 -050056 cflags += [
57 "-g",
58 "-g3",
59 ]
Alexis Hetud6d10f92016-11-22 13:47:04 -050060 } else { # Release
Alexis Hetu91f10e32016-06-07 19:53:42 -040061 # All Release builds use function/data sections to make the shared libraries smaller
62 cflags += [
63 "-ffunction-sections",
64 "-fdata-sections",
Alexis Hetu91f10e32016-06-07 19:53:42 -040065 "-fomit-frame-pointer",
Alexis Hetua11d03e2017-01-27 11:38:59 -050066 "-Os",
Alexis Hetu91f10e32016-06-07 19:53:42 -040067 ]
Alexis Hetu2ddef882017-03-14 15:11:15 -040068
69 defines += [
70 "ANGLE_DISABLE_TRACE",
71 "NDEBUG",
72 ]
Alexis Hetu91f10e32016-06-07 19:53:42 -040073 }
74
Alexis Hetud6d10f92016-11-22 13:47:04 -050075 if (target_cpu == "x64") { # 64 bit version
Alexis Hetu91f10e32016-06-07 19:53:42 -040076 cflags += [
77 "-m64",
78 "-fPIC",
Alexis Hetua11d03e2017-01-27 11:38:59 -050079 "-march=core2",
Alexis Hetu91f10e32016-06-07 19:53:42 -040080 ]
Alexis Hetud6d10f92016-11-22 13:47:04 -050081 } else { # 32 bit version
Alexis Hetua11d03e2017-01-27 11:38:59 -050082 cflags += [
83 "-m32",
84 "-msse2",
85 "-march=i686",
86 ]
Alexis Hetu91f10e32016-06-07 19:53:42 -040087 }
Alexis Hetua11d03e2017-01-27 11:38:59 -050088
Alexis Hetub1031c82017-01-30 13:46:08 -050089 if (is_linux) {
90 ldflags = [
91 "-Wl,--hash-style=both",
92 "-Wl,--gc-sections",
93 ]
Nicolas Capens0f7d4272017-06-05 13:24:09 -040094 # A bug in the gold linker prevents using ICF on 32-bit (crbug.com/729532)
95 if (use_gold && target_cpu == "x86") {
96 ldflags += [
97 "-Wl,--icf=none",
98 ]
99 }
Alexis Hetub1031c82017-01-30 13:46:08 -0500100 }
Alexis Hetu91f10e32016-06-07 19:53:42 -0400101 }
102}
103
Alexis Hetu68f564d2016-07-06 17:43:22 -0400104group("swiftshader") {
Alexis Hetu996663b2016-09-21 13:47:42 -0400105 data_deps = [
106 "src/OpenGL/libGLESv2:swiftshader_libGLESv2",
107 "src/OpenGL/libEGL:swiftshader_libEGL",
108 ]
Alexis Hetua6e99c02016-11-16 13:53:57 -0500109}
110
111group("swiftshader_tests") {
112 testonly = true
113
114 data_deps = [
115 "tests/unittests:swiftshader_unittests",
116 ]
Alexis Hetud6d10f92016-11-22 13:47:04 -0500117}