Fix the TF wheel build on Windows.
PiperOrigin-RevId: 355400706
Change-Id: I28de129edc73a1ede72c1276d8e11c9737f1c220
diff --git a/third_party/flatbuffers/build_defs.bzl b/third_party/flatbuffers/build_defs.bzl
index 8f79cef..e0fe108 100644
--- a/third_party/flatbuffers/build_defs.bzl
+++ b/third_party/flatbuffers/build_defs.bzl
@@ -379,13 +379,18 @@
)
def _concat_flatbuffer_py_srcs_impl(ctx):
- # Merge all generated python files.
- command = "find '%s' -name '*.py' -exec cat {} + | sed '/import flatbuffers/d'"
- command += " | sed '1s/^/import flatbuffers\\'$'\\n/' > %s"
+ # Merge all generated python files. The files are concatenated and import
+ # statements are removed. Finally we import the flatbuffer runtime library.
+ # IMPORTANT: Our Windows shell does not support "find ... -exec" properly.
+ # If you're changing the commandline below, please build wheels and run smoke
+ # tests on all the three operating systems.
+ command = "echo 'import flatbuffers\n' > %s; "
+ command += "for f in $(find %s -name '*.py'); do cat $f | sed '/import flatbuffers/d' >> %s; done "
ctx.actions.run_shell(
inputs = ctx.attr.deps[0].files,
outputs = [ctx.outputs.out],
command = command % (
+ ctx.outputs.out.path,
ctx.attr.deps[0].files.to_list()[0].path,
ctx.outputs.out.path,
),