-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
58 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,71 @@ | ||
use std::env; | ||
use std::path::PathBuf; | ||
use std::process::Command; | ||
|
||
use anyhow::Result; | ||
use log::info; | ||
|
||
use crate::utils; | ||
use compositor_chromium::cef::bundle_app; | ||
use compositor_chromium::cef; | ||
|
||
// const ARM_MAC_TARGET: &str = "aarch64-apple-darwin"; | ||
const ARM_MAC_TARGET: &str = "aarch64-apple-darwin"; | ||
const ARM_OUTPUT_FILE: &str = "video_compositor_darwin_aarch64.app.tar.gz"; | ||
const INTEL_MAC_TARGET: &str = "x86_64-apple-darwin"; | ||
const INTEL_OUTPUT_FILE: &str = "video_compositor_darwin_x86_64.app.tar.gz"; | ||
|
||
pub fn bundle_macos_app() -> Result<()> { | ||
if cfg!(target_arch = "x86_64") { | ||
bundle_app(INTEL_MAC_TARGET, INTEL_OUTPUT_FILE)?; | ||
} else if cfg!(target_arch = "aarch64") { | ||
bundle_app(ARM_MAC_TARGET, ARM_OUTPUT_FILE)?; | ||
// We do not have CI with M1 yet, so this will be built locally for now. | ||
let release_tag = env::var("RELEASE_TAG")?; | ||
let root_dir_str = env!("CARGO_MANIFEST_DIR"); | ||
let root_dir: PathBuf = root_dir_str.into(); | ||
let upload_path = root_dir.join(ARM_OUTPUT_FILE); | ||
Command::new("gh") | ||
.args([ | ||
"release", | ||
"upload", | ||
&release_tag, | ||
&upload_path.display().to_string(), | ||
]) | ||
.spawn()? | ||
.wait()?; | ||
} else { | ||
panic!("Unknown architecture") | ||
} | ||
Ok(()) | ||
} | ||
|
||
fn bundle_app(target: &'static str, output_name: &'static str) -> Result<()> { | ||
env_logger::init_from_env( | ||
env_logger::Env::default().filter_or(env_logger::DEFAULT_FILTER_ENV, "info"), | ||
); | ||
let root_dir_str = env!("CARGO_MANIFEST_DIR"); | ||
let root_dir: PathBuf = root_dir_str.into(); | ||
let build_dir = root_dir.join(format!("target/{INTEL_MAC_TARGET}/release")); | ||
let build_dir = root_dir.join(format!("target/{target}/release")); | ||
let tmp_dir = root_dir.join("video_compositor.app"); | ||
|
||
info!("Build main_process binary."); | ||
utils::cargo_build("main_process", INTEL_MAC_TARGET)?; | ||
utils::cargo_build("main_process", target)?; | ||
info!("Build process_helper binary."); | ||
utils::cargo_build("process_helper", INTEL_MAC_TARGET)?; | ||
utils::cargo_build("process_helper", target)?; | ||
|
||
info!("Create macOS bundle."); | ||
bundle_app(&build_dir, &tmp_dir)?; | ||
cef::bundle_app(&build_dir, &tmp_dir)?; | ||
|
||
info!("Create tar.gz archive."); | ||
Command::new("tar") | ||
.args([ | ||
"-C", | ||
root_dir_str, | ||
"-czvf", | ||
output_name, | ||
"video_compositor.app", | ||
]) | ||
.spawn()? | ||
.wait()?; | ||
|
||
Ok(()) | ||
} |