Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trim source paths for release binaries #478

Merged
merged 1 commit into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
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
8 changes: 7 additions & 1 deletion aws-lc-fips-sys/builder/cmake_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use crate::OutputLib::{Crypto, RustWrapper, Ssl};
use crate::{
cargo_env, emit_warning, execute_command, is_no_asm, option_env, target, target_arch,
target_env, target_os, target_underscored, target_vendor, OutputLibType,
target_env, target_family, target_os, target_underscored, target_vendor, OutputLibType,
};
use std::collections::HashMap;
use std::env;
Expand Down Expand Up @@ -102,6 +102,12 @@ impl CmakeBuilder {
cmake_cfg.define("CMAKE_BUILD_TYPE", "relwithdebinfo");
} else {
cmake_cfg.define("CMAKE_BUILD_TYPE", "release");
if target_family() == "unix" || target_env() == "gnu" {
cmake_cfg.cflag(format!(
"-ffile-prefix-map={}=",
self.manifest_dir.display()
));
}
}
} else if target_os() == "windows" {
// The Windows/FIPS build rejects "debug" profile
Expand Down
4 changes: 4 additions & 0 deletions aws-lc-fips-sys/builder/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ fn emit_warning(message: &str) {
println!("cargo:warning={message}");
}

fn target_family() -> String {
cargo_env("CARGO_CFG_TARGET_FAMILY")
}

fn target_os() -> String {
cargo_env("CARGO_CFG_TARGET_OS")
}
Expand Down
12 changes: 12 additions & 0 deletions aws-lc-sys/builder/cc_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,18 @@ impl CcBuilder {
.define("BORINGSSL_IMPLEMENTATION", "1")
.define("BORINGSSL_PREFIX", prefix.as_str());
}

let opt_level = cargo_env("OPT_LEVEL");
match opt_level.as_str() {
"0" | "1" | "2" => {}
_ => {
cc_build.flag(format!(
"-ffile-prefix-map={}=",
self.manifest_dir.display()
));
}
}

self.add_includes(&mut cc_build);
cc_build
}
Expand Down
11 changes: 9 additions & 2 deletions aws-lc-sys/builder/cmake_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
use crate::OutputLib::{Crypto, RustWrapper, Ssl};
use crate::{
cargo_env, emit_warning, execute_command, is_crt_static, is_no_asm, option_env, target,
target_arch, target_env, target_os, target_underscored, target_vendor, OutputLibType,
target_arch, target_env, target_family, target_os, target_underscored, target_vendor,
OutputLibType,
};
use std::env;
use std::ffi::OsString;
Expand Down Expand Up @@ -85,12 +86,18 @@ impl CmakeBuilder {
cmake_cfg.define("BUILD_SHARED_LIBS", "0");
}

let opt_level = env::var("OPT_LEVEL").unwrap_or_else(|_| "0".to_string());
let opt_level = cargo_env("OPT_LEVEL");
if opt_level.ne("0") {
if opt_level.eq("1") || opt_level.eq("2") {
cmake_cfg.define("CMAKE_BUILD_TYPE", "relwithdebinfo");
} else {
cmake_cfg.define("CMAKE_BUILD_TYPE", "release");
if target_family() == "unix" || target_env() == "gnu" {
cmake_cfg.cflag(format!(
"-ffile-prefix-map={}=",
self.manifest_dir.display()
));
}
}
} else {
cmake_cfg.define("CMAKE_BUILD_TYPE", "debug");
Expand Down
4 changes: 4 additions & 0 deletions aws-lc-sys/builder/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@ fn emit_warning(message: &str) {
println!("cargo:warning={message}");
}

fn target_family() -> String {
cargo_env("CARGO_CFG_TARGET_FAMILY")
}

fn target_os() -> String {
cargo_env("CARGO_CFG_TARGET_OS")
}
Expand Down
Loading