allow codesigning any server backend on macos (#5085)
* allow codesigning any server backend on macos * clippy
This commit is contained in:
1 parent
887a87dcc1
commit
02b62342ef
1 file changed
+39
-30
@@ -4359,39 +4359,38 @@ __wbg_init({{module_or_path: "/{}/{wasm_path}"}}).then((wasm) => {{
|
|||||||
///
|
///
|
||||||
/// This might include codesigning, zipping, creating an appimage, etc
|
/// This might include codesigning, zipping, creating an appimage, etc
|
||||||
async fn assemble(&self, ctx: &BuildContext) -> Result<()> {
|
async fn assemble(&self, ctx: &BuildContext) -> Result<()> {
|
||||||
match self.bundle {
|
if let BundleFormat::Android = self.bundle {
|
||||||
BundleFormat::Android => {
|
ctx.status_running_gradle();
|
||||||
ctx.status_running_gradle();
|
|
||||||
|
|
||||||
// When the build mode is set to release and there is an Android signature configuration, use assembleRelease
|
// When the build mode is set to release and there is an Android signature configuration, use assembleRelease
|
||||||
let build_type = if self.release && self.config.bundle.android.is_some() {
|
let build_type = if self.release && self.config.bundle.android.is_some() {
|
||||||
"assembleRelease"
|
"assembleRelease"
|
||||||
} else {
|
} else {
|
||||||
"assembleDebug"
|
"assembleDebug"
|
||||||
};
|
};
|
||||||
|
|
||||||
let output = Command::new(self.gradle_exe()?)
|
let output = Command::new(self.gradle_exe()?)
|
||||||
.arg(build_type)
|
.arg(build_type)
|
||||||
.current_dir(self.root_dir())
|
.current_dir(self.root_dir())
|
||||||
.output()
|
.output()
|
||||||
.await
|
.await
|
||||||
.context("Failed to run gradle")?;
|
.context("Failed to run gradle")?;
|
||||||
|
|
||||||
if !output.status.success() {
|
if !output.status.success() {
|
||||||
bail!(
|
bail!(
|
||||||
"Failed to assemble apk: {}",
|
"Failed to assemble apk: {}",
|
||||||
String::from_utf8_lossy(&output.stderr)
|
String::from_utf8_lossy(&output.stderr)
|
||||||
);
|
);
|
||||||
}
|
|
||||||
}
|
|
||||||
BundleFormat::MacOS | BundleFormat::Ios => {
|
|
||||||
if self.should_codesign {
|
|
||||||
ctx.status_codesigning();
|
|
||||||
self.codesign_apple().await?;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_ => {}
|
// if the triple is a ios or macos target, we need to codesign the binary
|
||||||
|
if matches!(
|
||||||
|
self.triple.operating_system,
|
||||||
|
OperatingSystem::Darwin(_) | OperatingSystem::IOS(_)
|
||||||
|
) && self.should_codesign
|
||||||
|
{
|
||||||
|
self.codesign_apple(ctx).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -5268,7 +5267,9 @@ __wbg_init({{module_or_path: "/{}/{wasm_path}"}}).then((wasm) => {{
|
|||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn codesign_apple(&self) -> Result<()> {
|
pub async fn codesign_apple(&self, ctx: &BuildContext) -> Result<()> {
|
||||||
|
ctx.status_codesigning();
|
||||||
|
|
||||||
// We don't want to drop the entitlements file, until the end of the block, so we hoist it to this temporary.
|
// We don't want to drop the entitlements file, until the end of the block, so we hoist it to this temporary.
|
||||||
let mut _saved_entitlements = None;
|
let mut _saved_entitlements = None;
|
||||||
|
|
||||||
@@ -5303,6 +5304,14 @@ __wbg_init({{module_or_path: "/{}/{wasm_path}"}}).then((wasm) => {{
|
|||||||
app_dev_name
|
app_dev_name
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// determine the target exe - the server and macos bundles are different
|
||||||
|
let target_exe = match self.bundle {
|
||||||
|
BundleFormat::MacOS => self.root_dir(),
|
||||||
|
BundleFormat::Ios => self.root_dir(),
|
||||||
|
BundleFormat::Server => self.main_exe(),
|
||||||
|
_ => bail!("Codesigning is only supported for MacOS and iOS bundles"),
|
||||||
|
};
|
||||||
|
|
||||||
// codesign the app
|
// codesign the app
|
||||||
let output = Command::new("codesign")
|
let output = Command::new("codesign")
|
||||||
.args([
|
.args([
|
||||||
@@ -5312,7 +5321,7 @@ __wbg_init({{module_or_path: "/{}/{wasm_path}"}}).then((wasm) => {{
|
|||||||
"--sign",
|
"--sign",
|
||||||
app_dev_name,
|
app_dev_name,
|
||||||
])
|
])
|
||||||
.arg(self.root_dir())
|
.arg(target_exe)
|
||||||
.output()
|
.output()
|
||||||
.await
|
.await
|
||||||
.context("Failed to codesign the app - is `codesign` in your path?")?;
|
.context("Failed to codesign the app - is `codesign` in your path?")?;
|
||||||
|
|||||||
Reference in new issue
Block a user