Skip to content

Commit 5ac8824

Browse files
committed
wip build for macos
1 parent 2a34c90 commit 5ac8824

File tree

5 files changed

+59
-1
lines changed

5 files changed

+59
-1
lines changed

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build-scripts/qchatbuild.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,19 @@ def build_chat_bin(
8282
return out_path
8383

8484

85-
def build_macos(chat_path: pathlib.Path):
85+
def sign_and_notarize(chat_path: pathlib.Path):
86+
# First, sign the application
87+
88+
# Next, notarize the application
89+
90+
# Last, staple the notarization to the application
8691
pass
8792

8893

94+
def build_macos(chat_path: pathlib.Path):
95+
sign_and_notarize(chat_path)
96+
97+
8998
def build_linux(chat_path: pathlib.Path):
9099
"""
91100
Creates tar.gz, tar.xz, tar.zst, and zip archives under `BUILD_DIR`.

crates/chat-cli/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ nix = { version = "0.29.0", features = [
170170
skim = { version = "0.16.2" }
171171

172172
[target.'cfg(target_os = "macos")'.dependencies]
173+
embed_plist = "1.2"
173174
objc2 = "0.5.2"
174175
objc2-app-kit = { version = "0.2.2", features = ["NSWorkspace"] }
175176
objc2-foundation = { version = "0.2.2", features = ["NSString", "NSURL"] }

crates/chat-cli/build.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,47 @@ struct Def {
3939
metrics: Vec<MetricDef>,
4040
}
4141

42+
/// Writes a generated Info.plist for the qchat executable under src/.
43+
///
44+
/// This is required for signing the executable since we must embed the Info.plist directly within
45+
/// the binary.
46+
#[cfg(target_os = "macos")]
47+
fn write_plist() {
48+
let plist = format!(
49+
r#"
50+
<?xml version="1.0" encoding="UTF-8"?>
51+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
52+
<plist version="1.0">
53+
<dict>
54+
<key>CFBundlePackageType</key>
55+
<string>APPL</string>
56+
<key>CFBundleIdentifier</key>
57+
<string>com.amazon.codewhisperer</string>
58+
<key>CFBundleName</key>
59+
<string>{}</string>
60+
<key>CFBundleVersion</key>
61+
<string>{}</string>
62+
<key>CFBundleShortVersionString</key>
63+
<string>{}/string>
64+
<key>CFBundleInfoDictionaryVersion</key>
65+
<string>6.0</string>
66+
<key>NSHumanReadableCopyright</key>
67+
<string>Copyright © 2022 Amazon Q CLI Team ([email protected]):Chay Nabors ([email protected]):Brandon Kiser ([email protected]) All rights reserved.</string>
68+
</dict>
69+
"#,
70+
option_env!("AMAZON_Q_BUILD_HASH").unwrap_or("unknown"),
71+
option_env!("AMAZON_Q_BUILD_DATETIME").unwrap_or("unknown"),
72+
env!("CARGO_PKG_VERSION")
73+
);
74+
75+
std::fs::write("src/Info.plist", plist).expect("writing the Info.plist should not fail");
76+
}
77+
4278
fn main() {
4379
println!("cargo:rerun-if-changed=def.json");
4480

81+
write_plist();
82+
4583
let outdir = std::env::var("OUT_DIR").unwrap();
4684

4785
let data = serde_json::from_str::<Def>(DEF).unwrap();

crates/chat-cli/src/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ use tracing::metadata::LevelFilter;
2323
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
2424

2525
fn main() -> Result<ExitCode> {
26+
#[cfg(target_os = "macos")]
27+
embed_plist::embed_info_plist!("Info.plist");
28+
2629
color_eyre::install()?;
2730

2831
let parsed = match cli::Cli::try_parse() {

0 commit comments

Comments
 (0)