Skip to content

Commit

Permalink
add ".exe" suffix to all binary paths
Browse files Browse the repository at this point in the history
  • Loading branch information
usamoi committed Nov 1, 2024
1 parent c6b6866 commit b681551
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 7 deletions.
5 changes: 4 additions & 1 deletion cargo-pgrx/src/command/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ fn make_install_postgres(
) -> eyre::Result<PgConfig> {
let mut pg_config = get_pg_installdir(pgdir);
pg_config.push("bin");
pg_config.push("pg_config");
pg_config.push("pg_config.exe");
Ok(PgConfig::new_with_defaults(pg_config))
}

Expand Down Expand Up @@ -644,7 +644,10 @@ fn is_root_user() -> bool {

pub(crate) fn initdb(bindir: &Path, datadir: &Path) -> eyre::Result<()> {
println!(" {} data directory at {}", "Initializing".bold().green(), datadir.display());
#[cfg(not(target_os = "windows"))]
let initdb = bindir.join("initdb");
#[cfg(target_os = "windows")]
let initdb = bindir.join("initdb.exe");
let mut command = std::process::Command::new(initdb);
command
.stdout(Stdio::piped())
Expand Down
2 changes: 1 addition & 1 deletion cargo-pgrx/src/command/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pub(crate) fn start_postgres(pg_config: &PgConfig) -> eyre::Result<()> {
pg_config.major_version()?,
port.to_string().bold().cyan()
);
let pg_ctl = pg_config.bin_dir()?.join("pg_ctl");
let pg_ctl = pg_config.pg_ctl_path()?;
let mut command = std::process::Command::new(pg_ctl);
command
.stdout(Stdio::piped())
Expand Down
2 changes: 1 addition & 1 deletion cargo-pgrx/src/command/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub(crate) fn status_postgres(pg_config: &PgConfig) -> eyre::Result<bool> {
return Ok(false);
} // if Err, let the filesystem and OS handle our impending failure

let pg_ctl = pg_config.bin_dir()?.join("pg_ctl");
let pg_ctl = pg_config.pg_ctl_path()?;
let mut command = process::Command::new(pg_ctl);
command.stdout(Stdio::piped()).stderr(Stdio::piped()).arg("status").arg("-D").arg(&datadir);
let command_str = format!("{command:?}");
Expand Down
2 changes: 1 addition & 1 deletion cargo-pgrx/src/command/stop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pub(crate) fn stop_postgres(pg_config: &PgConfig) -> eyre::Result<()> {

println!("{} Postgres v{}", " Stopping".bold().green(), pg_config.major_version()?);

let pg_ctl = pg_config.bin_dir()?.join("pg_ctl");
let pg_ctl = pg_config.pg_ctl_path()?;
let mut command = std::process::Command::new(pg_ctl);
command
.stdout(Stdio::piped())
Expand Down
25 changes: 24 additions & 1 deletion pgrx-pg-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,32 +333,55 @@ impl PgConfig {

pub fn postmaster_path(&self) -> eyre::Result<PathBuf> {
let mut path = self.bin_dir()?;
#[cfg(not(target_os = "windows"))]
path.push("postgres");

#[cfg(target_os = "windows")]
path.push("postgres.exe");
Ok(path)
}

pub fn initdb_path(&self) -> eyre::Result<PathBuf> {
let mut path = self.bin_dir()?;
#[cfg(not(target_os = "windows"))]
path.push("initdb");
#[cfg(target_os = "windows")]
path.push("initdb.exe");
Ok(path)
}

pub fn createdb_path(&self) -> eyre::Result<PathBuf> {
let mut path = self.bin_dir()?;
#[cfg(not(target_os = "windows"))]
path.push("createdb");
#[cfg(target_os = "windows")]
path.push("createdb.exe");
Ok(path)
}

pub fn dropdb_path(&self) -> eyre::Result<PathBuf> {
let mut path = self.bin_dir()?;
#[cfg(not(target_os = "windows"))]
path.push("dropdb");
#[cfg(target_os = "windows")]
path.push("dropdb.exe");
Ok(path)
}

pub fn pg_ctl_path(&self) -> eyre::Result<PathBuf> {
let mut path = self.bin_dir()?;
#[cfg(not(target_os = "windows"))]
path.push("pg_ctl");
#[cfg(target_os = "windows")]
path.push("pg_ctl.exe");
Ok(path)
}

pub fn psql_path(&self) -> eyre::Result<PathBuf> {
let mut path = self.bin_dir()?;
#[cfg(not(target_os = "windows"))]
path.push("psql");
#[cfg(target_os = "windows")]
path.push("psql.exe");
Ok(path)
}

Expand Down
4 changes: 2 additions & 2 deletions pgrx-tests/src/framework.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ fn start_pg(loglines: LogLines) -> eyre::Result<String> {
let mut pipe = pipe::WindowsNamedPipe::create()?;

let pg_config = get_pg_config()?;
let pg_ctl = pg_config.bin_dir()?.join("pg_ctl");
let pg_ctl = pg_config.pg_ctl_path()?;

let postmaster_path = if use_valgrind() {
#[allow(unused_mut)]
Expand Down Expand Up @@ -644,7 +644,7 @@ fn start_pg(loglines: LogLines) -> eyre::Result<String> {

add_shutdown_hook(|| {
let pg_config = get_pg_config().unwrap();
let pg_ctl = pg_config.bin_dir().unwrap().join("pg_ctl");
let pg_ctl = pg_config.pg_ctl_path().unwrap();

let mut command = if let Some(runas) = get_runas() {
let mut cmd = sudo_command(runas);
Expand Down

0 comments on commit b681551

Please sign in to comment.