Skip to content
Merged
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
12 changes: 12 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,15 @@ build --java_runtime_version=11
build --remote_cache=https://storage.googleapis.com/zipline-bazel-cache
test --test_output=errors
test --test_timeout=1200

# Enable platform-specific configuration
build --enable_platform_specific_config

# macOS-specific flags
build:macos --copt=-Wno-macro-redefined
build:macos --copt=-Wno-deprecated-non-prototype
build:macos --host_copt=-Wno-macro-redefined
build:macos --host_copt=-Wno-deprecated-non-prototype

# CI-specific flags
build:linux --copt=-Wno-deprecated-function
12 changes: 12 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@ workspace(name = "chronon")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "zlib",
sha256 = "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1",
strip_prefix = "zlib-1.2.11",
urls = [
"https://mirror.bazel.build/zlib.net/zlib-1.2.11.tar.gz",
"https://zlib.net/zlib-1.2.11.tar.gz",
],
build_file = "//third_party:zlib.BUILD",
)


# Load scala version from the config
load("//:scala_config.bzl", "scala_version")

Expand Down
16 changes: 16 additions & 0 deletions third_party/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package(default_visibility = ["//visibility:public"])

exports_files([
"zlib.BUILD",
])

config_setting(
name = "macos",
constraint_values = ["@platforms//os:macos"],
)

cc_library(
name = "macos_zlib_fix",
srcs = ["macos_zlib_fix.cc"],
visibility = ["//visibility:public"],
)
8 changes: 8 additions & 0 deletions third_party/macos_zlib_fix.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifdef __APPLE__
/* This provides a redefinition-safe fdopen on macOS as zlib is incompatible without it */
#include <stdio.h>

FILE* my_fdopen_wrapper(int fd, const char* mode) {
return fdopen(fd, mode);
}
#endif
Comment on lines +1 to +8
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Missing C linkage.
Wrapper must be declared extern "C" to avoid name mangling.

32 changes: 32 additions & 0 deletions third_party/zlib.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package(default_visibility = ["//visibility:public"])

# Import config_setting for macOS
config_setting(
name = "macos",
constraint_values = ["@platforms//os:macos"],
)

# Define zlib with conditional compilation flags
cc_library(
name = "zlib",
srcs = glob(["*.c"], exclude = ["example.c", "minigzip.c"]),
hdrs = glob(["*.h"]),
includes = ["."],
defines = select({
":macos": [
"HAVE_UNISTD_H",
"NO_FSEEKO",
"HAVE_STDARG_H",
"_DARWIN_C_SOURCE",
"fdopen=my_fdopen_wrapper", # Redefine fdopen to avoid conflicts
],
"//conditions:default": [],
}),
copts = select({
":macos": [
"-Wno-macro-redefined",
"-Wno-deprecated-non-prototype",
],
"//conditions:default": [],
}),
)