mirror of
https://github.com/ankitects/anki.git
synced 2025-09-23 00:12:25 -04:00

* Prepare to switch Rust import style * Run nightly format Closes #2320 * Clean up a few imports * Enable comment wrapping * Wrap comments
43 lines
1.3 KiB
Rust
43 lines
1.3 KiB
Rust
// Copyright: Ankitects Pty Ltd and contributors
|
|
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
use std::env;
|
|
use std::process::Command;
|
|
|
|
use anyhow::bail;
|
|
use anyhow::Result;
|
|
use camino::Utf8Path;
|
|
use camino::Utf8PathBuf;
|
|
|
|
const CODESIGN_ARGS: &[&str] = &["-vvvv", "-o", "runtime", "-s", "Developer ID Application:"];
|
|
|
|
pub fn codesign_python_libs(bundle_dir: &Utf8PathBuf) -> Result<()> {
|
|
for entry in glob::glob(bundle_dir.join("Contents/MacOS/lib/**/*.so").as_str())? {
|
|
let entry = entry?;
|
|
let entry = Utf8PathBuf::from_path_buf(entry).unwrap();
|
|
codesign_file(&entry, &[])?;
|
|
}
|
|
codesign_file(&bundle_dir.join("Contents/MacOS/libankihelper.dylib"), &[])
|
|
}
|
|
|
|
pub fn codesign_app(bundle_dir: &Utf8PathBuf) -> Result<()> {
|
|
codesign_file(
|
|
bundle_dir,
|
|
&["--entitlements", "qt/bundle/mac/entitlements.python.xml"],
|
|
)
|
|
}
|
|
|
|
fn codesign_file(path: &Utf8Path, extra_args: &[&str]) -> Result<()> {
|
|
if env::var("ANKI_CODESIGN").is_ok() {
|
|
let status = Command::new("codesign")
|
|
.args(CODESIGN_ARGS)
|
|
.args(extra_args)
|
|
.arg(path.as_str())
|
|
.status()?;
|
|
if !status.success() {
|
|
bail!("codesign failed");
|
|
}
|
|
}
|
|
|
|
Ok(())
|
|
}
|