Skip to content
Draft
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
29 changes: 27 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
workspace(name = "ml_metadata")

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

github_archive(
name = "rules_cc",
repo = "https://github.com/bazelbuild/rules_cc",
commit = "818289e5613731ae410efb54218a4077fb9dbb03",
sha256 = "0adbd6f567291ad526e82c765e15aed33cea5e256eeba129f1501142c2c56610",
patches = [
"//ml_metadata/third_party:rules_cc.patch",
"//ml_metadata/third_party:rules_cc_2.patch"
]
)

http_archive(
name = "postgresql",
build_file = "//ml_metadata:postgresql.BUILD",
Expand Down Expand Up @@ -39,7 +51,10 @@ http_archive(
)

load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies")
rules_foreign_cc_dependencies()
rules_foreign_cc_dependencies(
register_preinstalled_tools = True,
register_built_tools = False,
)

http_archive(
name = "com_google_absl",
Expand Down Expand Up @@ -106,6 +121,14 @@ http_archive(
build_file = "//ml_metadata/third_party:six.BUILD"
)

github_archive(
name = "upb",
repo = "https://github.com/protocolbuffers/upb",
commit = "230d502d6ea96fc9d40f02ad26c20fe85a627648",
sha256 = "28488db7f638ed5a433f7ac3b67e6b62932c155c2cd9987a2c534a3591f3b2dd",
patches = ["//ml_metadata/third_party:upb.patch",],
)

http_archive(
name = "com_google_protobuf",
sha256 = "1add10f9bd92775b91f326da259f243881e904dd509367d5031d4c782ba82810",
Expand Down Expand Up @@ -252,7 +275,9 @@ http_archive(
name = "com_google_zetasql",
urls = ["https://github.com/google/zetasql/archive/%s.zip" % ZETASQL_COMMIT],
strip_prefix = "zetasql-%s" % ZETASQL_COMMIT,
#patches = ["//ml_metadata/third_party:zetasql.patch"],
patches = [
"//ml_metadata/third_party:zetasql_2.patch",
],
sha256 = '651a768cd51627f58aa6de7039aba9ddab22f4b0450521169800555269447840'
)

Expand Down
5 changes: 4 additions & 1 deletion ml_metadata/mysql_configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,8 @@ def mysql_configure():
workspace_file = "//ml_metadata:libmysqlclient.WORKSPACE",
remote = "https://github.com/MariaDB/mariadb-connector-c.git",
tag = "v3.0.8-release",
patches = ["//ml_metadata/third_party:libmysqlclient.patch"],
patches = [
"//ml_metadata/third_party:libmysqlclient.patch",
"//ml_metadata/third_party:libmysqlclient_2.patch",
],
)
4 changes: 3 additions & 1 deletion ml_metadata/postgresql.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -1146,7 +1146,9 @@ genrule(
"/* #undef HAVE__CPUID */",
"",
"/* Define to 1 if you have __get_cpuid. */",
"#define HAVE__GET_CPUID 1",
"#ifndef __APPLE__",
"# define HAVE__GET_CPUID 1",
"#endif",
"",
"/* Define to 1 if your compiler understands _Static_assert. */",
"#define HAVE__STATIC_ASSERT 1",
Expand Down
19 changes: 19 additions & 0 deletions ml_metadata/third_party/libmysqlclient_2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--- cmake/FindIconv.cmake 2025-02-07 16:18:14
+++ cmake/FindIconv.cmake.new 2025-02-07 16:21:47
@@ -18,14 +18,14 @@
set(ICONV_FIND_QUIETLY TRUE)
endif (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)

-find_path(ICONV_INCLUDE_DIR iconv.h)
+find_path(ICONV_INCLUDE_DIR iconv.h ${ICONV_PATH}/include)

IF(CMAKE_SYSTEM_NAME MATCHES "SunOS")
# There is some libiconv.so in /usr/local that must
# be avoided, iconv routines are in libc
ELSEIF(APPLE)
find_library(ICONV_LIBRARIES NAMES iconv libiconv PATHS
- /usr/lib/
+ ${ICONV_PATH}/lib
NO_CMAKE_SYSTEM_PATH)
SET(ICONV_EXTERNAL TRUE)
ELSE()
11 changes: 11 additions & 0 deletions ml_metadata/third_party/rules_cc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- ./cc/private/toolchain/cc_toolchain_config.bzl 2020-05-13 07:24:06
+++ ./cc/private/toolchain/cc_toolchain_config.bzl.new 2025-02-06 12:52:31
@@ -385,8 +385,6 @@
flag_group(
flags = [
"-lstdc++",
- "-undefined",
- "dynamic_lookup",
"-headerpad_max_install_names",
"-no-canonical-prefixes",
],
11 changes: 11 additions & 0 deletions ml_metadata/third_party/rules_cc_2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- cc/private/toolchain/unix_cc_configure.bzl 2025-02-06 15:38:22
+++ cc/private/toolchain/unix_cc_configure.bzl.new 2025-02-06 15:39:08
@@ -521,8 +521,6 @@
"-z",
) + (
[
- "-undefined",
- "dynamic_lookup",
"-headerpad_max_install_names",
] if darwin else bin_search_flag + [
# Gold linker only? Can we enable this by default?
11 changes: 11 additions & 0 deletions ml_metadata/third_party/upb.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- bazel/build_defs.bzl 2022-10-17 09:59:30
+++ bazel/build_defs.bzl.new 2025-02-06 11:28:56
@@ -34,7 +34,7 @@
_DEFAULT_CPPOPTS.extend([
"-Wextra",
# "-Wshorten-64-to-32", # not in GCC (and my Kokoro images doesn't have Clang)
- "-Werror",
+ # "-Werror",
"-Wno-long-long",
])
_DEFAULT_COPTS.extend([
24 changes: 24 additions & 0 deletions ml_metadata/third_party/zetasql.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
--- bazel/BUILD 2022-08-10 22:20:30
+++ bazel/BUILD.new 2025-02-07 14:49:24
@@ -40,7 +40,11 @@
configure_make(
name = "m4",
env = select({
- "@platforms//os:macos": {"AR": ""},
+ "@platforms//os:macos": {
+ "AR": "",
+ "CFLAGS": "-Wno-incompatible-function-pointer-types",
+ "CXXFLAGS": "-Wno-incompatible-function-pointer-types",
+ },
"//conditions:default": {},
}),
lib_source = "@m4//:all",
@@ -63,6 +67,8 @@
env = select({
"@platforms//os:macos": {
"AR": "",
+ "CFLAGS": "-Wno-incompatible-function-pointer-types",
+ "CXXFLAGS": "-Wno-incompatible-function-pointer-types",
"M4": "$(execpath :m4_bin)",
},
"//conditions:default": {"M4": "$(execpath :m4_bin)"},
9 changes: 9 additions & 0 deletions ml_metadata/utils.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

def github_archive(repo, commit, **kwargs):
repo_name = repo.split("/")[-1]
http_archive(
urls = [repo + "/archive/" + commit + ".zip"],
strip_prefix = repo_name + "-" + commit,
**kwargs
)
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ def finalize_options(self):
else:
self._additional_build_options = ['--macos_minimum_os=10.14']

if 'ICONV_LIBRARIES' in os.environ:
if 'ICONV_PATH' in os.environ:
self._additional_build_options.append(
'--action_env=CMAKE_ICONV_FLAG=-DICONV_LIBRARIES=' +
os.environ['ICONV_LIBRARIES'])
'--action_env=CMAKE_ICONV_FLAG=-DICONV_PATH=' +
os.environ['ICONV_PATH'])

def run(self):
subprocess.check_call(
Expand Down