Commit 8be41107 by Alexis Hetu Committed by Alexis Hétu

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/7152Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent cf3cd8d6
...@@ -26,23 +26,15 @@ config("swiftshader_config") { ...@@ -26,23 +26,15 @@ config("swiftshader_config") {
] ]
if (is_debug) { if (is_debug) {
cflags += [ cflags += [ "/RTC1" ] # Run-Time Error Checks
"/RTC1", # Run-Time Error Checks
]
} else { } else {
cflags += [ cflags += [ "/DANGLE_DISABLE_TRACE" ]
"/DANGLE_DISABLE_TRACE",
]
} }
} else { } else {
cflags = [ cflags = [ "-std=c++11" ]
"-std=c++11",
]
if (is_debug) { if (is_debug) {
cflags += [ cflags += [ "-g" ]
"-g",
]
} else { # Release } else { # Release
# All Release builds use function/data sections to make the shared libraries smaller # All Release builds use function/data sections to make the shared libraries smaller
cflags += [ cflags += [
...@@ -54,13 +46,9 @@ config("swiftshader_config") { ...@@ -54,13 +46,9 @@ config("swiftshader_config") {
# Choose the right Release architecture # Choose the right Release architecture
if (target_cpu == "x64") { if (target_cpu == "x64") {
cflags += [ cflags += [ "-march=core2" ]
"-march=core2",
]
} else { # 32 } else { # 32
cflags += [ cflags += [ "-march=i686" ]
"-march=i686",
]
} }
} }
...@@ -70,9 +58,7 @@ config("swiftshader_config") { ...@@ -70,9 +58,7 @@ config("swiftshader_config") {
"-fPIC", "-fPIC",
] ]
} else { # 32 bit version } else { # 32 bit version
cflags += [ cflags += [ "-m32" ]
"-m32",
]
} }
} }
} }
......
...@@ -15,9 +15,7 @@ ...@@ -15,9 +15,7 @@
# Need a separate config to ensure the warnings are added to the end. # Need a separate config to ensure the warnings are added to the end.
config("swiftshader_common_private_config") { config("swiftshader_common_private_config") {
if (is_win) { if (is_win) {
cflags = [ cflags = [ "/wd4201" ] # nameless struct/union
"/wd4201", # nameless struct/union
]
} else { } else {
cflags = [ cflags = [
"-DLOG_TAG=\"swiftshader_common\"", "-DLOG_TAG=\"swiftshader_common\"",
...@@ -40,7 +38,5 @@ source_set("swiftshader_common") { ...@@ -40,7 +38,5 @@ source_set("swiftshader_common") {
"Timer.cpp", "Timer.cpp",
] ]
configs += [ configs += [ ":swiftshader_common_private_config" ]
":swiftshader_common_private_config",
]
} }
\ No newline at end of file
...@@ -15,9 +15,7 @@ ...@@ -15,9 +15,7 @@
# Need a separate config to ensure the warnings are added to the end. # Need a separate config to ensure the warnings are added to the end.
config("swiftshader_main_private_config") { config("swiftshader_main_private_config") {
if (is_win) { if (is_win) {
cflags = [ cflags = [ "/wd4201" ] # nameless struct/union
"/wd4201", # nameless struct/union
]
if (is_clang) { if (is_clang) {
cflags += [ cflags += [
...@@ -35,9 +33,7 @@ config("swiftshader_main_private_config") { ...@@ -35,9 +33,7 @@ config("swiftshader_main_private_config") {
} }
source_set("swiftshader_main") { source_set("swiftshader_main") {
deps = [ deps = [ "../Common:swiftshader_common" ]
"../Common:swiftshader_common",
]
sources = [ sources = [
"Config.cpp", "Config.cpp",
...@@ -45,16 +41,14 @@ source_set("swiftshader_main") { ...@@ -45,16 +41,14 @@ source_set("swiftshader_main") {
"SwiftConfig.cpp", "SwiftConfig.cpp",
] ]
if (host_os == "linux") { if (is_linux) {
sources += [ sources += [
"libX11.cpp", "libX11.cpp",
"FrameBufferX11.cpp", "FrameBufferX11.cpp",
] ]
} else if (host_os == "mac") { } else if (is_mac) {
sources += [ sources += [ "FrameBufferOSX.mm" ]
"FrameBufferOSX.mm", } else if (is_win) {
]
} else if (host_os == "win") {
sources += [ sources += [
"FrameBufferDD.cpp", "FrameBufferDD.cpp",
"FrameBufferGDI.cpp", "FrameBufferGDI.cpp",
...@@ -62,20 +56,22 @@ source_set("swiftshader_main") { ...@@ -62,20 +56,22 @@ source_set("swiftshader_main") {
] ]
} }
if (host_os == "win") { if (is_win) {
configs -= [ configs -= [ "//build/config/win:unicode" ]
"//build/config/win:unicode" libs = [ "dxguid.lib" ] # For FrameBufferDD
]
libs = [
"dxguid.lib" # For FrameBufferDD
]
} }
configs += [ configs += [ ":swiftshader_main_private_config" ]
":swiftshader_main_private_config",
]
include_dirs = [ include_dirs = [
"..", "..",
"../Common", "../Common",
] ]
if (is_mac) {
include_dirs += [ "../../include" ]
libs = [
"Quartz.framework",
"Cocoa.framework"
]
}
} }
\ No newline at end of file
...@@ -21,14 +21,10 @@ config("swiftshader_opengl_common_private_config") { ...@@ -21,14 +21,10 @@ config("swiftshader_opengl_common_private_config") {
] ]
if (is_clang) { if (is_clang) {
cflags += [ cflags += [ "-Wno-delete-incomplete" ]
"-Wno-delete-incomplete",
]
} }
} else { } else {
cflags = [ cflags = [ "-DLOG_TAG=\"swiftshader_opengl_common\"" ]
"-DLOG_TAG=\"swiftshader_opengl_common\"",
]
} }
} }
...@@ -40,9 +36,7 @@ source_set("swiftshader_opengl_common") { ...@@ -40,9 +36,7 @@ source_set("swiftshader_opengl_common") {
"MatrixStack.cpp", "MatrixStack.cpp",
] ]
configs += [ configs += [ ":swiftshader_opengl_common_private_config" ]
":swiftshader_opengl_common_private_config",
]
include_dirs = [ include_dirs = [
"..", "..",
......
...@@ -23,9 +23,7 @@ config("swiftshader_opengl_compiler_private_config") { ...@@ -23,9 +23,7 @@ config("swiftshader_opengl_compiler_private_config") {
] ]
if (!is_debug) { if (!is_debug) {
cflags += [ cflags += [ "/wd4189" ] # local variable is initialized but not referenced (variables only used in ASSERTS)
"/wd4189", # local variable is initialized but not referenced (variables only used in ASSERTS)
]
} }
if (is_clang) { if (is_clang) {
...@@ -41,17 +39,13 @@ config("swiftshader_opengl_compiler_private_config") { ...@@ -41,17 +39,13 @@ config("swiftshader_opengl_compiler_private_config") {
] ]
if (!is_debug) { if (!is_debug) {
cflags += [ cflags += [ "-Wno-unused-variable" ] # local variable is initialized but not referenced (variables only used in ASSERTS)
"-Wno-unused-variable", # local variable is initialized but not referenced (variables only used in ASSERTS)
]
} }
} }
} }
source_set("swiftshader_opengl_compiler") { source_set("swiftshader_opengl_compiler") {
deps = [ deps = [ "preprocessor:swiftshader_opengl_preprocessor" ]
"preprocessor:swiftshader_opengl_preprocessor",
]
sources = [ sources = [
"AnalyzeCallDepth.cpp", "AnalyzeCallDepth.cpp",
...@@ -79,19 +73,13 @@ source_set("swiftshader_opengl_compiler") { ...@@ -79,19 +73,13 @@ source_set("swiftshader_opengl_compiler") {
"ValidateSwitch.cpp", "ValidateSwitch.cpp",
] ]
if ((host_os == "linux") || (host_os == "mac")) { if (is_linux || is_mac) {
sources += [ sources += [ "ossource_posix.cpp" ]
"ossource_posix.cpp", } else if (is_win) {
] sources += [ "ossource_win.cpp" ]
} else if (host_os == "win") {
sources += [
"ossource_win.cpp",
]
} }
configs += [ configs += [ ":swiftshader_opengl_compiler_private_config" ]
":swiftshader_opengl_compiler_private_config",
]
include_dirs = [ include_dirs = [
"..", "..",
......
...@@ -24,9 +24,7 @@ config("swiftshader_libEGL_private_config") { ...@@ -24,9 +24,7 @@ config("swiftshader_libEGL_private_config") {
] ]
if (is_clang) { if (is_clang) {
cflags += [ cflags += [ "-Wno-unused-function" ]
"-Wno-unused-function",
]
} }
} else { } else {
cflags = [ cflags = [
...@@ -54,29 +52,21 @@ shared_library("swiftshader_libEGL") { ...@@ -54,29 +52,21 @@ shared_library("swiftshader_libEGL") {
"resource.h", "resource.h",
] ]
if(is_debug) if(is_debug) {
{ sources += [ "../common/debug.cpp" ]
sources += [
"../common/debug.cpp",
]
} }
if (host_os == "mac") { if (is_mac) {
sources += [ sources += [ "OSXUtils.mm" ]
"OSXUtils.mm", libs = [
] "Quartz.framework",
} else if (host_os == "win") { "Cocoa.framework",
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" ] configs -= [ "//build/config/compiler:chromium_code" ]
......
...@@ -80,14 +80,9 @@ shared_library("swiftshader_libGLESv2") { ...@@ -80,14 +80,9 @@ shared_library("swiftshader_libGLESv2") {
"resource.h", "resource.h",
] ]
if (host_os == "win") { if (is_win) {
configs -= [ configs -= [ "//build/config/win:unicode" ]
"//build/config/win:unicode" ldflags = [ "/DEF:" + rebase_path("libGLESv2.def", root_build_dir) ]
]
ldflags = [
"/DEF:" + rebase_path("libGLESv2.def", root_build_dir),
]
} }
configs -= [ "//build/config/compiler:chromium_code" ] configs -= [ "//build/config/compiler:chromium_code" ]
......
...@@ -21,9 +21,7 @@ config("swiftshader_reactor_private_config") { ...@@ -21,9 +21,7 @@ config("swiftshader_reactor_private_config") {
] ]
if (is_clang) { if (is_clang) {
cflags += [ cflags += [ "-Wno-delete-incomplete" ]
"-Wno-delete-incomplete",
]
} }
} else { } else {
cflags = [ cflags = [
...@@ -48,18 +46,12 @@ source_set("swiftshader_reactor") { ...@@ -48,18 +46,12 @@ source_set("swiftshader_reactor") {
"RoutineManager.cpp", "RoutineManager.cpp",
] ]
if (host_os == "win") { if (is_win) {
sources += [ sources += [ "DLL.cpp" ]
"DLL.cpp", configs -= [ "//build/config/win:unicode" ]
]
configs -= [
"//build/config/win:unicode"
]
} }
configs += [ configs += [ ":swiftshader_reactor_private_config" ]
":swiftshader_reactor_private_config",
]
include_dirs = [ include_dirs = [
"..", "..",
......
...@@ -36,9 +36,7 @@ config("swiftshader_renderer_private_config") { ...@@ -36,9 +36,7 @@ config("swiftshader_renderer_private_config") {
} }
source_set("swiftshader_renderer") { source_set("swiftshader_renderer") {
deps = [ deps = [ "../Shader:swiftshader_shader" ]
"../Shader:swiftshader_shader",
]
sources = [ sources = [
"Blitter.cpp", "Blitter.cpp",
...@@ -60,15 +58,11 @@ source_set("swiftshader_renderer") { ...@@ -60,15 +58,11 @@ source_set("swiftshader_renderer") {
"VertexProcessor.cpp", "VertexProcessor.cpp",
] ]
if (host_os == "win") { if (is_win) {
configs -= [ configs -= [ "//build/config/win:unicode" ]
"//build/config/win:unicode"
]
} }
configs += [ configs += [ ":swiftshader_renderer_private_config" ]
":swiftshader_renderer_private_config",
]
include_dirs = [ include_dirs = [
".", ".",
......
...@@ -27,16 +27,12 @@ config("swiftshader_shader_private_config") { ...@@ -27,16 +27,12 @@ config("swiftshader_shader_private_config") {
] ]
} }
} else { } else {
cflags = [ cflags = [ "-DLOG_TAG=\"swiftshader_shader\"" ]
"-DLOG_TAG=\"swiftshader_shader\"",
]
} }
} }
source_set("swiftshader_shader") { source_set("swiftshader_shader") {
deps = [ deps = [ "../Main:swiftshader_main" ]
"../Main:swiftshader_main",
]
sources = [ sources = [
"Constants.cpp", "Constants.cpp",
...@@ -54,9 +50,7 @@ source_set("swiftshader_shader") { ...@@ -54,9 +50,7 @@ source_set("swiftshader_shader") {
"VertexShader.cpp", "VertexShader.cpp",
] ]
configs += [ configs += [ ":swiftshader_shader_private_config" ]
":swiftshader_shader_private_config",
]
include_dirs = [ include_dirs = [
".", ".",
......
...@@ -36,9 +36,7 @@ config("swiftshader_llvm_private_config") { ...@@ -36,9 +36,7 @@ config("swiftshader_llvm_private_config") {
] ]
if (!is_debug) { if (!is_debug) {
cflags += [ cflags += [ "/wd4324" ]
"/wd4324",
]
} }
if (is_clang) { if (is_clang) {
...@@ -442,34 +440,22 @@ source_set("swiftshader_llvm") { ...@@ -442,34 +440,22 @@ source_set("swiftshader_llvm") {
"lib/VMCore/Verifier.cpp", "lib/VMCore/Verifier.cpp",
] ]
if (host_os == "win") { if (is_win) {
configs -= [ configs -= [ "//build/config/win:unicode" ]
"//build/config/win:unicode"
]
} }
configs += [ configs += [ ":swiftshader_llvm_private_config" ]
":swiftshader_llvm_private_config",
]
include_dirs = [ include_dirs = [ "lib/Target/X86" ]
"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. # The "include-<platform>" directory includes the <platform> specific config file.
# Non-Windows platforms must add their platform specific include directory before the "include" directory # 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. # is added, otherwise, the Windows specific config file will be used and compilation will fail.
if (host_os == "linux") { if (is_linux) {
include_dirs += [ include_dirs += [ "include-linux" ]
"include-linux", } else if (is_mac) {
] include_dirs += [ "include-osx" ]
} else if (host_os == "mac") {
include_dirs += [
"include-mac",
]
} }
include_dirs += [ include_dirs += [ "include" ]
"include",
]
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment