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
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,16 @@ Available bazel flags are:
* `--@postgres_config//:with_gssapi`: bool (default false)
* `--@postgres_config//:with_krb_srvnam`: string (default postgres)
* `--@postgres_config//:with_libcurl`: bool (default false)
* `--@postgres_config//:with_lz4`: bool (default false)
* `--@postgres_config//:lz4_lib`: label (default `@lz4//:lz4_frame`)
* `--@postgres_config//:with_lz4`: bool (default true)
* `--@postgres_config//:with_pgport`: int (default 5432)
* `--@postgres_config//:with_readline`: bool (default false)
* `--@postgres_config//:with_segsize`: int (default 1)
* `--@postgres_config//:with_ssl`: One of `openssl` (default), `boringssl`, or `none`
* `--@postgres_config//:with_wal_blocksize`: int (default 8). One of 2^{0..6}.
* `--@postgres_config//:with_zlib`: bool (default false)
* `--@postgres_config//:with_zstd`: bool (default false)
* `--@postgres_config//:with_zlib`: bool (default true)
* `--@postgres_config//:with_zstd`: bool (default true)
* `--@postgres_config//:zlib_lib`: label (default `@zlib//:zlib`)
* `--@postgres_config//:zstd_lib`: label (default `@zstd//:zstd`)

`pg_config.h` comes from a real `rules_cc_autoconf` probe of upstream's `pg_config.h.in`, not a hand-maintained header. See the `:autoconf_probes` target in each postgres version's root.
22 changes: 19 additions & 3 deletions postgres_bazel/config/BUILD.bazel.template
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,33 @@ cc_library(

bool_flag(
name = "with_zlib",
build_setting_default = False,
build_setting_default = True,
)

label_flag(
name = "zlib_lib",
build_setting_default = "@zlib//:zlib",
)

bool_flag(
name = "with_lz4",
build_setting_default = False,
build_setting_default = True,
)

# Postgres uses the LZ4 frame API, which BCR's lz4 splits out of `:lz4`.
label_flag(
name = "lz4_lib",
build_setting_default = "@lz4//:lz4_frame",
)

bool_flag(
name = "with_zstd",
build_setting_default = False,
build_setting_default = True,
)

label_flag(
name = "zstd_lib",
build_setting_default = "@zstd//:zstd",
)

bool_flag(
Expand Down
29 changes: 22 additions & 7 deletions postgres_bazel/templates/major/16/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,21 @@ PG_VERSION_NUM = "{version_num}"
# repository's BUILD file for the full list.
# ---------------------------------------------------------------------------

_ZLIB_DEPS = select({
"@postgres_config//:zlib_on": ["@postgres_config//:zlib_lib"],
"//conditions:default": [],
})

_LZ4_DEPS = select({
"@postgres_config//:lz4_on": ["@postgres_config//:lz4_lib"],
"//conditions:default": [],
})

_ZSTD_DEPS = select({
"@postgres_config//:zstd_on": ["@postgres_config//:zstd_lib"],
"//conditions:default": [],
})

# Compiler-aware config_setting_groups so the autoconf rule below can emit
# different defines on MSVC than on GCC/Clang. MSVC doesn't grok
# `__int128`, GCC's `gnu_printf` format attribute, or x86_64 inline-asm
Expand Down Expand Up @@ -1394,7 +1409,7 @@ cc_library(
# controldata_utils.c computes the control-file CRC.
":pgport_crc32c",
":ssl_backend",
],
] + _ZLIB_DEPS + _ZSTD_DEPS,
)

cc_library(
Expand Down Expand Up @@ -1598,7 +1613,7 @@ cc_library(
":include",
":pgport_srv",
":ssl_backend",
],
] + _ZLIB_DEPS + _ZSTD_DEPS,
)

# Sources that are #included into another .c rather than compiled on their
Expand Down Expand Up @@ -1680,7 +1695,7 @@ cc_library(
] + select({
"@postgres_config//:gssapi_on": ["@postgres_config//:gssapi_lib"],
"//conditions:default": [],
}),
}) + _LZ4_DEPS + _ZLIB_DEPS + _ZSTD_DEPS,
)

