bundle.rs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. mod appimage_bundle;
  2. mod category;
  3. mod common;
  4. mod deb_bundle;
  5. mod dmg_bundle;
  6. mod ios_bundle;
  7. #[cfg(target_os = "windows")]
  8. mod msi_bundle;
  9. mod osx_bundle;
  10. mod path_utils;
  11. mod platform;
  12. mod rpm_bundle;
  13. mod settings;
  14. mod tauri_config;
  15. #[cfg(target_os = "windows")]
  16. mod wix;
  17. pub use self::common::{print_error, print_finished, print_info};
  18. pub use self::settings::{BuildArtifact, PackageType, Settings};
  19. use std::path::PathBuf;
  20. /// Bundles the project.
  21. /// Returns the list of paths where the bundles can be found.
  22. pub fn bundle_project(settings: Settings) -> crate::Result<Vec<PathBuf>> {
  23. let mut paths = Vec::new();
  24. let package_types = settings.package_types()?;
  25. for package_type in &package_types {
  26. let mut bundle_paths = match package_type {
  27. PackageType::OsxBundle => {
  28. if package_types.clone().iter().any(|&t| t == PackageType::Dmg) {
  29. vec![]
  30. } else {
  31. osx_bundle::bundle_project(&settings)?
  32. }
  33. }
  34. PackageType::IosBundle => ios_bundle::bundle_project(&settings)?,
  35. #[cfg(target_os = "windows")]
  36. PackageType::WindowsMsi => msi_bundle::bundle_project(&settings)?,
  37. PackageType::Deb => deb_bundle::bundle_project(&settings)?,
  38. PackageType::Rpm => rpm_bundle::bundle_project(&settings)?,
  39. PackageType::AppImage => appimage_bundle::bundle_project(&settings)?,
  40. PackageType::Dmg => dmg_bundle::bundle_project(&settings)?,
  41. };
  42. paths.append(&mut bundle_paths);
  43. }
  44. settings.copy_resources(settings.project_out_directory())?;
  45. settings.copy_binaries(settings.project_out_directory())?;
  46. Ok(paths)
  47. }
  48. /// Check to see if there are icons in the settings struct
  49. pub fn check_icons(settings: &Settings) -> crate::Result<bool> {
  50. // make a peekable iterator of the icon_files
  51. let mut iter = settings.icon_files().peekable();
  52. // if iter's first value is a None then there are no Icon files in the settings struct
  53. if iter.peek().is_none() {
  54. Ok(false)
  55. } else {
  56. Ok(true)
  57. }
  58. }