aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar herb <herb@google.com>2016-09-16 13:29:57 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-09-16 13:29:57 -0700
commitb6318bf44dd89dc8465dcf48ba820701eae24acb (patch)
tree6ad7f01fed3c966fcdf7fcb87b66509a18f35f93
parent3b294d5ba96b68ae1cbe59cfea29b112959cca09 (diff)
Compile the skia library for windows using gn.
TBR=mtklein@google.com BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2347443002 Review-Url: https://codereview.chromium.org/2347443002
-rw-r--r--BUILD.gn2
-rw-r--r--gn/BUILD.gn354
-rw-r--r--gn/BUILDCONFIG.gn9
-rw-r--r--third_party/sfntly/BUILD.gn4
-rw-r--r--third_party/third_party.gni6
5 files changed, 253 insertions, 122 deletions
diff --git a/BUILD.gn b/BUILD.gn
index cc608f35af..23fca35cc6 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -481,7 +481,7 @@ component("skia") {
"src/ports/SkTypeface_win_dw.cpp",
"src/xps/SkDocument_XPS.cpp",
]
- sources -= [ "src/utils/SkThreadUtils_pthread.cpp" ]
+ sources -= [ get_path_info("src/utils/SkThreadUtils_pthread.cpp", "abspath") ]
} else {
sources += [
"src/ports/SkOSFile_posix.cpp",
diff --git a/gn/BUILD.gn b/gn/BUILD.gn
index aee8faebb4..7beefa1339 100644
--- a/gn/BUILD.gn
+++ b/gn/BUILD.gn
@@ -14,6 +14,8 @@ declare_args() {
cxx = "$ndk/toolchains/llvm/prebuilt/$ndk_host/bin/clang++"
}
+ windk = ""
+
extra_cflags = ""
extra_cflags_c = ""
extra_cflags_cc = ""
@@ -22,140 +24,162 @@ declare_args() {
compiler_prefix = ""
}
-config("no_rtti") {
- if (sanitize != "ASAN") { # -fsanitize=vptr requires RTTI
- cflags_cc = [ "-fno-rtti" ]
+if (is_win) {
+ config("default") {
+ cflags = [
+ "/FS", # Preserve previous PDB behavior.
+ "/bigobj", # Some of our files are bigger than the regular limits.
+ ]
+ cflags_c = ["/TC"]
+ cflags_cc = ["/TP"]
+ defines = [
+ "_HAS_EXCEPTIONS=0",
+ "WIN32_LEAN_AND_MEAN",
+ "NOMINMAX",
+ ]
}
-}
+ config("no_rtti") { }
-config("debug_symbols") {
- # It's annoying to wait for full debug symbols to push over
- # to Android devices. -gline-tables-only is a lot slimmer.
- if (is_android) {
- cflags = [ "-gline-tables-only" ]
- } else {
- cflags = [ "-g" ]
+ config("debug_symbols") { }
+
+} else {
+ config("debug_symbols") {
+ # It's annoying to wait for full debug symbols to push over
+ # to Android devices. -gline-tables-only is a lot slimmer.
+ if (is_android) {
+ cflags = [ "-gline-tables-only" ]
+ } else {
+ cflags = [ "-g" ]
+ }
}
-}
-config("default") {
- asmflags = []
- cflags = [
- "-O1",
- "-fstrict-aliasing",
- "-fPIC",
- "-fvisibility=hidden",
-
- "-Werror",
- "-Wall",
- "-Wextra",
- "-Winit-self",
- "-Wpointer-arith",
- "-Wsign-compare",
- "-Wvla",
-
- "-Wno-deprecated-declarations",
- "-Wno-unused-parameter",
- ]
- cflags_cc = [
- "-std=c++11",
- "-fno-exceptions",
- "-fno-threadsafe-statics",
- "-fvisibility-inlines-hidden",
-
- "-Wnon-virtual-dtor",
- ]
- ldflags = []
-
- if (current_cpu == "arm") {
- cflags += [
- "-march=armv7-a",
- "-mfpu=neon",
- "-mthumb",
- ]
- } else if (current_cpu == "mipsel") {
- cflags += [
- "-march=mips32r2",
- "-mdspr2",
- ]
- } else if (current_cpu == "x86") {
- asmflags += [ "-m32" ]
- cflags += [
- "-m32",
- "-msse2",
- "-mfpmath=sse",
- ]
- ldflags += [ "-m32" ]
+ config("no_rtti") {
+ if (sanitize != "ASAN") { # -fsanitize=vptr requires RTTI
+ cflags_cc = [ "-fno-rtti" ]
+ }
}
- if (is_android) {
- asmflags += [
- "--target=$ndk_target",
- "-B$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin",
- ]
- cflags += [
- "--sysroot=$ndk/platforms/$ndk_platform",
- "--target=$ndk_target",
- "-B$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin",
- ]
- cflags_cc += [
- "-isystem$ndk/sources/android/support/include",
- "-isystem$ndk/sources/cxx-stl/llvm-libc++/libcxx/include",
- ]
- ldflags += [
- "--sysroot=$ndk/platforms/$ndk_platform",
- "--target=$ndk_target",
- "-B$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin",
- "-pie",
- ]
- lib_dirs = [
- "$ndk/sources/cxx-stl/llvm-libc++/libs/$ndk_stdlib",
- "$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/lib/gcc/$ndk_target/4.9.x",
+ config("default") {
+ asmflags = []
+ cflags = [
+ "-O1",
+ "-fstrict-aliasing",
+ "-fPIC",
+ "-fvisibility=hidden",
+
+ "-Werror",
+ "-Wall",
+ "-Wextra",
+ "-Winit-self",
+ "-Wpointer-arith",
+ "-Wsign-compare",
+ "-Wvla",
+
+ "-Wno-deprecated-declarations",
+ "-Wno-unused-parameter",
]
- libs = [
- # Order matters here! Keep these three in exactly this order.
- "c++_static",
- "c++abi",
- "android_support",
+ cflags_cc = [
+ "-std=c++11",
+ "-fno-exceptions",
+ "-fno-threadsafe-statics",
+ "-fvisibility-inlines-hidden",
+
+ "-Wnon-virtual-dtor",
]
- if (target_cpu == "arm") {
- libs += [ "unwind" ]
+ ldflags = []
+
+ if (current_cpu == "arm") {
+ cflags += [
+ "-march=armv7-a",
+ "-mfpu=neon",
+ "-mthumb",
+ ]
+ } else if (current_cpu == "mipsel") {
+ cflags += [
+ "-march=mips32r2",
+ "-mdspr2",
+ ]
+ } else if (current_cpu == "x86") {
+ asmflags += [ "-m32" ]
+ cflags += [
+ "-m32",
+ "-msse2",
+ "-mfpmath=sse",
+ ]
+ ldflags += [ "-m32" ]
}
- }
- if (is_linux) {
- libs = [ "pthread" ]
- }
+ if (is_android) {
+ asmflags += [
+ "--target=$ndk_target",
+ "-B$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin",
+ ]
+ cflags += [
+ "--sysroot=$ndk/platforms/$ndk_platform",
+ "--target=$ndk_target",
+ "-B$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin",
+ ]
+ cflags_cc += [
+ "-isystem$ndk/sources/android/support/include",
+ "-isystem$ndk/sources/cxx-stl/llvm-libc++/libcxx/include",
+ ]
+ ldflags += [
+ "--sysroot=$ndk/platforms/$ndk_platform",
+ "--target=$ndk_target",
+ "-B$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin",
+ "-pie",
+ ]
+ lib_dirs = [
+ "$ndk/sources/cxx-stl/llvm-libc++/libs/$ndk_stdlib",
+ "$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/lib/gcc/$ndk_target/4.9.x",
+ ]
- if (sanitize != "") {
- # You can either pass the sanitizers directly, e.g. "address,undefined",
- # or pass one of the couple common aliases used by the bots.
- sanitizers = sanitize
- if (sanitize == "ASAN") {
- sanitizers = "address,bool,function,integer-divide-by-zero,nonnull-attribute,null,object-size,return,returns-nonnull-attribute,shift,signed-integer-overflow,unreachable,vla-bound,vptr"
- } else if (sanitize == "TSAN") {
- sanitizers = "thread"
- } else if (sanitize == "MSAN") {
- sanitizers = "memory"
+ libs = [
+ # Order matters here! Keep these three in exactly this order.
+ "c++_static",
+ "c++abi",
+ "android_support",
+ ]
+ if (target_cpu == "arm") {
+ libs += [ "unwind" ]
+ }
}
- cflags += [
- "-fsanitize=$sanitizers",
- "-fno-sanitize-recover=$sanitizers",
- "-fsanitize-blacklist=" + rebase_path("../tools/xsan.blacklist"),
- ]
- ldflags += [ "-fsanitize=$sanitizers" ]
- if (sanitizers == "memory") {
- cflags += [ "-fsanitize-memory-track-origins" ]
- cflags_cc += [ "-stdlib=libc++" ]
- ldflags += [ "-stdlib=libc++" ]
+ if (is_linux) {
+ libs = [ "pthread" ]
+ }
+
+ if (sanitize != "") {
+ # You can either pass the sanitizers directly, e.g. "address,undefined",
+ # or pass one of the couple common aliases used by the bots.
+ sanitizers = sanitize
+ if (sanitize == "ASAN") {
+ sanitizers = "address,bool,function,integer-divide-by-zero,nonnull-attribute,null,object-size,return,returns-nonnull-attribute,shift,signed-integer-overflow,unreachable,vla-bound,vptr"
+ } else if (sanitize == "TSAN") {
+ sanitizers = "thread"
+ } else if (sanitize == "MSAN") {
+ sanitizers = "memory"
+ }
+
+ cflags += [
+ "-fsanitize=$sanitizers",
+ "-fno-sanitize-recover=$sanitizers",
+ "-fsanitize-blacklist=" + rebase_path("../tools/xsan.blacklist"),
+ ]
+ ldflags += [ "-fsanitize=$sanitizers" ]
+ if (sanitizers == "memory") {
+ cflags += [ "-fsanitize-memory-track-origins" ]
+ cflags_cc += [ "-stdlib=libc++" ]
+ ldflags += [ "-stdlib=libc++" ]
+ }
}
}
-}
-config("release") {
- cflags = [ "-O3" ]
- defines = [ "NDEBUG" ]
+ config("release") {
+ cflags = [ "-O3" ]
+ defines = [ "NDEBUG" ]
+ }
+
}
config("executable") {
@@ -169,6 +193,100 @@ config("executable") {
}
}
+toolchain("msvc") {
+ vc = "$windk\VC\bin\amd64\cl.exe"
+ vlink = "$windk\VC\bin\amd64\link.exe"
+ vlib = "$windk\VC\bin\amd64\lib.exe"
+ # TODO: add a python function that generates the includes using <VSPATH>/win_sdk/bin/SetEnv.<cpu>.json
+ windk_include_dirs = "/I$windk\win_sdk\bin\..\..\win_sdk\Include\10.0.10586.0\um /I$windk\win_sdk\bin\..\..\win_sdk\Include\10.0.10586.0\shared /I$windk\win_sdk\bin\..\..\win_sdk\Include\10.0.10586.0\winrt /I$windk\win_sdk\bin\..\..\win_sdk\Include\10.0.10586.0\ucrt /I$windk\win_sdk\bin\..\..\VC\include /I$windk\win_sdk\bin\..\..\VC\atlmfc\include "
+
+ tool("cc") {
+ rspfile = "{{output}}.rsp"
+ precompiled_header_type = "msvc"
+ pdbname = "{{target_out_dir}}/{{label_name}}_c.pdb"
+
+ # Label names may have spaces in them so the pdbname must be quoted. The
+ # source and output don't need to be quoted because GN knows they're a
+ # full file name and will quote automatically when necessary.
+
+ command = "$vc /nologo /showIncludes /FC @$rspfile /c {{source}} /Fo{{output}} /Fd\"$pdbname\""
+ depsformat = "msvc"
+ description = "CC {{output}}"
+ outputs = [
+ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj",
+ # "$object_subdir/{{source_name_part}}.obj",
+ ]
+ rspfile_content = "$windk_include_dirs {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}}"
+ }
+
+ tool("cxx") {
+ rspfile = "{{output}}.rsp"
+ precompiled_header_type = "msvc"
+ pdbname = "{{target_out_dir}}/{{label_name}}_c.pdb"
+
+ # Label names may have spaces in them so the pdbname must be quoted. The
+ # source and output don't need to be quoted because GN knows they're a
+ # full file name and will quote automatically when necessary.
+ command = "$vc /nologo /showIncludes /FC @$rspfile /c {{source}} /Fo{{output}} /Fd\"$pdbname\""
+ depsformat = "msvc"
+ description = "C++ {{output}}"
+ outputs = [
+ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj",
+ ]
+ rspfile_content = "$windk_include_dirs {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}}"
+ }
+
+ tool("alink") {
+ rspfile = "{{output}}.rsp"
+ # gyp_win_tool_path = rebase_path("../third_party/externals/gyp/pylib/gyp/win_tool.py")
+ command = "$vlib /nologo {{arflags}} /OUT:{{output}} @$rspfile"
+ description = "LIB {{output}}"
+ outputs = [
+ # Ignore {{output_extension}} and always use .lib, there's no reason to
+ # allow targets to override this extension on Windows.
+ "{{root_out_dir}}/{{target_output_name}}{{output_extension}}",
+ ]
+ default_output_extension = ".lib"
+ default_output_dir = "{{target_out_dir}}"
+
+ # The use of inputs_newline is to work around a fixed per-line buffer
+ # size in the linker.
+ rspfile_content = "{{inputs_newline}}"
+ }
+
+ tool("link") {
+ exename = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}"
+ pdbname = "$exename.pdb"
+ rspfile = "$exename.rsp"
+
+ # gyp_win_tool_path = rebase_path("../third_party/externals/gyp/pylib/gyp/win_tool.py")
+ command = "$vlink /nologo /OUT:$exename /PDB:$pdbname @$rspfile"
+
+ default_output_extension = ".exe"
+ default_output_dir = "{{root_out_dir}}"
+ description = "LINK {{output}}"
+ outputs = [
+ #"{{root_out_dir}}/{{target_output_name}}{{output_extension}}",
+ exename,
+ ]
+ #if (symbol_level != 0) {
+ # outputs += [ pdbname ]
+ #}
+ #runtime_outputs = outputs
+
+ # The use of inputs_newline is to work around a fixed per-line buffer
+ # size in the linker.
+ rspfile_content = "{{inputs_newline}} {{libs}} {{solibs}} {{ldflags}}"
+ }
+
+
+ tool("stamp") {
+ win_stamp_path = rebase_path("win_stamp.py")
+ command = "python $win_stamp_path {{output}}"
+ }
+}
+
+
toolchain("gcc_like") {
lib_switch = "-l"
lib_dir_switch = "-L"
diff --git a/gn/BUILDCONFIG.gn b/gn/BUILDCONFIG.gn
index 79d06f400b..e294854aa7 100644
--- a/gn/BUILDCONFIG.gn
+++ b/gn/BUILDCONFIG.gn
@@ -147,5 +147,10 @@ set_defaults("component") {
}
}
-# For now, we support GCC-like toolchains, including Clang.
-set_default_toolchain("//gn:gcc_like")
+if (is_win) {
+ # Windows tool chain
+ set_default_toolchain("//gn:msvc")
+} else {
+ # GCC-like toolchains, including Clang.
+ set_default_toolchain("//gn:gcc_like")
+}
diff --git a/third_party/sfntly/BUILD.gn b/third_party/sfntly/BUILD.gn
index 845c6ed198..1e418a16e9 100644
--- a/third_party/sfntly/BUILD.gn
+++ b/third_party/sfntly/BUILD.gn
@@ -70,4 +70,8 @@ third_party("sfntly") {
"../externals/sfntly/cpp/src/sfntly/tools/subsetter/subsetter.cc",
"../externals/sfntly/cpp/src/sfntly/tools/subsetter/table_subsetter_impl.cc",
]
+
+ if (is_win) {
+ defines += [ "WIN32", ]
+ }
}
diff --git a/third_party/third_party.gni b/third_party/third_party.gni
index 34751c0286..37b1e03687 100644
--- a/third_party/third_party.gni
+++ b/third_party/third_party.gni
@@ -12,7 +12,11 @@ template("third_party") {
public_configs = [ ":" + target_name + "_public" ]
# Warnings are just noise if we're not maintaining the code.
- cflags = [ "-w" ]
+ if (is_win) {
+ cflags = [ "/w" ]
+ } else {
+ cflags = [ "-w" ]
+ }
}
}