BUILD.gn 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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. import("//build/config/c++/c++.gni")
  15. import("//build/config/compiler/compiler.gni")
  16. import("//build/config/mips.gni")
  17. config("swiftshader_config") {
  18. defines = []
  19. if (is_win) {
  20. cflags = [
  21. "/GS", # Detects some buffer overruns
  22. "/Zc:wchar_t",
  23. "/EHs-c-", # Disable C++ exceptions
  24. "/nologo",
  25. "/Gd", # Default calling convention
  26. ]
  27. if (!use_custom_libcxx) {
  28. # Disable EH usage in STL headers.
  29. # libc++ uses a predefined macro to control whether to use exceptions, so
  30. # defining this macro is unnecessary. Defining _HAS_EXCEPTIONS to 0 also
  31. # breaks libc++ because it depends on MSVC headers that only provide
  32. # certain declarations if _HAS_EXCEPTIONS is 1.
  33. defines += [
  34. "_HAS_EXCEPTIONS=0",
  35. ]
  36. }
  37. defines += [
  38. "_CRT_SECURE_NO_DEPRECATE",
  39. "NOMINMAX",
  40. "_WINDLL",
  41. "NO_SANITIZE_FUNCTION=",
  42. ]
  43. if (!is_debug) {
  44. defines += [ "ANGLE_DISABLE_TRACE" ]
  45. }
  46. } else {
  47. cflags = [
  48. "-std=c++11",
  49. "-fno-exceptions",
  50. "-fno-operator-names",
  51. ]
  52. defines += [
  53. "__STDC_CONSTANT_MACROS",
  54. "__STDC_LIMIT_MACROS",
  55. "NO_SANITIZE_FUNCTION=__attribute__((no_sanitize(\"function\")))",
  56. ]
  57. if (is_debug) {
  58. cflags += [
  59. "-g",
  60. "-g3",
  61. ]
  62. } else { # Release
  63. # All Release builds use function/data sections to make the shared libraries smaller
  64. cflags += [
  65. "-ffunction-sections",
  66. "-fdata-sections",
  67. "-fomit-frame-pointer",
  68. "-Os",
  69. ]
  70. defines += [
  71. "ANGLE_DISABLE_TRACE",
  72. "NDEBUG",
  73. ]
  74. }
  75. if (target_cpu == "x64") { # 64 bit version
  76. cflags += [
  77. "-m64",
  78. "-fPIC",
  79. "-march=x86-64",
  80. "-mtune=generic",
  81. ]
  82. } else if (target_cpu == "x86") { # 32 bit version
  83. cflags += [
  84. "-m32",
  85. "-msse2",
  86. "-mfpmath=sse",
  87. "-march=pentium4",
  88. "-mtune=generic",
  89. ]
  90. } else if (target_cpu == "mipsel" && current_cpu == target_cpu) {
  91. cflags += [
  92. "-march=mipsel",
  93. "-fPIC",
  94. "-mhard-float",
  95. "-mfp32",
  96. ]
  97. if (mips_arch_variant == "r1") {
  98. cflags += [
  99. "-mcpu=mips32",
  100. ]
  101. } else {
  102. cflags += [
  103. "-mcpu=mips32r2",
  104. ]
  105. }
  106. } else if (target_cpu == "mips64el" && current_cpu == target_cpu) {
  107. cflags += [
  108. "-march=mips64el",
  109. "-mcpu=mips64r2",
  110. "-mabi=64",
  111. "-fPIC",
  112. ]
  113. }
  114. if (is_linux) {
  115. ldflags = [ "-Wl,--gc-sections" ]
  116. if (target_cpu == "mipsel") {
  117. ldflags += [
  118. "-Wl,--hash-style=sysv",
  119. ]
  120. if (mips_arch_variant == "r1") {
  121. ldflags += [
  122. "-mips32",
  123. ]
  124. } else {
  125. ldflags += [
  126. "-mips32r2",
  127. ]
  128. }
  129. } else if (target_cpu == "mips64el") {
  130. ldflags += [
  131. "-Wl,--hash-style=sysv",
  132. "-mips64r2",
  133. ]
  134. } else {
  135. ldflags += [ "-Wl,--hash-style=both" ]
  136. }
  137. # A bug in the gold linker prevents using ICF on 32-bit (crbug.com/729532)
  138. if (use_gold && (target_cpu == "x86" || target_cpu == "mipsel")) {
  139. ldflags += [ "-Wl,--icf=none" ]
  140. }
  141. }
  142. }
  143. }
  144. source_set("vertex_routine_fuzzer") {
  145. sources = [
  146. "tests/fuzzers/VertexRoutineFuzzer.cpp"
  147. ]
  148. if (is_win) {
  149. cflags = [
  150. "/wd4201", # nameless struct/union
  151. "/wd4065", # switch statement contains 'default' but no 'case' labels
  152. "/wd5030", # attribute is not recognized
  153. ]
  154. }
  155. include_dirs = [
  156. "src/",
  157. ]
  158. deps = [
  159. "src/OpenGL/libGLESv2:swiftshader_libGLESv2_static",
  160. ]
  161. }
  162. group("swiftshader") {
  163. data_deps = [
  164. "src/OpenGL/libGLESv2:swiftshader_libGLESv2",
  165. "src/OpenGL/libEGL:swiftshader_libEGL",
  166. ]
  167. }
  168. group("swiftshader_tests") {
  169. testonly = true
  170. data_deps = [
  171. "tests/GLESUnitTests:swiftshader_unittests",
  172. ]
  173. }