(args: &[String], cwd: &Path)
| 436 | #[cfg(target_os = "linux")] |
| 437 | fn scripts_dylib_name() -> &'static str { |
| 438 | "libscripts.so" |
| 439 | } |
| 440 | |
| 441 | #[cfg(target_os = "macos")] |
| 442 | fn scripts_dylib_name() -> &'static str { |
| 443 | "libscripts.dylib" |
| 444 | } |
| 445 | |
| 446 | pub(crate) fn copy_steam_runtime_library( |
| 447 | target_dir: &Path, |
| 448 | profile_dir: &str, |
| 449 | output_dir: &Path, |
| 450 | ) -> Result<(), String> { |
| 451 | let Some(library_name) = steam_runtime_library_name() else { |
| 452 | return Ok(()); |
| 453 | }; |
| 454 | let build_dir = target_dir.join(profile_dir).join("build"); |
| 455 | let source = find_steam_runtime_library(&build_dir, library_name).ok_or_else(|| { |
| 456 | format!( |
| 457 | "Steam enabled but {library_name} was not found under {}", |
| 458 | build_dir.display() |
| 459 | ) |
| 460 | })?; |
| 461 | fs::create_dir_all(output_dir) |
| 462 | .map_err(|err| format!("failed to create {}: {err}", output_dir.display()))?; |
| 463 | let target = output_dir.join(library_name); |
| 464 | fs::copy(&source, &target).map_err(|err| { |
| 465 | format!( |
| 466 | "failed to copy Steam runtime library from {} to {}: {err}", |
| 467 | source.display(), |
| 468 | target.display() |
| 469 | ) |
| 470 | })?; |
| 471 | Ok(()) |
| 472 | } |
| 473 | |
| 474 | fn steam_runtime_library_name() -> Option<&'static str> { |
| 475 | if cfg!(target_os = "windows") { |
| 476 | Some("steam_api64.dll") |
| 477 | } else if cfg!(target_os = "linux") { |
| 478 | Some("libsteam_api.so") |
| 479 | } else if cfg!(target_os = "macos") { |
| 480 | Some("libsteam_api.dylib") |
| 481 | } else { |
| 482 | None |
| 483 | } |
| 484 | } |
| 485 | |
| 486 | fn find_steam_runtime_library(build_dir: &Path, library_name: &str) -> Option<PathBuf> { |
no test coverage detected