|
|
|
@@ -310,17 +310,6 @@ pub fn rustfs_binary_path() -> PathBuf {
|
|
|
|
|
rustfs_binary_path_with_features(requested_rustfs_build_features().as_deref())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn resolve_rustfs_binary_path(workspace: &Path, configured_target_dir: Option<&Path>) -> PathBuf {
|
|
|
|
|
let mut path = match configured_target_dir {
|
|
|
|
|
Some(path) if path.is_absolute() => path.to_path_buf(),
|
|
|
|
|
Some(path) => workspace.join(path),
|
|
|
|
|
None => workspace.join("target"),
|
|
|
|
|
};
|
|
|
|
|
path.push(if cfg!(debug_assertions) { "debug" } else { "release" });
|
|
|
|
|
path.push(format!("rustfs{}", std::env::consts::EXE_SUFFIX));
|
|
|
|
|
path
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Resolve the RustFS binary relative to the workspace, optionally requesting build features.
|
|
|
|
|
pub fn rustfs_binary_path_with_features(requested_features: Option<&str>) -> PathBuf {
|
|
|
|
|
if let Some(path) = std::env::var_os("CARGO_BIN_EXE_rustfs") {
|
|
|
|
@@ -328,9 +317,11 @@ pub fn rustfs_binary_path_with_features(requested_features: Option<&str>) -> Pat
|
|
|
|
|
}
|
|
|
|
|
let requested_features = requested_features.and_then(normalize_rustfs_build_features);
|
|
|
|
|
|
|
|
|
|
let workspace = workspace_root();
|
|
|
|
|
let configured_target_dir = std::env::var_os("CARGO_TARGET_DIR").map(PathBuf::from);
|
|
|
|
|
let binary_path = resolve_rustfs_binary_path(&workspace, configured_target_dir.as_deref());
|
|
|
|
|
let mut binary_path = workspace_root();
|
|
|
|
|
binary_path.push("target");
|
|
|
|
|
let profile_dir = if cfg!(debug_assertions) { "debug" } else { "release" };
|
|
|
|
|
binary_path.push(profile_dir);
|
|
|
|
|
binary_path.push(format!("rustfs{}", std::env::consts::EXE_SUFFIX));
|
|
|
|
|
|
|
|
|
|
let features_match = binary_features_match(&binary_path, requested_features.as_deref());
|
|
|
|
|
let source_is_newer = workspace_sources_newer_than_binary(&binary_path);
|
|
|
|
@@ -347,7 +338,7 @@ pub fn rustfs_binary_path_with_features(requested_features: Option<&str>) -> Pat
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
info!("Building RustFS binary to ensure it's up to date...");
|
|
|
|
|
build_rustfs_binary(requested_features.as_deref(), &binary_path);
|
|
|
|
|
build_rustfs_binary(requested_features.as_deref());
|
|
|
|
|
|
|
|
|
|
info!("Using RustFS binary at {:?}", binary_path);
|
|
|
|
|
binary_path
|
|
|
|
@@ -449,7 +440,7 @@ fn path_is_newer_than(binary_modified: std::time::SystemTime, path: &Path) -> bo
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Build the RustFS binary using cargo
|
|
|
|
|
fn build_rustfs_binary(requested_features: Option<&str>, binary_path: &Path) {
|
|
|
|
|
fn build_rustfs_binary(requested_features: Option<&str>) {
|
|
|
|
|
let workspace = workspace_root();
|
|
|
|
|
info!("Building RustFS binary from workspace: {:?}", workspace);
|
|
|
|
|
|
|
|
|
@@ -485,7 +476,11 @@ fn build_rustfs_binary(requested_features: Option<&str>, binary_path: &Path) {
|
|
|
|
|
panic!("Failed to build RustFS binary. Error: {stderr}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let stamp_path = rustfs_binary_features_stamp_path(binary_path);
|
|
|
|
|
let mut binary_path = workspace;
|
|
|
|
|
binary_path.push("target");
|
|
|
|
|
binary_path.push(if cfg!(debug_assertions) { "debug" } else { "release" });
|
|
|
|
|
binary_path.push(format!("rustfs{}", std::env::consts::EXE_SUFFIX));
|
|
|
|
|
let stamp_path = rustfs_binary_features_stamp_path(&binary_path);
|
|
|
|
|
if let Err(err) = stdfs::write(&stamp_path, requested_features.unwrap_or_default()) {
|
|
|
|
|
warn!("Failed to write RustFS feature stamp {:?}: {}", stamp_path, err);
|
|
|
|
|
}
|
|
|
|
@@ -1760,27 +1755,6 @@ mod tests {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn resolves_rustfs_binary_in_configured_cargo_target_directory() {
|
|
|
|
|
let workspace = Path::new("workspace");
|
|
|
|
|
let profile = if cfg!(debug_assertions) { "debug" } else { "release" };
|
|
|
|
|
let binary = format!("rustfs{}", std::env::consts::EXE_SUFFIX);
|
|
|
|
|
assert_eq!(
|
|
|
|
|
resolve_rustfs_binary_path(workspace, None),
|
|
|
|
|
workspace.join("target").join(profile).join(&binary)
|
|
|
|
|
);
|
|
|
|
|
assert_eq!(
|
|
|
|
|
resolve_rustfs_binary_path(workspace, Some(Path::new("custom-target"))),
|
|
|
|
|
workspace.join("custom-target").join(profile).join(&binary)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
let absolute = std::env::temp_dir().join("rustfs-e2e-custom-target");
|
|
|
|
|
assert_eq!(
|
|
|
|
|
resolve_rustfs_binary_path(workspace, Some(&absolute)),
|
|
|
|
|
absolute.join(profile).join(binary)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn full_feature_enables_any_required_feature() {
|
|
|
|
|
assert!(rustfs_build_feature_enabled(Some("full"), "sftp"));
|
|
|
|
|