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
32 changes: 31 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,40 @@ Libraries:

Binaries:

* `psql`
* `clusterdb`
* `createdb`
* `createuser`
* `dropdb`
* `dropuser`
* `initdb`
* `pg_amcheck`
* `pg_archivecleanup`
* `pg_basebackup`
* `pg_checksums`
* `pg_combinebackup` (17+)
* `pg_config`
* `pg_controldata`
* `pg_createsubscriber` (17+)
* `pg_ctl`
* `pg_dump`
* `pg_dumpall`
* `pg_isready`
* `pg_receivewal`
* `pg_recvlogical`
* `pg_resetwal`
* `pg_restore`
* `pg_rewind`
* `pg_test_fsync`
* `pg_test_timing`
* `pg_upgrade`
* `pg_verifybackup`
* `pg_waldump`
* `pg_walsummary` (17+)
* `pgbench`
* `postgres`
* `psql`
* `reindexdb`
* `vacuumdb`

For using each of these binaries as tools or via `bazel run`, use the `_bin` suffixed version of each of those targets. They pull all dependent files in as runfiles, ensure that postgres has its expected path layout, and executes the binary in the right bazel configuration.

Expand Down
9 changes: 8 additions & 1 deletion postgres_bazel/default_repo.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@

def _postgres_default_repo_impl(repository_ctx):
template = repository_ctx.read(repository_ctx.attr._build_file)
repository_ctx.file("BUILD.bazel", template.replace("{repo}", repository_ctx.attr.target_repo))
repository_ctx.file("BUILD.bazel", template.replace(
"{repo}",
repository_ctx.attr.target_repo,
).replace(
"{major}",
repository_ctx.attr.major,
))

postgres_default_repo = repository_rule(
implementation = _postgres_default_repo_impl,
doc = "Aliases every public target of a versioned postgres repository.",
attrs = {
"major": attr.string(mandatory = True, doc = "Major version of the versioned repository's template."),
"target_repo": attr.string(mandatory = True, doc = "Apparent name of the versioned repository."),
"_build_file": attr.label(default = "//templates:default/BUILD.bazel.template"),
},
Expand Down
6 changes: 4 additions & 2 deletions postgres_bazel/extension.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def _postgres_impl(module_ctx):
version = tag.version,
)
created.append(name)
repo_for_version.setdefault(tag.version, name)
repo_for_version.setdefault(tag.version, (name, major))

for module in module_ctx.modules:
for tag in module.tags.default_version:
Expand All @@ -85,9 +85,11 @@ def _postgres_impl(module_ctx):
tag.version,
", ".join(sorted(repo_for_version)),
))
target_repo, major = repo_for_version[tag.version]
postgres_default_repo(
name = tag.repo_name,
target_repo = repo_for_version[tag.version],
major = major,
target_repo = target_repo,
)
created.append(tag.repo_name)

Expand Down
3 changes: 3 additions & 0 deletions postgres_bazel/templates/17.0/files.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ src/backend/utils/fmgroids.h
src/backend/utils/fmgrprotos.h
src/backend/utils/fmgrtab.c
src/backend/utils/misc/guc-file.c
src/bin/pgbench/exprparse.c
src/bin/pgbench/exprparse.h
src/bin/pgbench/exprscan.c
src/bin/psql/psqlscanslash.c
src/bin/psql/sql_help.c
src/bin/psql/sql_help.h
Expand Down
Loading
Loading