support a new environment variable (PGX_PG_CONFIG_PATH) to tell build.rs where to find a single pg_config
@@ -320,11 +320,17 @@ impl Pgx {
}
pub fn from_config() -> Result<Self, std::io::Error> {
+ match std::env::var("PGX_PG_CONFIG_PATH") {
+ Ok(pg_config) => {
+ // we have an environment variable that tells us the pg_config to use
+ let mut pgx = Pgx::new();
+ pgx.push(PgConfig::new(pg_config.into()));
+ Ok(pgx)
+ }
+ Err(_) => {
+ // we'll get what we need from cargo-pgx' config.toml file
let path = Pgx::config_toml()?;
-
if !path.exists() {
- // TODO: do this automatically if an environment variable is set?
- // I think we want/need that ability
return Err(std::io::Error::new(
ErrorKind::NotFound,
format!(
@@ -347,6 +353,8 @@ impl Pgx {
Err(e) => Err(std::io::Error::new(ErrorKind::InvalidInput, e)),
}
}
+ }
+ }
pub fn push(&mut self, pg_config: PgConfig) {
self.pg_configs.push(pg_config);
