Skip to content

Commit e9f4d99

Browse files
committed
feat(build): Parameterize binary names in build scripts
- Add CHAT_BINARY_BRANCH and CLI_BINARY_NAME_MINIMAL to const.py - Import CHAT_BINARY_BRANCH and TAURI_PRODUCT_NAME in build.py - Replace hardcoded 'qchat' with CHAT_BINARY_NAME constant - Replace hardcoded 'q_desktop' with TAURI_PRODUCT_NAME constant - Replace hardcoded 'q_cli' with CLI_PACKAGE_NAME constant - Replace hardcoded 'prod' with CHAT_BINARY_BRANCH constant - Update comments to use generic binary name placeholders 🤖 Assisted by Amazon Q Developer
1 parent 8cd1cc5 commit e9f4d99

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

build-scripts/build.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
from importlib import import_module
3737
from const import (
3838
APP_NAME,
39+
CHAT_BINARY_BRANCH,
3940
CHAT_BINARY_NAME,
4041
CHAT_PACKAGE_NAME,
4142
CLI_BINARY_NAME,
@@ -51,6 +52,7 @@
5152
MACOS_BUNDLE_ID,
5253
PTY_BINARY_NAME,
5354
PTY_PACKAGE_NAME,
55+
TAURI_PRODUCT_NAME,
5456
URL_SCHEMA,
5557
)
5658

@@ -179,7 +181,7 @@ def fetch_chat_bin(chat_build_bucket_name: str | None, chat_download_role_arn: s
179181
warn("missing required chat arguments, creating dummy binary")
180182
dummy_dir = BUILD_DIR / "dummy_chat"
181183
dummy_dir.mkdir(exist_ok=True)
182-
dummy_path = dummy_dir / f"qchat-{get_target_triple()}"
184+
dummy_path = dummy_dir / f"{CHAT_BINARY_NAME}-{get_target_triple()}"
183185
dummy_path.write_text("#!/usr/bin/env sh\n\necho dummy chat binary\n")
184186
set_executable(dummy_path)
185187
return dummy_path
@@ -205,21 +207,21 @@ def fetch_chat_bin(chat_build_bucket_name: str | None, chat_download_role_arn: s
205207
)
206208

207209
# The path to the download should be:
208-
# BUILD_BUCKET/prod/latest/{target}/qchat.zip
210+
# BUILD_BUCKET/{CHAT_BINARY_BRANCH}/latest/{target}/{CHAT_BINARY_NAME}.zip
209211
target = get_target_triple()
210-
chat_bucket_path = f"prod/latest/{target}/qchat.zip"
212+
chat_bucket_path = f"{CHAT_BINARY_BRANCH}/latest/{target}/{CHAT_BINARY_NAME}.zip"
211213
chat_dl_dir = BUILD_DIR / "chat_download"
212214
chat_dl_dir.mkdir(exist_ok=True)
213-
chat_dl_path = chat_dl_dir / "qchat.zip"
214-
info(f"Downloading qchat zip from bucket: {chat_bucket_path} and path: {chat_bucket_path}")
215+
chat_dl_path = chat_dl_dir / f"{CHAT_BINARY_NAME}.zip"
216+
info(f"Downloading {CHAT_BINARY_NAME} zip from bucket: {chat_bucket_path} and path: {chat_bucket_path}")
215217
s3.download_file(chat_build_bucket_name, chat_bucket_path, chat_dl_path)
216218

217219
# unzip and return the path to the contained binary
218220
run_cmd(["unzip", "-o", chat_dl_path, "-d", chat_dl_dir])
219221

220222
# Append target triple, as expected by tauri cli.
221-
chat_path = chat_dl_dir / f"qchat-{target}"
222-
(chat_dl_dir / "qchat").rename(chat_path)
223+
chat_path = chat_dl_dir / f"{CHAT_BINARY_NAME}-{target}"
224+
(chat_dl_dir / CHAT_BINARY_NAME).rename(chat_path)
223225
return chat_path
224226

225227

@@ -341,7 +343,7 @@ def build_macos_desktop_app(
341343
manifest_path.unlink(missing_ok=True)
342344
tauri_config_path.unlink(missing_ok=True)
343345

344-
target_bundle = pathlib.Path(f"target/{target}/release/bundle/macos/q_desktop.app")
346+
target_bundle = pathlib.Path(f"target/{target}/release/bundle/macos/{TAURI_PRODUCT_NAME}.app")
345347
app_path = BUILD_DIR / f"{APP_NAME}.app"
346348
shutil.rmtree(app_path, ignore_errors=True)
347349
shutil.copytree(target_bundle, app_path)
@@ -466,9 +468,9 @@ def build_linux_minimal(cli_path: pathlib.Path, pty_path: pathlib.Path, chat_pat
466468
Creates tar.gz, tar.xz, tar.zst, and zip archives under `BUILD_DIR`.
467469
468470
Each archive has the following structure:
469-
- archive/bin/q
470-
- archive/bin/qterm
471-
- archive/bin/qchat
471+
- archive/bin/{cli_binary}
472+
- archive/bin/{pty_binary}
473+
- archive/bin/{chat_binary}
472474
- archive/install.sh
473475
- archive/README
474476
- archive/BUILD-INFO
@@ -879,7 +881,7 @@ def build(
879881
else:
880882
signing_data = None
881883

882-
cargo_features: Mapping[str, Sequence[str]] = {"q_cli": ["wayland"]}
884+
cargo_features: Mapping[str, Sequence[str]] = {CLI_PACKAGE_NAME: ["wayland"]}
883885

884886
match stage_name:
885887
case "prod" | None:

build-scripts/const.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33

44
APP_NAME = "Amazon Q"
55
CLI_BINARY_NAME = "q"
6+
CLI_BINARY_NAME_MINIMAL = "q-minimal"
67
CHAT_BINARY_NAME = "qchat"
78
PTY_BINARY_NAME = "qterm"
89
DESKTOP_BINARY_NAME = "q-desktop"
910
URL_SCHEMA = "q"
1011
TAURI_PRODUCT_NAME = "q_desktop"
1112
LINUX_PACKAGE_NAME = "amazon-q"
13+
CHAT_BINARY_BRANCH = "prod"
1214

1315
# macos specific
1416
MACOS_BUNDLE_ID = "com.amazon.codewhisperer"

0 commit comments

Comments
 (0)