mostly cosmetic cleanups to build.rs before I do some overhauls so we don't need to download all the Postgres versions
@@ -77,13 +77,11 @@ fn main() -> Result<(), std::io::Error> {
let shim_mutex = Mutex::new(());
let need_common_rs = AtomicBool::new(false);
- vec![("10.13", "8810"), ("11.8", "8811"), ("12.3", "8812")]
- .par_iter()
- .for_each(|v| {
+ let pg_versions = vec![("10.13", 8810), ("11.8", 8811), ("12.3", 8812)];
+ pg_versions.par_iter().for_each(|v| {
let version: &str = v.0;
- let major_version =
- u16::from_str(version.split_terminator('.').next().unwrap()).unwrap();
- let port_no = u16::from_str(v.1).unwrap();
+ let major_version = u16::from_str(version.split_terminator('.').next().unwrap()).unwrap();
+ let port_no = v.1;
let include_path = PathBuf::from(format!(
"{}/postgresql-{}/pgx-install/include/server",
target_dir.display(),
@@ -110,7 +108,13 @@ fn main() -> Result<(), std::io::Error> {
eprintln!("include_h={}", include_h.display());
download_postgres(&manifest_dir, version, &target_dir)
.unwrap_or_else(|_| panic!("failed to download Postgres v{}", version));
- let did_compile = compile_postgres(&manifest_dir, version, &target_dir, port_no)
+ let did_compile = compile_postgres(
+ &manifest_dir,
+ version,
+ &target_dir,
+ port_no,
+ pg_versions.len(),
+ )
.unwrap_or_else(|_| panic!("failed to compile Postgres v{}", version));
build_shim(&shim_dir, &shim_mutex, &target_dir, major_version, version);
@@ -144,9 +148,7 @@ fn main() -> Result<(), std::io::Error> {
.derive_partialord(false)
.layout_tests(false)
.generate()
- .unwrap_or_else(|e| {
- panic!("Unable to generate bindings for {}: {:?}", version, e)
- });
+ .unwrap_or_else(|e| panic!("Unable to generate bindings for {}: {:?}", version, e));
let bindings = apply_pg_guard(bindings.to_string()).unwrap();
std::fs::write(bindings_rs.clone(), bindings).unwrap_or_else(|e| {
@@ -269,8 +271,9 @@ fn compile_postgres(
version_number: &str,
target_dir: &PathBuf,
port_number: u16,
+ num_versions: usize,
) -> Result<bool, std::io::Error> {
- let num_cpus = 1.max(num_cpus::get() / 3);
+ let num_cpus = 1.max(num_cpus::get() / num_versions);
let rc = run_command(
Command::new("./compile-postgres.sh")
.arg(version_number)
