Made SwiftShader compile on Mac in Chromium
Fixed a few things in the BUILD.gn files:
1) Style guide mentions single entries should be on single lines
2) Changed "host_os == ..." for the is_... equivalent values
3) Added missing Mac libs and include dirs
Change-Id: I28d35fd86a8cf9c9157a397370a385fe3e5e958b
Reviewed-on: https://swiftshader-review.googlesource.com/7152
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
diff --git a/BUILD.gn b/BUILD.gn
index 7e4cef7..3b0d027 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -26,23 +26,15 @@
]
if (is_debug) {
- cflags += [
- "/RTC1", # Run-Time Error Checks
- ]
+ cflags += [ "/RTC1" ] # Run-Time Error Checks
} else {
- cflags += [
- "/DANGLE_DISABLE_TRACE",
- ]
+ cflags += [ "/DANGLE_DISABLE_TRACE" ]
}
} else {
- cflags = [
- "-std=c++11",
- ]
+ cflags = [ "-std=c++11" ]
if (is_debug) {
- cflags += [
- "-g",
- ]
+ cflags += [ "-g" ]
} else { # Release
# All Release builds use function/data sections to make the shared libraries smaller
cflags += [
@@ -54,13 +46,9 @@
# Choose the right Release architecture
if (target_cpu == "x64") {
- cflags += [
- "-march=core2",
- ]
+ cflags += [ "-march=core2" ]
} else { # 32
- cflags += [
- "-march=i686",
- ]
+ cflags += [ "-march=i686" ]
}
}
@@ -70,9 +58,7 @@
"-fPIC",
]
} else { # 32 bit version
- cflags += [
- "-m32",
- ]
+ cflags += [ "-m32" ]
}
}
}
diff --git a/src/Common/BUILD.gn b/src/Common/BUILD.gn
index 96c73f8..979def0 100644
--- a/src/Common/BUILD.gn
+++ b/src/Common/BUILD.gn
@@ -15,9 +15,7 @@
# Need a separate config to ensure the warnings are added to the end.
config("swiftshader_common_private_config") {
if (is_win) {
- cflags = [
- "/wd4201", # nameless struct/union
- ]
+ cflags = [ "/wd4201" ] # nameless struct/union
} else {
cflags = [
"-DLOG_TAG=\"swiftshader_common\"",
@@ -40,7 +38,5 @@
"Timer.cpp",
]
- configs += [
- ":swiftshader_common_private_config",
- ]
+ configs += [ ":swiftshader_common_private_config" ]
}
\ No newline at end of file
diff --git a/src/Main/BUILD.gn b/src/Main/BUILD.gn
index 849f49e..9f5ca94 100644
--- a/src/Main/BUILD.gn
+++ b/src/Main/BUILD.gn
@@ -15,9 +15,7 @@
# Need a separate config to ensure the warnings are added to the end.
config("swiftshader_main_private_config") {
if (is_win) {
- cflags = [
- "/wd4201", # nameless struct/union
- ]
+ cflags = [ "/wd4201" ] # nameless struct/union
if (is_clang) {
cflags += [
@@ -35,9 +33,7 @@
}
source_set("swiftshader_main") {
- deps = [
- "../Common:swiftshader_common",
- ]
+ deps = [ "../Common:swiftshader_common" ]
sources = [
"Config.cpp",
@@ -45,16 +41,14 @@
"SwiftConfig.cpp",
]
- if (host_os == "linux") {
+ if (is_linux) {
sources += [
"libX11.cpp",
"FrameBufferX11.cpp",
]
- } else if (host_os == "mac") {
- sources += [
- "FrameBufferOSX.mm",
- ]
- } else if (host_os == "win") {
+ } else if (is_mac) {
+ sources += [ "FrameBufferOSX.mm" ]
+ } else if (is_win) {
sources += [
"FrameBufferDD.cpp",
"FrameBufferGDI.cpp",
@@ -62,20 +56,22 @@
]
}
- if (host_os == "win") {
- configs -= [
- "//build/config/win:unicode"
- ]
- libs = [
- "dxguid.lib" # For FrameBufferDD
- ]
+ if (is_win) {
+ configs -= [ "//build/config/win:unicode" ]
+ libs = [ "dxguid.lib" ] # For FrameBufferDD
}
- configs += [
- ":swiftshader_main_private_config",
- ]
+ configs += [ ":swiftshader_main_private_config" ]
include_dirs = [
"..",
"../Common",
]
+
+ if (is_mac) {
+ include_dirs += [ "../../include" ]
+ libs = [
+ "Quartz.framework",
+ "Cocoa.framework"
+ ]
+ }
}
\ No newline at end of file
diff --git a/src/OpenGL/common/BUILD.gn b/src/OpenGL/common/BUILD.gn
index bf80c44..9d47e6c 100644
--- a/src/OpenGL/common/BUILD.gn
+++ b/src/OpenGL/common/BUILD.gn
@@ -21,14 +21,10 @@
]
if (is_clang) {
- cflags += [
- "-Wno-delete-incomplete",
- ]
+ cflags += [ "-Wno-delete-incomplete" ]
}
} else {
- cflags = [
- "-DLOG_TAG=\"swiftshader_opengl_common\"",
- ]
+ cflags = [ "-DLOG_TAG=\"swiftshader_opengl_common\"" ]
}
}
@@ -40,9 +36,7 @@
"MatrixStack.cpp",
]
- configs += [
- ":swiftshader_opengl_common_private_config",
- ]
+ configs += [ ":swiftshader_opengl_common_private_config" ]
include_dirs = [
"..",
diff --git a/src/OpenGL/compiler/BUILD.gn b/src/OpenGL/compiler/BUILD.gn
index 89e54e3..8cd74a5 100644
--- a/src/OpenGL/compiler/BUILD.gn
+++ b/src/OpenGL/compiler/BUILD.gn
@@ -23,9 +23,7 @@
]
if (!is_debug) {
- cflags += [
- "/wd4189", # local variable is initialized but not referenced (variables only used in ASSERTS)
- ]
+ cflags += [ "/wd4189" ] # local variable is initialized but not referenced (variables only used in ASSERTS)
}
if (is_clang) {
@@ -41,17 +39,13 @@
]
if (!is_debug) {
- cflags += [
- "-Wno-unused-variable", # local variable is initialized but not referenced (variables only used in ASSERTS)
- ]
+ cflags += [ "-Wno-unused-variable" ] # local variable is initialized but not referenced (variables only used in ASSERTS)
}
}
}
source_set("swiftshader_opengl_compiler") {
- deps = [
- "preprocessor:swiftshader_opengl_preprocessor",
- ]
+ deps = [ "preprocessor:swiftshader_opengl_preprocessor" ]
sources = [
"AnalyzeCallDepth.cpp",
@@ -79,19 +73,13 @@
"ValidateSwitch.cpp",
]
- if ((host_os == "linux") || (host_os == "mac")) {
- sources += [
- "ossource_posix.cpp",
- ]
- } else if (host_os == "win") {
- sources += [
- "ossource_win.cpp",
- ]
+ if (is_linux || is_mac) {
+ sources += [ "ossource_posix.cpp" ]
+ } else if (is_win) {
+ sources += [ "ossource_win.cpp" ]
}
- configs += [
- ":swiftshader_opengl_compiler_private_config",
- ]
+ configs += [ ":swiftshader_opengl_compiler_private_config" ]
include_dirs = [
"..",
diff --git a/src/OpenGL/libEGL/BUILD.gn b/src/OpenGL/libEGL/BUILD.gn
index 35692bb..cd76ab9 100644
--- a/src/OpenGL/libEGL/BUILD.gn
+++ b/src/OpenGL/libEGL/BUILD.gn
@@ -24,9 +24,7 @@
]
if (is_clang) {
- cflags += [
- "-Wno-unused-function",
- ]
+ cflags += [ "-Wno-unused-function" ]
}
} else {
cflags = [
@@ -54,29 +52,21 @@
"resource.h",
]
- if(is_debug)
- {
- sources += [
- "../common/debug.cpp",
- ]
+ if(is_debug) {
+ sources += [ "../common/debug.cpp" ]
}
- if (host_os == "mac") {
- sources += [
- "OSXUtils.mm",
+ if (is_mac) {
+ sources += [ "OSXUtils.mm" ]
+ libs = [
+ "Quartz.framework",
+ "Cocoa.framework",
]
- } else if (host_os == "win") {
- configs -= [
- "//build/config/win:unicode"
- ]
-
- ldflags = [
- "/DEF:" + rebase_path("libGLESv2.def", root_build_dir),
- ]
- } else if (host_os == "linux") {
- sources += [
- "../../Main/libX11.cpp",
- ]
+ } else if (is_win) {
+ configs -= [ "//build/config/win:unicode" ]
+ ldflags = [ "/DEF:" + rebase_path("libGLESv2.def", root_build_dir) ]
+ } else if (is_linux) {
+ sources += [ "../../Main/libX11.cpp" ]
}
configs -= [ "//build/config/compiler:chromium_code" ]
diff --git a/src/OpenGL/libGLESv2/BUILD.gn b/src/OpenGL/libGLESv2/BUILD.gn
index a7c9a3b..5902917 100644
--- a/src/OpenGL/libGLESv2/BUILD.gn
+++ b/src/OpenGL/libGLESv2/BUILD.gn
@@ -80,14 +80,9 @@
"resource.h",
]
- if (host_os == "win") {
- configs -= [
- "//build/config/win:unicode"
- ]
-
- ldflags = [
- "/DEF:" + rebase_path("libGLESv2.def", root_build_dir),
- ]
+ if (is_win) {
+ configs -= [ "//build/config/win:unicode" ]
+ ldflags = [ "/DEF:" + rebase_path("libGLESv2.def", root_build_dir) ]
}
configs -= [ "//build/config/compiler:chromium_code" ]
diff --git a/src/Reactor/BUILD.gn b/src/Reactor/BUILD.gn
index d6cb5c9..baba9c0 100644
--- a/src/Reactor/BUILD.gn
+++ b/src/Reactor/BUILD.gn
@@ -21,9 +21,7 @@
]
if (is_clang) {
- cflags += [
- "-Wno-delete-incomplete",
- ]
+ cflags += [ "-Wno-delete-incomplete" ]
}
} else {
cflags = [
@@ -48,18 +46,12 @@
"RoutineManager.cpp",
]
- if (host_os == "win") {
- sources += [
- "DLL.cpp",
- ]
- configs -= [
- "//build/config/win:unicode"
- ]
+ if (is_win) {
+ sources += [ "DLL.cpp" ]
+ configs -= [ "//build/config/win:unicode" ]
}
- configs += [
- ":swiftshader_reactor_private_config",
- ]
+ configs += [ ":swiftshader_reactor_private_config" ]
include_dirs = [
"..",
diff --git a/src/Renderer/BUILD.gn b/src/Renderer/BUILD.gn
index cec4b3b..b29b99d 100644
--- a/src/Renderer/BUILD.gn
+++ b/src/Renderer/BUILD.gn
@@ -36,9 +36,7 @@
}
source_set("swiftshader_renderer") {
- deps = [
- "../Shader:swiftshader_shader",
- ]
+ deps = [ "../Shader:swiftshader_shader" ]
sources = [
"Blitter.cpp",
@@ -60,15 +58,11 @@
"VertexProcessor.cpp",
]
- if (host_os == "win") {
- configs -= [
- "//build/config/win:unicode"
- ]
+ if (is_win) {
+ configs -= [ "//build/config/win:unicode" ]
}
- configs += [
- ":swiftshader_renderer_private_config",
- ]
+ configs += [ ":swiftshader_renderer_private_config" ]
include_dirs = [
".",
diff --git a/src/Shader/BUILD.gn b/src/Shader/BUILD.gn
index 288fe9c..8ab03c6 100644
--- a/src/Shader/BUILD.gn
+++ b/src/Shader/BUILD.gn
@@ -27,16 +27,12 @@
]
}
} else {
- cflags = [
- "-DLOG_TAG=\"swiftshader_shader\"",
- ]
+ cflags = [ "-DLOG_TAG=\"swiftshader_shader\"" ]
}
}
source_set("swiftshader_shader") {
- deps = [
- "../Main:swiftshader_main",
- ]
+ deps = [ "../Main:swiftshader_main" ]
sources = [
"Constants.cpp",
@@ -54,9 +50,7 @@
"VertexShader.cpp",
]
- configs += [
- ":swiftshader_shader_private_config",
- ]
+ configs += [ ":swiftshader_shader_private_config" ]
include_dirs = [
".",
diff --git a/third_party/LLVM/BUILD.gn b/third_party/LLVM/BUILD.gn
index 761f6c8..1c69f3f 100644
--- a/third_party/LLVM/BUILD.gn
+++ b/third_party/LLVM/BUILD.gn
@@ -36,9 +36,7 @@
]
if (!is_debug) {
- cflags += [
- "/wd4324",
- ]
+ cflags += [ "/wd4324" ]
}
if (is_clang) {
@@ -442,34 +440,22 @@
"lib/VMCore/Verifier.cpp",
]
- if (host_os == "win") {
- configs -= [
- "//build/config/win:unicode"
- ]
+ if (is_win) {
+ configs -= [ "//build/config/win:unicode" ]
}
- configs += [
- ":swiftshader_llvm_private_config",
- ]
+ configs += [ ":swiftshader_llvm_private_config" ]
- include_dirs = [
- "lib/Target/X86",
- ]
+ include_dirs = [ "lib/Target/X86" ]
- # The "include" directory includes common files and the Windows specific config file.
+ # The "include" directory includes common files and the Windows specific config file.
# The "include-<platform>" directory includes the <platform> specific config file.
# Non-Windows platforms must add their platform specific include directory before the "include" directory
# is added, otherwise, the Windows specific config file will be used and compilation will fail.
- if (host_os == "linux") {
- include_dirs += [
- "include-linux",
- ]
- } else if (host_os == "mac") {
- include_dirs += [
- "include-mac",
- ]
+ if (is_linux) {
+ include_dirs += [ "include-linux" ]
+ } else if (is_mac) {
+ include_dirs += [ "include-osx" ]
}
- include_dirs += [
- "include",
- ]
+ include_dirs += [ "include" ]
}
\ No newline at end of file