The extension version. The control file's default_version, the generated install script's name and the crate's CARGO_PKG_VERSION must agree; this is the one place it is written.
4VERSION = "0.0.1"
The PostgreSQL majors the extension supports, oldest first. The
generated Cargo manifests declare one pgNN feature per entry and make
the last the default (tools/cargo-gen). third-party/Cargo.toml selects
the one buck builds.
10PG_MAJORS = ["17", "18"]
The major a target builds for is a configuration, not a buckconfig
value: //platforms:pgNN sets the pg_major constraint, and every
major-dependent attribute branches on it through pg_major_select, so
one graph builds (and tests) every major. Anything configured without
the constraint (the default target platform, the execution platform)
gets the newest. Code that differs between majors branches on the
feature = "pgNN" cfg, which every pgrx-reaching crate gets, as under
cargo's generated pgNN features.
The Rust edition of every first-party crate, for buck (toolchains/BUCK) and the generated Cargo manifests alike.
31RUST_EDITION = "2024"
First-party Rust targets. Each one also gets a <name>-lint test that
fails when clippy (which includes every rustc warning) reports
anything: buck prints no compiler output for actions that succeed, so
without this a warning is invisible. Third-party crates are built with
--cap-lints=allow by reindeer's rules and are not linted.
Every first-party target also records what tools/cargo-gen needs to
write its Cargo manifest: a <name>-cargo JSON file of its kind, crate
root and deps, and a <name>-manifest filegroup of the manifest
committed beside it, which the drift test compares.
52def _cargo_meta(name, kind, crate_root, deps, pgrx_extension = False): 53 meta = { 54 "package": native.package_name(), 55 "name": name, 56 "kind": kind, 57 "crate_root": crate_root, 58 "deps": deps, 59 "pgrx_extension": pgrx_extension, 60 } 61 native.genrule( 62 name = name + "-cargo", 63 out = name + ".json", 64 cmd = "cat > $OUT <<'CARGO_META_EOF'\n" + json.encode(meta) + "\nCARGO_META_EOF", 65 visibility = ["PUBLIC"], 66 ) 67 native.filegroup( 68 name = name + "-manifest", 69 srcs = native.glob(["Cargo.toml", "src/bin/pgrx_embed.rs"]), 70 visibility = ["PUBLIC"], 71 )
73def first_party_library(name, pgrx_extension = False, pg_major = False, **kwargs): 74 if pg_major: 75 kwargs["features"] = kwargs.get("features", []) + _pg_major_features() 76 native.rust_library(name = name, **kwargs) 77 _cargo_meta(name, "library", kwargs["crate_root"], kwargs.get("deps", []), pgrx_extension) 78 _lint_test(name) 79 80def first_party_binary(name, **kwargs): 81 native.rust_binary(name = name, **kwargs) 82 _cargo_meta(name, "binary", kwargs["crate_root"], kwargs.get("deps", [])) 83 _lint_test(name) 84 85def first_party_test(name, **kwargs): 86 native.rust_test(name = name, **kwargs)
The same test on every older major: <name>-pgNN is configured for
//platforms:pgNN, so its whole graph (pgrx's features, bindgen's
pg_config, the server it starts) is that major's.