Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Account for optimization levels other than numbers #417

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions configure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::path::PathBuf;
pub struct Config {
pub manifest_dir: PathBuf,
pub out_dir: PathBuf,
pub opt_level: u8,
pub opt_level: String,
pub cargo_features: Vec<String>,
pub target_arch: String,
pub target_env: String,
Expand All @@ -31,7 +31,7 @@ impl Config {
Self {
manifest_dir: PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()),
out_dir: PathBuf::from(env::var("OUT_DIR").unwrap()),
opt_level: env::var("OPT_LEVEL").unwrap().parse().unwrap(),
opt_level: env::var("OPT_LEVEL").unwrap(),
cargo_features,
target_arch: env::var("CARGO_CFG_TARGET_ARCH").unwrap(),
target_env: env::var("CARGO_CFG_TARGET_ENV").unwrap(),
Expand Down Expand Up @@ -91,7 +91,7 @@ fn emit_arch_cfg() {
fn emit_optimization_cfg(cfg: &Config) {
println!("cargo:rustc-check-cfg=cfg(optimizations_enabled)");

if cfg.opt_level >= 2 {
if !matches!(cfg.opt_level.as_str(), "0" | "1") {
println!("cargo:rustc-cfg=optimizations_enabled");
}
}
Expand Down