# localtime.c/pgtz.c/strftime.c, linked into the backend and (localtime.c
Expand Down Expand Up @@ -1855,7 +1870,7 @@ cc_library(
],
hdrs = glob(["src/bin/pg_dump/*.h"]),
local_defines = _FRONTEND_DEFINES,
deps = _FRONTEND_DEPS,
deps = _FRONTEND_DEPS + _LZ4_DEPS + _ZLIB_DEPS + _ZSTD_DEPS,
)

cc_binary(
Expand Down Expand Up @@ -1899,7 +1914,7 @@ cc_library(
],
hdrs = glob(["src/bin/pg_basebackup/*.h"]),
local_defines = _FRONTEND_DEFINES,
deps = _FRONTEND_DEPS,
deps = _FRONTEND_DEPS + _LZ4_DEPS + _ZLIB_DEPS + _ZSTD_DEPS,
)

[
Expand Down Expand Up @@ -1932,7 +1947,7 @@ cc_binary(
] + glob(["src/bin/pg_rewind/*.h"]),
local_defines = _FRONTEND_DEFINES,
visibility = ["//visibility:public"],
deps = _FRONTEND_DEPS,
deps = _FRONTEND_DEPS + _LZ4_DEPS + _ZSTD_DEPS,
)

cc_binary(
Expand Down Expand Up @@ -1984,7 +1999,7 @@ cc_binary(
]),
local_defines = _FRONTEND_DEFINES,
visibility = ["//visibility:public"],
deps = _FRONTEND_DEPS,
deps = _FRONTEND_DEPS + _LZ4_DEPS + _ZSTD_DEPS,
)

cc_binary(
Expand Down
29 changes: 22 additions & 7 deletions postgres_bazel/templates/major/17/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,21 @@ PG_VERSION_NUM = "{version_num}"
# repository's BUILD file for the full list.
# ---------------------------------------------------------------------------

_ZLIB_DEPS = select({
"@postgres_config//:zlib_on": ["@postgres_config//:zlib_lib"],
"//conditions:default": [],
})

_LZ4_DEPS = select({
"@postgres_config//:lz4_on": ["@postgres_config//:lz4_lib"],
"//conditions:default": [],
})

_ZSTD_DEPS = select({
"@postgres_config//:zstd_on": ["@postgres_config//:zstd_lib"],
"//conditions:default": [],
})

# Compiler-aware config_setting_groups so the autoconf rule below can emit
# different defines on MSVC than on GCC/Clang. MSVC doesn't grok
# `__int128`, GCC's `gnu_printf` format attribute, or x86_64 inline-asm
Expand Down Expand Up @@ -1402,7 +1417,7 @@ cc_library(
# controldata_utils.c computes the control-file CRC.
":pgport_crc32c",
":ssl_backend",
],
] + _ZLIB_DEPS + _ZSTD_DEPS,
)

cc_library(
Expand Down Expand Up @@ -1606,7 +1621,7 @@ cc_library(
":include",
":pgport_srv",
":ssl_backend",
],
] + _ZLIB_DEPS + _ZSTD_DEPS,
)

# Sources that are #included into another .c rather than compiled on their
Expand Down Expand Up @@ -1692,7 +1707,7 @@ cc_library(
] + select({
"@postgres_config//:gssapi_on": ["@postgres_config//:gssapi_lib"],
"//conditions:default": [],
}),
}) + _LZ4_DEPS + _ZLIB_DEPS + _ZSTD_DEPS,
)

# localtime.c/pgtz.c/strftime.c, linked into the backend and (localtime.c
Expand Down Expand Up @@ -1892,7 +1907,7 @@ cc_library(
],
hdrs = glob(["src/bin/pg_dump/*.h"]),
local_defines = _FRONTEND_DEFINES,
deps = _FRONTEND_DEPS,
deps = _FRONTEND_DEPS + _LZ4_DEPS + _ZLIB_DEPS + _ZSTD_DEPS,
)

cc_binary(
Expand Down Expand Up @@ -1936,7 +1951,7 @@ cc_library(
],
hdrs = glob(["src/bin/pg_basebackup/*.h"]),
local_defines = _FRONTEND_DEFINES,
deps = _FRONTEND_DEPS,
deps = _FRONTEND_DEPS + _LZ4_DEPS + _ZLIB_DEPS + _ZSTD_DEPS,
)

