Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 70 additions & 20 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ is_loong64 = current_cpu == "loong64"
opts("hsw") {
enabled = is_x86
sources = skia_opts.hsw_sources
if (is_win) {
if (is_msvc) {
cflags = [ "/arch:AVX2" ]
} else {
cflags = [ "-march=haswell" ]
Expand All @@ -183,7 +183,7 @@ opts("hsw") {
opts("skx") {
enabled = is_x86
sources = skia_opts.skx_sources
if (is_win) {
if (is_msvc) {
cflags = [ "/arch:AVX512" ]
} else {
cflags = [ "-march=skylake-avx512" ]
Expand Down Expand Up @@ -497,7 +497,11 @@ optional("fontmgr_win_gdi") {
public_defines = [ "SK_FONTMGR_GDI_AVAILABLE" ]
public = skia_ports_windows_fonts_public
sources = skia_ports_fonthost_win_sources
libs = [ "Gdi32.lib" ]
if (is_msvc) {
libs = [ "Gdi32.lib" ]
} else {
libs = [ "gdi32" ]
}
}

if (skia_lex) {
Expand Down Expand Up @@ -898,7 +902,31 @@ optional("gpu_shared") {

if (skia_use_dawn) {
public_defines += [ "SK_DAWN" ]
public_deps += [ "//third_party/dawn" ]

# When building for WASM, the WebGPU headers are provided by Emscripten. For native builds we
# have to depend on Dawn directly.
if (!skia_use_webgpu) {
public_deps += [
"//third_party/externals/dawn/include/dawn:cpp_headers",
"//third_party/externals/dawn/src/dawn:cpp",
"//third_party/externals/dawn/src/dawn:proc",
]

if (dawn_enable_d3d12 || dawn_enable_d3d11 || dawn_enable_desktop_gl ||
dawn_enable_metal || dawn_enable_opengles || dawn_enable_vulkan) {
public_deps += [ "//third_party/externals/dawn/src/dawn/native" ]
}
if (dawn_enable_d3d12) {
if (is_msvc) {
libs += ["d3d12.lib", "dxgi.lib", "d3dcompiler.lib"]
} else {
libs += ["d3d12", "dxgi", "d3dcompiler"]
}

} else if (dawn_enable_metal) {
frameworks += [ "Metal.framework" ]
}
}
}

if (skia_use_direct3d) {
Expand Down Expand Up @@ -1001,7 +1029,12 @@ optional("gpu") {
"src/gpu/ganesh/gl/win/GrGLMakeWinInterface.cpp",
]
if (target_cpu != "arm64") {
libs += [ "OpenGL32.lib" ]
if (is_msvc) {
libs += [ "OpenGL32.lib" ]
} else {
libs += [ "opengl32" ]
}

}
} else {
sources += [ "src/gpu/ganesh/gl/GrGLMakeNativeInterface_none.cpp" ]
Expand All @@ -1026,11 +1059,19 @@ optional("gpu") {
if (skia_enable_direct3d_debug_layer) {
public_defines += [ "SK_ENABLE_D3D_DEBUG_LAYER" ]
}
libs += [
"d3d12.lib",
"dxgi.lib",
"d3dcompiler.lib",
]
if(is_msvc) {
libs += [
"d3d12.lib",
"dxgi.lib",
"d3dcompiler.lib",
]
} else {
libs += [
"d3d12",
"dxgi",
"d3dcompiler",
]
}
}

cflags_objcc = []
Expand Down Expand Up @@ -1760,17 +1801,18 @@ skia_component("skia") {
"src/ports/SkDebug_win.cpp",
"src/ports/SkImageGeneratorWIC.cpp",
]
libs += [
"Ole32.lib",
"OleAut32.lib",
]

if(is_msvc) {
libs += ["Ole32.lib","OleAut32.lib"]
} else {
libs += ["ole32","oleaut32"]
}
if (!skia_enable_winuwp) {
libs += [
"FontSub.lib",
"User32.lib",
"Usp10.lib",
]
if(is_msvc) {
libs += ["FontSub.lib", "User32.lib", "Usp10.lib"]
} else {
libs += ["fontsub", "user32", "usp10"]
}

}
} else {
sources += [ "src/ports/SkOSFile_posix.cpp" ]
Expand Down Expand Up @@ -1927,6 +1969,14 @@ action("skia.h") {
outputs = [ skia_h ]
}

config("cpp17") {
if (is_msvc) {
cflags_cc = [ "/std:c++17" ]
} else {
cflags_cc = [ "-std=c++17" ]
}
}

skia_source_set("public_headers_warnings_check") {
sources = [ "tools/public_headers_warnings_check.cpp" ]
configs = [ ":use_skia_vulkan_headers" ]
Expand Down
38 changes: 34 additions & 4 deletions gn/BUILDCONFIG.gn
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,36 @@ is_mac = current_os == "mac"
is_wasm = current_os == "wasm"
is_win = current_os == "win"

declare_args() {
extra_asmflags = []
extra_cflags = []
extra_cflags_c = []
extra_cflags_cc = []
extra_ldflags = []
malloc = ""
werror = false
xcode_sysroot = ""
}

target_triple = ""
foreach(flag, extra_cflags) {
if (flag == "--target" || flag == "-target") {
} else {
parts = []
parts = string_split(flag, "=")
if (parts[0] == "--target" || parts[0] == "-target") {
target_triple = parts[1]
}
}
}
is_mingw = (string_replace(target_triple, "mingw", "") != target_triple) ||
(string_replace(target_triple, "windows-gnu", "") != target_triple)
is_msvc = !is_mingw

if (is_mingw) {
extra_cflags += ["-mno-avx512f","-mno-avx512vl","-mpclmul"]
}

# Dawn has references to fuchsia, but Skia's GN rules do not
is_fuchsia = false

Expand Down Expand Up @@ -128,7 +158,7 @@ if (is_android) {
}
}

if (target_os == "win") {
if (is_msvc) {
# By default we look for 2017 (Enterprise, Pro, and Community), then 2015. If MSVC is installed in a
# non-default location, you can set win_vc to inform us where it is.

Expand All @@ -139,11 +169,11 @@ if (target_os == "win") {
# directory.
}

if (target_os == "win") {
if (is_msvc) {
if (win_toolchain_version == "") {
win_toolchain_version = exec_script("//gn/highest_version_dir.py",
[
"$win_vc/Tools/MSVC",
"$win_vc/tools/msvc",
"[0-9]{2}\.[0-9]{2}\.[0-9]{5}",
],
"trim string")
Expand Down Expand Up @@ -233,7 +263,7 @@ if (!is_official_build) {
[ "//gn/skia:warnings_for_public_headers" ]
}

if (is_win) {
if (is_msvc) {
# Windows tool chain
set_default_toolchain("//gn/toolchain:msvc")
default_toolchain_name = "msvc"
Expand Down
2 changes: 1 addition & 1 deletion gn/portable/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ config("add_exceptions") {
}

config("add_rtti") {
if (is_win) {
if (is_msvc) {
cflags_cc = [ "/GR" ]
} else {
cflags_cc = [ "-frtti" ]
Expand Down
59 changes: 31 additions & 28 deletions gn/skia/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,6 @@ if (is_wasm) {

import("../skia.gni")

declare_args() {
extra_asmflags = []
extra_cflags = []
extra_cflags_c = []
extra_cflags_cc = []
extra_ldflags = []

malloc = ""
werror = false
xcode_sysroot = ""
}

if (is_ios && xcode_sysroot == "") {
if (is_tvos) {
sdk = "appletvos"
Expand Down Expand Up @@ -59,12 +47,12 @@ config("default") {
# Disable warnings about unknown attributes.
# (These unknown attribute warnings are on by default, so we don't make
# disabling them part of :warnings, as some targets remove :warnings.)
if (is_win && !is_clang) {
if (is_msvc && !is_clang) {
cflags += [
"/wd5030",
"/wd5051",
]
} else {
} else if (!is_mingw) {
cflags += [ "-Wno-attributes" ]
}

Expand All @@ -74,7 +62,7 @@ config("default") {
cflags += [ "-ffp-contract=off" ]
}

if (is_win) {
if (is_msvc) {
if (is_clang && current_cpu == "arm64") {
cflags += [ "--target=arm64-windows" ]
}
Expand Down Expand Up @@ -120,6 +108,16 @@ config("default") {
"$win_vc/Tools/MSVC/$win_toolchain_version/lib/$current_cpu",
]
} else {
if (is_mingw) {
if (target_cpu == "arm64") {
cflags += ["-march=armv8-a+simd+fp"]
} else {
cflags += ["-mavx2", "-mavx512f", "-mf16c", "-mfma"]
}
cflags += ["-fpermissive", "-fstrict-aliasing", "-fvisibility=default"]
} else {
cflags += ["-fstrict-aliasing", "-fPIC", "-fvisibility=hidden"]
}
cflags += [
"-fPIC",
"-fvisibility=hidden",
Expand Down Expand Up @@ -158,15 +156,20 @@ config("default") {
]
libs += [ malloc ]
}

if (is_mingw) {
defines += ["_CRT_SECURE_NO_WARNINGS", "WIN32_LEAN_AND_MEAN", "NOMINMAX"]
if (!is_clang) {
cflags += ["-Wno-attributes", "-Wno-stringop-overflow"]
}
}
if (is_android) {
cflags += [ "--sysroot=$ndk/toolchains/llvm/prebuilt/$ndk_host/sysroot" ]
ldflags += [ "-static-libstdc++" ]
}

if (show_includes) {
assert(is_clang, "show_includes requires clang to build.")
if (is_win) {
if (is_msvc) {
cflags += [
"/clang:-H",
"/clang:-fshow-skipped-includes",
Expand All @@ -189,8 +192,6 @@ config("default") {
_arch_flags = [
"-arch",
"arm64",
"-arch",
"arm64e",
]
} else if (current_cpu == "x86") {
_arch_flags = [
Expand Down Expand Up @@ -346,7 +347,7 @@ config("default") {
cflags += [ "-fno-sanitize=function" ]
}

if (is_win) {
if (is_msvc) {
cflags += [
# On Release builds, we get strange warnings about string literals.
"/GF-",
Expand Down Expand Up @@ -385,7 +386,7 @@ config("recover_pointer_overflow") {

config("no_exceptions") {
# Exceptions are disabled by default on Windows. (Use /EHsc to enable them.)
if (!is_win) {
if (!is_msvc) {
cflags_cc = [ "-fno-exceptions" ]
cflags_objcc = cflags_cc
}
Expand All @@ -398,14 +399,14 @@ config("warnings") {
cflags_objcc = []

if (werror) {
if (is_win) {
if (is_msvc) {
cflags += [ "/WX" ]
} else {
cflags += [ "-Werror" ]
}
}

if (is_win) {
if (is_msvc) {
cflags += [
"/W3", # Turn on lots of warnings.

Expand Down Expand Up @@ -652,7 +653,7 @@ config("debug_symbols") {
"-gline-tables-only",
"-funwind-tables", # Helps make in-process backtraces fuller.
]
} else if (is_win) {
} else if (is_msvc) {
cflags = [ "/Z7" ]
if (is_clang) {
cflags += [ "-gcodeview-ghash" ]
Expand All @@ -672,7 +673,7 @@ config("no_rtti") {
# -fsanitize=vptr requires RTTI which is enabled as a part of
# -fsanitize=undefined
if (sanitize != "ASAN") {
if (is_win) {
if (is_msvc) {
cflags_cc = [ "/GR-" ]
} else {
cflags_cc = [ "-fno-rtti" ]
Expand All @@ -683,7 +684,7 @@ config("no_rtti") {

config("optimize") {
ldflags = []
if (is_win) {
if (is_msvc) {
cflags = [
"/O2",
"/Zc:inline",
Expand All @@ -698,7 +699,7 @@ config("optimize") {
} else {
if (skia_enable_optimize_size) {
cflags = [ "-Oz" ]
if (!is_android) {
if (!is_android && !is_mingw) {
cflags += [
# Clang 15 turns PIE (Position-indendendent Executable) on by default.
"-fno-PIE",
Expand Down Expand Up @@ -761,7 +762,9 @@ config("executable") {
"-rdynamic",
"-Wl,-rpath,\$ORIGIN",
]
} else if (is_win) {
} else if (is_mingw) {
ldflags = [ "-mconsole" ]
} else if (is_msvc) {
ldflags = [
"/SUBSYSTEM:CONSOLE", # Quiet "no subsystem specified; CONSOLE assumed".
"/INCREMENTAL:NO", # Quiet warnings about failing to incrementally link
Expand Down
Loading