Skip to content

Commit

Permalink
always compile pgrx_embed_* without opts (#1838)
Browse files Browse the repository at this point in the history
This addresses issue #1835 by always compiling the `pgrx_embed_xxx`
binary in debug mode.

Essentially, `cargo pgrx` now ignores the `--release` or `--profile XXX`
arguments when compiling the `pgrx_embed_xxx` binary.
  • Loading branch information
eeeebbbbrrrr authored Sep 3, 2024
1 parent f62ee03 commit 7755cc7
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions cargo-pgrx/src/command/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ pub(crate) fn generate_schema(
let lib_filename = manifest.lib_filename()?;

if !skip_build {
// NB: The only path where this happens is via the command line using `cargo pgrx schema`
first_build(
user_manifest_path.as_ref(),
profile,
Expand Down Expand Up @@ -202,7 +203,6 @@ pub(crate) fn generate_schema(

second_build(
user_manifest_path.as_ref(),
profile,
features,
log_level.clone(),
&features_arg,
Expand All @@ -211,7 +211,7 @@ pub(crate) fn generate_schema(
&package_name,
)?;

compute_sql(profile, &package_name, &manifest)?;
compute_sql(&package_name, &manifest)?;

Ok(())
}
Expand Down Expand Up @@ -469,7 +469,6 @@ fn compute_codegen(

fn second_build(
user_manifest_path: Option<&impl AsRef<Path>>,
profile: &CargoProfile,
features: &clap_cargo::Features,
log_level: Option<String>,
features_arg: &str,
Expand All @@ -496,8 +495,6 @@ fn second_build(
command.arg(user_manifest_path.as_ref());
}

command.args(profile.cargo_args());

if let Some(log_level) = &log_level {
command.env("RUST_LOG", log_level);
}
Expand Down Expand Up @@ -527,9 +524,10 @@ fn second_build(

let command_str = format!("{:?}", command);
eprintln!(
"{} for SQL generation with features `{}`",
"{} {}, in debug mode, for SQL generation with features {}",
" Rebuilding".bold().green(),
features_arg,
"pgrx_embed".cyan(),
features_arg.cyan(),
);

tracing::debug!(command = %command_str, "Running");
Expand All @@ -545,13 +543,9 @@ fn second_build(
Ok(())
}

fn compute_sql(
profile: &CargoProfile,
package_name: &str,
manifest: &Manifest,
) -> eyre::Result<()> {
fn compute_sql(package_name: &str, manifest: &Manifest) -> eyre::Result<()> {
let mut bin = get_target_dir()?;
bin.push(profile.target_subdir());
bin.push("debug"); // pgrx_embed_ is always compiled in debug mode
bin.push(format!("pgrx_embed_{package_name}"));

let mut command = std::process::Command::new(bin);
Expand Down

0 comments on commit 7755cc7

Please sign in to comment.