[
Expand Down Expand Up @@ -1969,7 +1984,7 @@ cc_binary(
] + glob(["src/bin/pg_rewind/*.h"]),
local_defines = _FRONTEND_DEFINES,
visibility = ["//visibility:public"],
deps = _FRONTEND_DEPS,
deps = _FRONTEND_DEPS + _LZ4_DEPS + _ZSTD_DEPS,
)

cc_binary(
Expand Down Expand Up @@ -2018,7 +2033,7 @@ cc_binary(
]),
local_defines = _FRONTEND_DEFINES,
visibility = ["//visibility:public"],
deps = _FRONTEND_DEPS,
deps = _FRONTEND_DEPS + _LZ4_DEPS + _ZSTD_DEPS,
)

cc_binary(
Expand Down
31 changes: 23 additions & 8 deletions postgres_bazel/templates/major/18/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,21 @@ PG_VERSION_NUM = "{version_num}"
# repository's BUILD file for the full list.
# ---------------------------------------------------------------------------

_ZLIB_DEPS = select({
"@postgres_config//:zlib_on": ["@postgres_config//:zlib_lib"],
"//conditions:default": [],
})

_LZ4_DEPS = select({
"@postgres_config//:lz4_on": ["@postgres_config//:lz4_lib"],
"//conditions:default": [],
})

_ZSTD_DEPS = select({
"@postgres_config//:zstd_on": ["@postgres_config//:zstd_lib"],
"//conditions:default": [],
})

# Compiler-aware config_setting_groups so the autoconf rule below can emit
# different defines on MSVC than on GCC/Clang. MSVC doesn't grok
# `__int128`, GCC's `gnu_printf` format attribute, or x86_64 inline-asm
Expand Down Expand Up @@ -1375,7 +1390,7 @@ cc_library(
# controldata_utils.c computes the control-file CRC.
":pgport_crc32c",
":ssl_backend",
],
] + _ZLIB_DEPS + _ZSTD_DEPS,
)

cc_library(
Expand Down Expand Up @@ -1409,7 +1424,7 @@ cc_library(
":pgcommon_tools",
":pgport",
":pq",
],
] + _LZ4_DEPS + _ZLIB_DEPS + _ZSTD_DEPS,
)

cc_binary(
Expand Down Expand Up @@ -1568,7 +1583,7 @@ cc_library(
":include",
":pgport_srv",
":ssl_backend",
],
] + _ZLIB_DEPS + _ZSTD_DEPS,
)

# Sources that are #included into another .c rather than compiled on their
Expand Down Expand Up @@ -1649,7 +1664,7 @@ cc_library(
] + select({
"@postgres_config//:gssapi_on": ["@postgres_config//:gssapi_lib"],
"//conditions:default": [],
}),
}) + _LZ4_DEPS + _ZLIB_DEPS + _ZSTD_DEPS,
)

# localtime.c/pgtz.c/strftime.c, linked into the backend and (localtime.c
Expand Down Expand Up @@ -1850,7 +1865,7 @@ cc_library(
],
hdrs = glob(["src/bin/pg_dump/*.h"]),
local_defines = _FRONTEND_DEFINES,
deps = _FRONTEND_DEPS,
deps = _FRONTEND_DEPS + _LZ4_DEPS + _ZLIB_DEPS + _ZSTD_DEPS,
)

cc_binary(
Expand Down Expand Up @@ -1889,7 +1904,7 @@ cc_library(
],
hdrs = glob(["src/bin/pg_basebackup/*.h"]),
local_defines = _FRONTEND_DEFINES,
deps = _FRONTEND_DEPS,
deps = _FRONTEND_DEPS + _LZ4_DEPS + _ZLIB_DEPS + _ZSTD_DEPS,
)

[
Expand Down Expand Up @@ -1922,7 +1937,7 @@ cc_binary(
] + glob(["src/bin/pg_rewind/*.h"]),
local_defines = _FRONTEND_DEFINES,
visibility = ["//visibility:public"],
deps = _FRONTEND_DEPS,
deps = _FRONTEND_DEPS + _LZ4_DEPS + _ZSTD_DEPS,
)

cc_binary(
Expand Down Expand Up @@ -1975,7 +1990,7 @@ cc_binary(
]),
local_defines = _FRONTEND_DEFINES,
visibility = ["//visibility:public"],
deps = _FRONTEND_DEPS,
deps = _FRONTEND_DEPS + _LZ4_DEPS + _ZSTD_DEPS,
)

cc_binary(
Expand Down
Loading