1
0
Fork 0

Use the correct MacOS bundle type for binaries

This commit is contained in:
Robbert van der Helm 2022-04-22 17:57:09 +02:00
parent 6a6e7e0992
commit aa7666dfc5

View file

@ -49,6 +49,13 @@ pub enum Architecture {
AArch64, AArch64,
} }
/// The type of a MacOS bundle.
#[derive(Debug, Clone, Copy)]
pub enum BundleType {
Plugin,
Binary,
}
/// The main xtask entry point function. See the readme for instructions on how to use this. /// The main xtask entry point function. See the readme for instructions on how to use this.
pub fn main() -> Result<()> { pub fn main() -> Result<()> {
let args = std::env::args().skip(1); let args = std::env::args().skip(1);
@ -231,6 +238,7 @@ fn bundle_binary(
&bundle_name, &bundle_name,
&standalone_bundle_home, &standalone_bundle_home,
compilation_target, compilation_target,
BundleType::Binary,
)?; )?;
eprintln!( eprintln!(
@ -286,6 +294,7 @@ fn bundle_plugin(
&bundle_name, &bundle_name,
&clap_bundle_home, &clap_bundle_home,
compilation_target, compilation_target,
BundleType::Plugin,
)?; )?;
eprintln!("Created a CLAP bundle at '{}'", clap_bundle_home.display()); eprintln!("Created a CLAP bundle at '{}'", clap_bundle_home.display());
@ -312,6 +321,7 @@ fn bundle_plugin(
&bundle_name, &bundle_name,
&vst2_bundle_home, &vst2_bundle_home,
compilation_target, compilation_target,
BundleType::Plugin,
)?; )?;
eprintln!("Created a VST2 bundle at '{}'", vst2_bundle_home.display()); eprintln!("Created a VST2 bundle at '{}'", vst2_bundle_home.display());
@ -337,6 +347,7 @@ fn bundle_plugin(
&bundle_name, &bundle_name,
vst3_bundle_home, vst3_bundle_home,
compilation_target, compilation_target,
BundleType::Plugin,
)?; )?;
eprintln!("Created a VST3 bundle at '{}'", vst3_bundle_home.display()); eprintln!("Created a VST3 bundle at '{}'", vst3_bundle_home.display());
@ -514,15 +525,24 @@ pub fn maybe_create_macos_bundle_metadata(
display_name: &str, display_name: &str,
bundle_home: &Path, bundle_home: &Path,
target: CompilationTarget, target: CompilationTarget,
bundle_type: BundleType,
) -> Result<()> { ) -> Result<()> {
if !matches!(target, CompilationTarget::MacOS(_)) { if !matches!(target, CompilationTarget::MacOS(_)) {
return Ok(()); return Ok(());
} }
let package_type = match bundle_type {
BundleType::Plugin => "BNDL",
BundleType::Binary => "APPL",
};
// TODO: May want to add bundler.toml fields for the identifier, version and signature at some // TODO: May want to add bundler.toml fields for the identifier, version and signature at some
// point. // point.
fs::write(bundle_home.join("Contents").join("PkgInfo"), "BNDL????") fs::write(
.context("Could not create PkgInfo file")?; bundle_home.join("Contents").join("PkgInfo"),
format!("{package_type}????"),
)
.context("Could not create PkgInfo file")?;
fs::write( fs::write(
bundle_home.join("Contents").join("Info.plist"), bundle_home.join("Contents").join("Info.plist"),
format!(r#"<?xml version="1.0" encoding="UTF-8"?> format!(r#"<?xml version="1.0" encoding="UTF-8"?>
@ -541,7 +561,7 @@ pub fn maybe_create_macos_bundle_metadata(
<key>CFBundleDisplayName</key> <key>CFBundleDisplayName</key>
<string>{display_name}</string> <string>{display_name}</string>
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>BNDL</string> <string>{package_type}</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>