@@ -6,7 +6,7 @@ exports_files(["COPYRIGHT"])
6
6
7
7
# This is OSS version of PostgreSQL bazel build target.
8
8
# 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
10
10
cc_library(
11
11
name = "postgresql",
12
12
srcs = glob([
@@ -43,8 +43,8 @@ cc_library(
43
43
"src/common/unicode_norm.c",
44
44
"src/common/username.c",
45
45
"src/common/wait_error.c",
46
- "src/interfaces/libpq/fe-auth.c",
47
46
"src/interfaces/libpq/fe-auth-scram.c",
47
+ "src/interfaces/libpq/fe-auth.c",
48
48
"src/interfaces/libpq/fe-connect.c",
49
49
"src/interfaces/libpq/fe-exec.c",
50
50
"src/interfaces/libpq/fe-lobj.c",
@@ -62,8 +62,6 @@ cc_library(
62
62
"src/port/path.c",
63
63
"src/port/pg_bitutils.c",
64
64
"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",
67
65
"src/port/pg_strong_random.c",
68
66
"src/port/pgcheckdir.c",
69
67
"src/port/pgmkdirp.c",
@@ -80,12 +78,28 @@ cc_library(
80
78
"src/port/tar.c",
81
79
"src/port/thread.c",
82
80
] + 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
+ ],
84
94
"//conditions:default": [
85
95
"src/port/getpeereid.c",
86
- "src/port/strlcat.c",
87
96
"src/port/strlcpy.c",
88
97
],
98
+ }) + select({
99
+ "@platforms//cpu:x86_64": [
100
+ "src/port/pg_crc32c_sse42_choose.c",
101
+ ],
102
+ "//conditions:default": [],
89
103
}),
90
104
hdrs = [
91
105
"config/pg_config.h",
@@ -98,7 +112,14 @@ cc_library(
98
112
defines = [
99
113
"FRONTEND",
100
114
] + 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": [
102
123
"HAVE_DECL_STRLCPY=1",
103
124
"HAVE_STRLCPY=1",
104
125
"HAVE_STRUCT_SOCKADDR_STORAGE_SS_LEN=1",
@@ -114,9 +135,18 @@ cc_library(
114
135
"src/include",
115
136
"src/interfaces/libpq",
116
137
] + select({
138
+ "@bazel_tools//src/conditions:windows": [
139
+ "src/include/port/win32",
140
+ "src/include/port/win32_msvc",
141
+ "src/port",
142
+ ],
117
143
"//conditions:default": [],
118
144
}),
119
145
linkopts = select({
146
+ "@bazel_tools//src/conditions:windows": [
147
+ "-DEFAULTLIB:ws2_32.lib",
148
+ "-DEFAULTLIB:shell32.lib",
149
+ ],
120
150
"//conditions:default": [],
121
151
}),
122
152
deps = [],
@@ -125,7 +155,10 @@ cc_library(
125
155
genrule(
126
156
name = "pg_config_os_h",
127
157
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": [
129
162
"src/include/port/darwin.h",
130
163
],
131
164
"//conditions:default": [
@@ -135,18 +168,22 @@ genrule(
135
168
outs = [
136
169
"config/pg_config_os.h",
137
170
],
138
- cmd = "cp $< $@",
171
+ cmd = ( "cp $< $@") ,
139
172
)
140
173
141
174
genrule(
142
175
name = "pg_config_ext_h",
143
176
srcs = select({
177
+ "@bazel_tools//src/conditions:windows": [
178
+ "src/include/pg_config_ext.h.win32",
179
+ ],
144
180
"//conditions:default": [
145
181
"src/include/pg_config_ext.h.in",
146
182
],
147
183
}),
148
184
outs = ["config/pg_config_ext.h"],
149
185
cmd = select({
186
+ "@bazel_tools//src/conditions:windows": ("cp $< $@"),
150
187
"//conditions:default": (
151
188
"sed " +
152
189
"-e 's/undef PG_INT64_TYPE/define PG_INT64_TYPE long int/g' " +
@@ -357,6 +394,9 @@ genrule(
357
394
genrule(
358
395
name = "pg_config_h",
359
396
srcs = select({
397
+ "@bazel_tools//src/conditions:windows": [
398
+ "src/include/pg_config.h.win32",
399
+ ],
360
400
"//conditions:default": [
361
401
"src/include/pg_config.h.in",
362
402
],
@@ -365,7 +405,8 @@ genrule(
365
405
"config/pg_config.h",
366
406
],
367
407
cmd = select({
368
- "//conditions:default": "\n".join([
408
+ "@bazel_tools//src/conditions:windows": ("cp $< $@"),
409
+ "//conditions:default": ("\n".join([
369
410
"cat <<'EOF' >$@",
370
411
"/* src/include/pg_config.h. Generated from pg_config.h.in by configure. */",
371
412
"/* src/include/pg_config.h.in. Generated from configure.in by autoheader. */",
@@ -1145,9 +1186,11 @@ genrule(
1145
1186
"/* Define to 1 if you have __cpuid. */",
1146
1187
"/* #undef HAVE__CPUID */",
1147
1188
"",
1189
+ "#if defined __x86_64__",
1148
1190
"/* Define to 1 if you have __get_cpuid. */",
1149
1191
"#define HAVE__GET_CPUID 1",
1150
1192
"",
1193
+ "#endif",
1151
1194
"/* Define to 1 if your compiler understands _Static_assert. */",
1152
1195
"#define HAVE__STATIC_ASSERT 1",
1153
1196
"",
@@ -1312,15 +1355,13 @@ genrule(
1312
1355
"/* #undef USE_PAM */",
1313
1356
"",
1314
1357
"/* 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 */",
1317
1359
"",
1318
1360
"/* Define to 1 use Intel SSE 4.2 CRC instructions. */",
1319
1361
"/* #undef USE_SSE42_CRC32C */",
1320
1362
"",
1321
1363
"/* 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",
1324
1365
"",
1325
1366
"/* Define to build with systemd support. (--with-systemd) */",
1326
1367
"/* #undef USE_SYSTEMD */",
@@ -1334,6 +1375,15 @@ genrule(
1334
1375
"/* Define to select unnamed POSIX semaphores. */",
1335
1376
"/* #undef USE_UNNAMED_POSIX_SEMAPHORES */",
1336
1377
"",
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
+ "",
1337
1387
"/* Define to 1 if `wcstombs_l' requires <xlocale.h>. */",
1338
1388
"#define WCSTOMBS_L_IN_XLOCALE 1",
1339
1389
"",
@@ -1405,6 +1455,6 @@ genrule(
1405
1455
" pointer, if such a type exists, and if the system does not define it. */",
1406
1456
"/* #undef uintptr_t */",
1407
1457
"EOF",
1408
- ]),
1458
+ ])) ,
1409
1459
}),
1410
- )
1460
+ )
0 commit comments