@@ -6,7 +6,7 @@ exports_files(["COPYRIGHT"])
66
77# This is OSS version of PostgreSQL bazel build target.
88# The build target is consistent with Tensorflow's dependency on PostgreSQL.
9- # Reference: https://github.com/tensorflow/io/commit/6a2b9b3e94fd80f9a7f0b982089e8a69751bd059
9+ # Reference: https://github.com/tensorflow/io/commit/a1171cdd20e658ef3f1a8b3bf66dd4e228ceae30
1010cc_library(
1111 name = "postgresql",
1212 srcs = glob([
@@ -43,8 +43,8 @@ cc_library(
4343 "src/common/unicode_norm.c",
4444 "src/common/username.c",
4545 "src/common/wait_error.c",
46- "src/interfaces/libpq/fe-auth.c",
4746 "src/interfaces/libpq/fe-auth-scram.c",
47+ "src/interfaces/libpq/fe-auth.c",
4848 "src/interfaces/libpq/fe-connect.c",
4949 "src/interfaces/libpq/fe-exec.c",
5050 "src/interfaces/libpq/fe-lobj.c",
@@ -62,8 +62,6 @@ cc_library(
6262 "src/port/path.c",
6363 "src/port/pg_bitutils.c",
6464 "src/port/pg_crc32c_sb8.c",
65- # Comment this line out to force usage of sb8 algorithm of crc32c
66- # "src/port/pg_crc32c_sse42_choose.c",
6765 "src/port/pg_strong_random.c",
6866 "src/port/pgcheckdir.c",
6967 "src/port/pgmkdirp.c",
@@ -80,12 +78,28 @@ cc_library(
8078 "src/port/tar.c",
8179 "src/port/thread.c",
8280 ] + select({
83- "@//ml_metadata:macos": [],
81+ "@bazel_tools//src/conditions:darwin": [],
82+ "@bazel_tools//src/conditions:windows": [
83+ "src/interfaces/libpq/pthread-win32.c",
84+ "src/interfaces/libpq/win32.c",
85+ "src/port/dirmod.c",
86+ "src/port/getaddrinfo.c",
87+ "src/port/inet_aton.c",
88+ "src/port/open.c",
89+ "src/port/strlcpy.c",
90+ "src/port/win32error.c",
91+ "src/port/win32setlocale.c",
92+ "src/port/pthread-win32.h",
93+ ],
8494 "//conditions:default": [
8595 "src/port/getpeereid.c",
86- "src/port/strlcat.c",
8796 "src/port/strlcpy.c",
8897 ],
98+ }) + select({
99+ "@platforms//cpu:x86_64": [
100+ "src/port/pg_crc32c_sse42_choose.c",
101+ ],
102+ "//conditions:default": [],
89103 }),
90104 hdrs = [
91105 "config/pg_config.h",
@@ -98,7 +112,14 @@ cc_library(
98112 defines = [
99113 "FRONTEND",
100114 ] + select({
101- "@//ml_metadata:macos": [
115+ "@bazel_tools//src/conditions:windows": [
116+ "BLCKSZ=8192",
117+ "XLOG_BLCKSZ=8192",
118+ 'PG_MAJORVERSION=\\"12\\"',
119+ "HAVE_LIBZ=1",
120+ "WIN32",
121+ ],
122+ "@bazel_tools//src/conditions:darwin": [
102123 "HAVE_DECL_STRLCPY=1",
103124 "HAVE_STRLCPY=1",
104125 "HAVE_STRUCT_SOCKADDR_STORAGE_SS_LEN=1",
@@ -114,9 +135,18 @@ cc_library(
114135 "src/include",
115136 "src/interfaces/libpq",
116137 ] + select({
138+ "@bazel_tools//src/conditions:windows": [
139+ "src/include/port/win32",
140+ "src/include/port/win32_msvc",
141+ "src/port",
142+ ],
117143 "//conditions:default": [],
118144 }),
119145 linkopts = select({
146+ "@bazel_tools//src/conditions:windows": [
147+ "-DEFAULTLIB:ws2_32.lib",
148+ "-DEFAULTLIB:shell32.lib",
149+ ],
120150 "//conditions:default": [],
121151 }),
122152 deps = [],
@@ -125,7 +155,10 @@ cc_library(
125155genrule(
126156 name = "pg_config_os_h",
127157 srcs = select({
128- "@//ml_metadata:macos": [
158+ "@bazel_tools//src/conditions:windows": [
159+ "src/include/port/win32.h",
160+ ],
161+ "@bazel_tools//src/conditions:darwin": [
129162 "src/include/port/darwin.h",
130163 ],
131164 "//conditions:default": [
@@ -135,18 +168,22 @@ genrule(
135168 outs = [
136169 "config/pg_config_os.h",
137170 ],
138- cmd = "cp $< $@",
171+ cmd = ( "cp $< $@") ,
139172)
140173
141174genrule(
142175 name = "pg_config_ext_h",
143176 srcs = select({
177+ "@bazel_tools//src/conditions:windows": [
178+ "src/include/pg_config_ext.h.win32",
179+ ],
144180 "//conditions:default": [
145181 "src/include/pg_config_ext.h.in",
146182 ],
147183 }),
148184 outs = ["config/pg_config_ext.h"],
149185 cmd = select({
186+ "@bazel_tools//src/conditions:windows": ("cp $< $@"),
150187 "//conditions:default": (
151188 "sed " +
152189 "-e 's/undef PG_INT64_TYPE/define PG_INT64_TYPE long int/g' " +
@@ -357,6 +394,9 @@ genrule(
357394genrule(
358395 name = "pg_config_h",
359396 srcs = select({
397+ "@bazel_tools//src/conditions:windows": [
398+ "src/include/pg_config.h.win32",
399+ ],
360400 "//conditions:default": [
361401 "src/include/pg_config.h.in",
362402 ],
@@ -365,7 +405,8 @@ genrule(
365405 "config/pg_config.h",
366406 ],
367407 cmd = select({
368- "//conditions:default": "\n".join([
408+ "@bazel_tools//src/conditions:windows": ("cp $< $@"),
409+ "//conditions:default": ("\n".join([
369410 "cat <<'EOF' >$@",
370411 "/* src/include/pg_config.h. Generated from pg_config.h.in by configure. */",
371412 "/* src/include/pg_config.h.in. Generated from configure.in by autoheader. */",
@@ -1145,9 +1186,11 @@ genrule(
11451186 "/* Define to 1 if you have __cpuid. */",
11461187 "/* #undef HAVE__CPUID */",
11471188 "",
1189+ "#if defined __x86_64__",
11481190 "/* Define to 1 if you have __get_cpuid. */",
11491191 "#define HAVE__GET_CPUID 1",
11501192 "",
1193+ "#endif",
11511194 "/* Define to 1 if your compiler understands _Static_assert. */",
11521195 "#define HAVE__STATIC_ASSERT 1",
11531196 "",
@@ -1312,15 +1355,13 @@ genrule(
13121355 "/* #undef USE_PAM */",
13131356 "",
13141357 "/* Define to 1 to use software CRC-32C implementation (slicing-by-8). */",
1315- # Force usage of sb8 algorithm of crc32c
1316- "#define USE_SLICING_BY_8_CRC32C 1",
1358+ "/* #undef USE_SLICING_BY_8_CRC32C */",
13171359 "",
13181360 "/* Define to 1 use Intel SSE 4.2 CRC instructions. */",
13191361 "/* #undef USE_SSE42_CRC32C */",
13201362 "",
13211363 "/* Define to 1 to use Intel SSE 4.2 CRC instructions with a runtime check. */",
1322- # Do not check at runtime but force usage of sb8 algorithm of crc32c
1323- "/* #undef USE_SSE42_CRC32C_WITH_RUNTIME_CHECK */",
1364+ "#define USE_SSE42_CRC32C_WITH_RUNTIME_CHECK 1",
13241365 "",
13251366 "/* Define to build with systemd support. (--with-systemd) */",
13261367 "/* #undef USE_SYSTEMD */",
@@ -1334,6 +1375,15 @@ genrule(
13341375 "/* Define to select unnamed POSIX semaphores. */",
13351376 "/* #undef USE_UNNAMED_POSIX_SEMAPHORES */",
13361377 "",
1378+ "/* Define to use native Windows API for random number generation */",
1379+ "/* #undef USE_WIN32_RANDOM */",
1380+ "",
1381+ "/* Define to select Win32-style semaphores. */",
1382+ "/* #undef USE_WIN32_SEMAPHORES */",
1383+ "",
1384+ "/* Define to select Win32-style shared memory. */",
1385+ "/* #undef USE_WIN32_SHARED_MEMORY */",
1386+ "",
13371387 "/* Define to 1 if `wcstombs_l' requires <xlocale.h>. */",
13381388 "#define WCSTOMBS_L_IN_XLOCALE 1",
13391389 "",
@@ -1405,6 +1455,6 @@ genrule(
14051455 " pointer, if such a type exists, and if the system does not define it. */",
14061456 "/* #undef uintptr_t */",
14071457 "EOF",
1408- ]),
1458+ ])) ,
14091459 }),
1410- )
1460+ )
0 commit comments