diff --git a/WORKSPACE b/WORKSPACE index 7ca808505..4f7bb3b2e 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -176,6 +176,25 @@ http_archive( ], ) +# 2023-06-05 +# This version of Glog is required for Windows support, but currently causes +# crashes on some Android devices. +http_archive( + name = "com_github_glog_glog_windows", + strip_prefix = "glog-3a0d4d22c5ae0b9a2216988411cfa6bf860cc372", + sha256 = "170d08f80210b82d95563f4723a15095eff1aad1863000e8eeb569c96a98fefb", + urls = [ + "https://github.com/google/glog/archive/3a0d4d22c5ae0b9a2216988411cfa6bf860cc372.zip", + ], + patches = [ + "@//third_party:com_github_glog_glog.diff", + "@//third_party:com_github_glog_glog_windows_patch.diff", + ], + patch_args = [ + "-p1", + ], +) + # easyexif http_archive( name = "easyexif", diff --git a/third_party/BUILD b/third_party/BUILD index 229252087..d784fc3cc 100644 --- a/third_party/BUILD +++ b/third_party/BUILD @@ -45,7 +45,7 @@ cc_library( "@com_github_glog_glog//:glog", ], "//mediapipe:windows": [ - "@com_github_glog_glog//:glog", + "@com_github_glog_glog_windows//:glog", ], "//conditions:default": [ "@com_github_glog_glog//:glog", diff --git a/third_party/com_github_glog_glog.diff b/third_party/com_github_glog_glog.diff index 1e83001bd..bf08045b3 100644 --- a/third_party/com_github_glog_glog.diff +++ b/third_party/com_github_glog_glog.diff @@ -39,18 +39,3 @@ index 4028ccc..483e639 100644 if (append_newline) { // Fix the ostrstream back how it was before we screwed with it. // It's 99.44% certain that we don't need to worry about doing this. - -diff --git a/bazel/glog.bzl b/bazel/glog.bzl -index 4208d9e..3c86abf 100644 ---- a/bazel/glog.bzl -+++ b/bazel/glog.bzl -@@ -180,6 +180,9 @@ def glog_library(namespace = "google", with_gflags = 1, **kwargs): - }), - copts = - select({ -+ "@bazel_tools//src/conditions:windows": ["-std=c++17"], -+ "//conditions:default": [], -+ }) + select({ - "@bazel_tools//src/conditions:windows": common_copts + windows_only_copts, - "@bazel_tools//src/conditions:darwin": common_copts + linux_or_darwin_copts + darwin_only_copts, - "@bazel_tools//src/conditions:freebsd": common_copts + linux_or_darwin_copts + freebsd_only_copts, diff --git a/third_party/com_github_glog_glog_windows_patch.diff b/third_party/com_github_glog_glog_windows_patch.diff new file mode 100644 index 000000000..250be1110 --- /dev/null +++ b/third_party/com_github_glog_glog_windows_patch.diff @@ -0,0 +1,26 @@ +diff --git a/bazel/glog.bzl b/bazel/glog.bzl +index dacd934..d7b3d78 100644 +--- a/bazel/glog.bzl ++++ b/bazel/glog.bzl +@@ -53,7 +53,6 @@ def glog_library(namespace = "google", with_gflags = 1, **kwargs): + ) + + common_copts = [ +- "-std=c++14", + "-DGLOG_BAZEL_BUILD", + # Inject a C++ namespace. + "-DGOOGLE_NAMESPACE='%s'" % namespace, +@@ -145,7 +144,13 @@ def glog_library(namespace = "google", with_gflags = 1, **kwargs): + ], + }) + ++ c14_opts = ["-std=c++14"] ++ c17_opts = ["-std=c++17"] ++ + final_lib_copts = select({ ++ "@bazel_tools//src/conditions:windows": c17_opts, ++ "//conditions:default": c14_opts, ++ }) + select({ + "@bazel_tools//src/conditions:windows": common_copts + windows_only_copts, + "@bazel_tools//src/conditions:darwin": common_copts + linux_or_darwin_copts + darwin_only_copts, + "@bazel_tools//src/conditions:freebsd": common_copts + linux_or_darwin_copts + freebsd_only_copts,