From 60c16c41cf3cbe2d91b506fceabe5f29b69c8368 Mon Sep 17 00:00:00 2001 From: Serge Bazanski Date: Sat, 8 May 2021 17:22:33 +0000 Subject: [PATCH] third_party/flatbuffers: add bashless patch --- WORKSPACE | 4 +++ third_party/flatbuffers/BUILD.bazel | 0 third_party/flatbuffers/bashless.diff | 47 +++++++++++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 third_party/flatbuffers/BUILD.bazel create mode 100644 third_party/flatbuffers/bashless.diff diff --git a/WORKSPACE b/WORKSPACE index cd64399..84df8d0 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -39,6 +39,10 @@ http_archive( urls = [ "https://github.com/google/flatbuffers/archive/ac203b20926b13a35ff85277d2e5d3c38698eee8.tar.gz", ], + patches = [ + "//third_party/flatbuffers:bashless.diff", + ], + patch_args = ["-p", "1"], ) http_archive( diff --git a/third_party/flatbuffers/BUILD.bazel b/third_party/flatbuffers/BUILD.bazel new file mode 100644 index 0000000..e69de29 diff --git a/third_party/flatbuffers/bashless.diff b/third_party/flatbuffers/bashless.diff new file mode 100644 index 0000000..11ffc40 --- /dev/null +++ b/third_party/flatbuffers/bashless.diff @@ -0,0 +1,47 @@ +This allows flatbuffers to be built via Bazel on Windows without MSYS/bash. + +This should, at some point, be upstreamed to the flatbuffers project, but there's more to be done here to 'fully' fix everything: + + - Fix the reflection genrule + - Investigate cmd_ps werrdness (see //.bazelrc, without this none of this works anyway) + - Investigate why only test //tests/... works. + +diff --git a/build_defs.bzl b/build_defs.bzl +index 88792be4..b1ea4b79 100644 +--- a/build_defs.bzl ++++ b/build_defs.bzl +@@ -73,7 +73,7 @@ def flatbuffer_library_public( + output_directory = ( + ("-o $(@D)/%s" % (out_prefix)) if len(srcs) > 1 else ("-o $(@D)") + ) +- genrule_cmd = " ".join([ ++ genrule_cmd_bash = " ".join([ + "SRCS=($(SRCS));", + "for f in $${SRCS[@]:0:%s}; do" % len(srcs), + "$(location %s)" % (flatc_path), +@@ -84,13 +84,24 @@ def flatbuffer_library_public( + "$$f;", + "done", + ]) ++ genrule_cmd_ps = " ".join([ ++ '"$(SRCS)".Split(" ") | ForEach {', ++ "$(location %s)" % (flatc_path), ++ " ".join(include_paths_cmd), ++ " ".join(flatc_args), ++ language_flag, ++ output_directory, ++ "$$_", ++ "}", ++ ]) + native.genrule( + name = name, + srcs = srcs + includes, + outs = outs, + output_to_bindir = output_to_bindir, + tools = [flatc_path], +- cmd = genrule_cmd, ++ cmd_bash = genrule_cmd_bash, ++ cmd_ps = genrule_cmd_ps, + compatible_with = compatible_with, + restricted_to = restricted_to, + message = ""