blob: 52a78e8912915812515f01843e2917b27fa69b86 [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",
Alexis Hetu03b67af2016-08-31 17:25:40 -040033 ]
34
35 if (is_debug) {
Alexis Hetud6d10f92016-11-22 13:47:04 -050036 cflags += [ "/RTC1" ] # Run-Time Error Checks
Alexis Hetu03b67af2016-08-31 17:25:40 -040037 } else {
Alexis Hetu2ddef882017-03-14 15:11:15 -040038 defines += [ "ANGLE_DISABLE_TRACE" ]
Alexis Hetu03b67af2016-08-31 17:25:40 -040039 }
40 } else {
Alexis Hetua11d03e2017-01-27 11:38:59 -050041 cflags = [
42 "-std=c++11",
43 "-Wall",
Alexis Hetu2c0546d2017-05-24 11:16:26 -040044 "-fno-exceptions",
Alexis Hetua11d03e2017-01-27 11:38:59 -050045 "-fno-operator-names",
Alexis Hetu2ddef882017-03-14 15:11:15 -040046 ]
47
48 defines += [
49 "__STDC_CONSTANT_MACROS",
50 "__STDC_LIMIT_MACROS",
Alexis Hetua11d03e2017-01-27 11:38:59 -050051 ]
Alexis Hetu91f10e32016-06-07 19:53:42 -040052
53 if (is_debug) {
Alexis Hetua11d03e2017-01-27 11:38:59 -050054 cflags += [
55 "-g",
56 "-g3",
57 ]
Alexis Hetud6d10f92016-11-22 13:47:04 -050058 } else { # Release
Alexis Hetu91f10e32016-06-07 19:53:42 -040059 # All Release builds use function/data sections to make the shared libraries smaller
60 cflags += [
61 "-ffunction-sections",
62 "-fdata-sections",
Alexis Hetu91f10e32016-06-07 19:53:42 -040063 "-fomit-frame-pointer",
Alexis Hetua11d03e2017-01-27 11:38:59 -050064 "-Os",
Alexis Hetu91f10e32016-06-07 19:53:42 -040065 ]
Alexis Hetu2ddef882017-03-14 15:11:15 -040066
67 defines += [
68 "ANGLE_DISABLE_TRACE",
69 "NDEBUG",
70 ]
Alexis Hetu91f10e32016-06-07 19:53:42 -040071 }
72
Alexis Hetud6d10f92016-11-22 13:47:04 -050073 if (target_cpu == "x64") { # 64 bit version
Alexis Hetu91f10e32016-06-07 19:53:42 -040074 cflags += [
75 "-m64",
76 "-fPIC",
Alexis Hetua11d03e2017-01-27 11:38:59 -050077 "-march=core2",
Alexis Hetu91f10e32016-06-07 19:53:42 -040078 ]
Alexis Hetud6d10f92016-11-22 13:47:04 -050079 } else { # 32 bit version
Alexis Hetua11d03e2017-01-27 11:38:59 -050080 cflags += [
81 "-m32",
82 "-msse2",
83 "-march=i686",
84 ]
Alexis Hetu91f10e32016-06-07 19:53:42 -040085 }
Alexis Hetua11d03e2017-01-27 11:38:59 -050086
Alexis Hetub1031c82017-01-30 13:46:08 -050087 if (is_linux) {
88 ldflags = [
89 "-Wl,--hash-style=both",
90 "-Wl,--gc-sections",
91 ]
Nicolas Capens0f7d4272017-06-05 13:24:09 -040092 # A bug in the gold linker prevents using ICF on 32-bit (crbug.com/729532)
93 if (use_gold && target_cpu == "x86") {
94 ldflags += [
95 "-Wl,--icf=none",
96 ]
97 }
Alexis Hetub1031c82017-01-30 13:46:08 -050098 }
Alexis Hetu91f10e32016-06-07 19:53:42 -040099 }
100}
101
Alexis Hetu68f564d2016-07-06 17:43:22 -0400102group("swiftshader") {
Alexis Hetu996663b2016-09-21 13:47:42 -0400103 data_deps = [
104 "src/OpenGL/libGLESv2:swiftshader_libGLESv2",
105 "src/OpenGL/libEGL:swiftshader_libEGL",
106 ]
Alexis Hetua6e99c02016-11-16 13:53:57 -0500107}
108
109group("swiftshader_tests") {
110 testonly = true
111
112 data_deps = [
113 "tests/unittests:swiftshader_unittests",
114 ]
Alexis Hetud6d10f92016-11-22 13:47:04 -0500115}