forked from tensorchord/VectorChord
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.rs
More file actions
44 lines (42 loc) · 1.7 KB
/
build.rs
File metadata and controls
44 lines (42 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// This software is licensed under a dual license model:
//
// GNU Affero General Public License v3 (AGPLv3): You may use, modify, and
// distribute this software under the terms of the AGPLv3.
//
// Elastic License v2 (ELv2): You may also use, modify, and distribute this
// software under the Elastic License v2, which has specific restrictions.
//
// We welcome any commercial collaboration or support. For inquiries
// regarding the licenses, please contact us at:
//
// Copyright (c) 2025 TensorChord Inc.
use std::collections::HashMap;
use std::env::{var, var_os};
use std::error::Error;
use std::process::{Command, Stdio};
fn main() -> Result<(), Box<dyn Error>> {
if var("CARGO_CFG_TARGET_OS")? == "macos" {
if let Some(path) = var_os("PGRX_PG_CONFIG_PATH") {
let map = {
let mut command = Command::new(&path);
command.stderr(Stdio::inherit());
let command_output = command.output()?;
let command_stdout = String::from_utf8(command_output.stdout)?;
let mut map = HashMap::new();
for line in command_stdout.lines() {
if let Some((key, value)) = line.split_once(" = ") {
map.insert(key.to_string(), value.to_string());
eprintln!("Config `{key}`: {value}");
}
}
map
};
let bindir = &map["BINDIR"];
println!("cargo::rustc-link-arg-cdylib=-Wl,-bundle,-bundle_loader,{bindir}/postgres",);
} else {
println!("cargo::rustc-link-arg-cdylib=-Wl,-undefined,dynamic_lookup");
}
}
Ok(())
}