diff --git a/build-scripts/build.py b/build-scripts/build.py index 499204a4f..48c0bdadd 100644 --- a/build-scripts/build.py +++ b/build-scripts/build.py @@ -36,6 +36,7 @@ from importlib import import_module from const import ( APP_NAME, + CHAT_BINARY_BRANCH, CHAT_BINARY_NAME, CHAT_PACKAGE_NAME, CLI_BINARY_NAME, @@ -51,6 +52,7 @@ MACOS_BUNDLE_ID, PTY_BINARY_NAME, PTY_PACKAGE_NAME, + TAURI_PRODUCT_NAME, URL_SCHEMA, ) @@ -179,7 +181,7 @@ def fetch_chat_bin(chat_build_bucket_name: str | None, chat_download_role_arn: s warn("missing required chat arguments, creating dummy binary") dummy_dir = BUILD_DIR / "dummy_chat" dummy_dir.mkdir(exist_ok=True) - dummy_path = dummy_dir / f"qchat-{get_target_triple()}" + dummy_path = dummy_dir / f"{CHAT_BINARY_NAME}-{get_target_triple()}" dummy_path.write_text("#!/usr/bin/env sh\n\necho dummy chat binary\n") set_executable(dummy_path) return dummy_path @@ -205,21 +207,21 @@ def fetch_chat_bin(chat_build_bucket_name: str | None, chat_download_role_arn: s ) # The path to the download should be: - # BUILD_BUCKET/prod/latest/{target}/qchat.zip + # BUILD_BUCKET/{CHAT_BINARY_BRANCH}/latest/{target}/{CHAT_BINARY_NAME}.zip target = get_target_triple() - chat_bucket_path = f"prod/latest/{target}/qchat.zip" + chat_bucket_path = f"{CHAT_BINARY_BRANCH}/latest/{target}/{CHAT_BINARY_NAME}.zip" chat_dl_dir = BUILD_DIR / "chat_download" chat_dl_dir.mkdir(exist_ok=True) - chat_dl_path = chat_dl_dir / "qchat.zip" - info(f"Downloading qchat zip from bucket: {chat_bucket_path} and path: {chat_bucket_path}") + chat_dl_path = chat_dl_dir / f"{CHAT_BINARY_NAME}.zip" + info(f"Downloading {CHAT_BINARY_NAME} zip from bucket: {chat_bucket_path} and path: {chat_bucket_path}") s3.download_file(chat_build_bucket_name, chat_bucket_path, chat_dl_path) # unzip and return the path to the contained binary run_cmd(["unzip", "-o", chat_dl_path, "-d", chat_dl_dir]) # Append target triple, as expected by tauri cli. - chat_path = chat_dl_dir / f"qchat-{target}" - (chat_dl_dir / "qchat").rename(chat_path) + chat_path = chat_dl_dir / f"{CHAT_BINARY_NAME}-{target}" + (chat_dl_dir / CHAT_BINARY_NAME).rename(chat_path) return chat_path @@ -341,7 +343,7 @@ def build_macos_desktop_app( manifest_path.unlink(missing_ok=True) tauri_config_path.unlink(missing_ok=True) - target_bundle = pathlib.Path(f"target/{target}/release/bundle/macos/q_desktop.app") + target_bundle = pathlib.Path(f"target/{target}/release/bundle/macos/{TAURI_PRODUCT_NAME}.app") app_path = BUILD_DIR / f"{APP_NAME}.app" shutil.rmtree(app_path, ignore_errors=True) shutil.copytree(target_bundle, app_path) @@ -466,9 +468,9 @@ def build_linux_minimal(cli_path: pathlib.Path, pty_path: pathlib.Path, chat_pat Creates tar.gz, tar.xz, tar.zst, and zip archives under `BUILD_DIR`. Each archive has the following structure: - - archive/bin/q - - archive/bin/qterm - - archive/bin/qchat + - archive/bin/{cli_binary} + - archive/bin/{pty_binary} + - archive/bin/{chat_binary} - archive/install.sh - archive/README - archive/BUILD-INFO @@ -879,7 +881,7 @@ def build( else: signing_data = None - cargo_features: Mapping[str, Sequence[str]] = {"q_cli": ["wayland"]} + cargo_features: Mapping[str, Sequence[str]] = {CLI_PACKAGE_NAME: ["wayland"]} match stage_name: case "prod" | None: diff --git a/build-scripts/const.py b/build-scripts/const.py index 8f3b19dcd..e3db6fade 100644 --- a/build-scripts/const.py +++ b/build-scripts/const.py @@ -3,12 +3,14 @@ APP_NAME = "Amazon Q" CLI_BINARY_NAME = "q" +CLI_BINARY_NAME_MINIMAL = "q-minimal" CHAT_BINARY_NAME = "qchat" PTY_BINARY_NAME = "qterm" DESKTOP_BINARY_NAME = "q-desktop" URL_SCHEMA = "q" TAURI_PRODUCT_NAME = "q_desktop" LINUX_PACKAGE_NAME = "amazon-q" +CHAT_BINARY_BRANCH = "prod" # macos specific MACOS_BUNDLE_ID = "com.amazon.codewhisperer" diff --git a/build-scripts/manifest.py b/build-scripts/manifest.py index c31ce46cc..61f450089 100644 --- a/build-scripts/manifest.py +++ b/build-scripts/manifest.py @@ -1,7 +1,7 @@ from dataclasses import dataclass from enum import Enum -from const import APPLE_TEAM_ID +from const import APPLE_TEAM_ID, APP_NAME, CLI_BINARY_NAME, PTY_BINARY_NAME, CHAT_BINARY_NAME class CdSigningType(Enum): @@ -52,21 +52,21 @@ def manifest( def app_manifest(): return manifest( - name="Amazon Q.app", + name=f"{APP_NAME}.app", identifier="com.amazon.codewhisperer", entitlements=True, embedded_requirements=[ EmbeddedRequirement( - path="Contents/MacOS/q", - identifier="com.amazon.q", + path=f"Contents/MacOS/{CLI_BINARY_NAME}", + identifier=f"com.amazon.{CLI_BINARY_NAME}", ), EmbeddedRequirement( - path="Contents/MacOS/qterm", - identifier="com.amazon.qterm", + path=f"Contents/MacOS/{PTY_BINARY_NAME}", + identifier=f"com.amazon.{PTY_BINARY_NAME}", ), EmbeddedRequirement( - path="Contents/MacOS/qchat", - identifier="com.amazon.qchat", + path=f"Contents/MacOS/{CHAT_BINARY_NAME}", + identifier=f"com.amazon.{CHAT_BINARY_NAME}", ), ], ) diff --git a/build-scripts/qchatbuild.py b/build-scripts/qchatbuild.py index 4a00ca900..bae469b49 100644 --- a/build-scripts/qchatbuild.py +++ b/build-scripts/qchatbuild.py @@ -201,7 +201,7 @@ def cd_build_signed_package(exe_path: pathlib.Path): ``` package ├─ EXECUTABLES_TO_SIGN - | ├─ qchat + | ├─ {chat_binary} ``` """ # Trying a different format without manifest.yaml and placing EXECUTABLES_TO_SIGN @@ -376,7 +376,7 @@ def sign_and_notarize(signing_data: CdSigningData, chat_path: pathlib.Path) -> p def build_macos(chat_path: pathlib.Path, signing_data: CdSigningData | None): """ - Creates a qchat.zip under the build directory. + Creates a chat binary zip under the build directory. """ chat_dst = BUILD_DIR / CHAT_BINARY_NAME chat_dst.unlink(missing_ok=True) @@ -495,7 +495,7 @@ def build_linux(chat_path: pathlib.Path, signer: GpgSigner | None): Creates tar.gz, tar.xz, tar.zst, and zip archives under `BUILD_DIR`. Each archive has the following structure: - - archive/qchat + - archive/{chat_binary} """ archive_name = CHAT_BINARY_NAME diff --git a/build-scripts/qchatmain.py b/build-scripts/qchatmain.py index 8389c5e65..b6142ee52 100644 --- a/build-scripts/qchatmain.py +++ b/build-scripts/qchatmain.py @@ -10,7 +10,7 @@ def __call__(self, parser, namespace, values, option_string=None): parser = argparse.ArgumentParser( prog="build", - description="Builds the qchat binary", + description="Builds the chat binary", ) subparsers = parser.add_subparsers(help="sub-command help", dest="subparser", required=True) diff --git a/bundle/linux/install.sh b/bundle/linux/install.sh index 7e5206a54..46584cf13 100755 --- a/bundle/linux/install.sh +++ b/bundle/linux/install.sh @@ -7,6 +7,9 @@ set -o errexit set -o nounset SCRIPT_DIR="$(dirname "$(readlink -f "$0")")" +CLI_BINARY_NAME="q" +CHAT_BINARY_NAME="qchat" +PTY_BINARY_NAME="qterm" log_error() { printf '\e[31m[ERROR]\e[0m %s\n' "$1" >&2 @@ -136,22 +139,22 @@ if is_target_triple_gnu && ! check_glibc_version; then fi if [ -n "${Q_INSTALL_GLOBAL:-}" ]; then - install -m 755 "$SCRIPT_DIR/bin/q" /usr/local/bin/ - install -m 755 "$SCRIPT_DIR/bin/qchat" /usr/local/bin/ - install -m 755 "$SCRIPT_DIR/bin/qterm" /usr/local/bin/ + install -m 755 "$SCRIPT_DIR/bin/$CLI_BINARY_NAME" /usr/local/bin/ + install -m 755 "$SCRIPT_DIR/bin/$CHAT_BINARY_NAME" /usr/local/bin/ + install -m 755 "$SCRIPT_DIR/bin/$PTY_BINARY_NAME" /usr/local/bin/ if [ -z "${Q_SKIP_SETUP:-}" ]; then - /usr/local/bin/q integrations install dotfiles - /usr/local/bin/q setup --global "$@" + /usr/local/bin/$CLI_BINARY_NAME integrations install dotfiles + /usr/local/bin/$CLI_BINARY_NAME setup --global "$@" fi else mkdir -p "$HOME/.local/bin" - install -m 755 "$SCRIPT_DIR/bin/q" "$HOME/.local/bin/" - install -m 755 "$SCRIPT_DIR/bin/qchat" "$HOME/.local/bin/" - install -m 755 "$SCRIPT_DIR/bin/qterm" "$HOME/.local/bin/" + install -m 755 "$SCRIPT_DIR/bin/$CLI_BINARY_NAME" "$HOME/.local/bin/" + install -m 755 "$SCRIPT_DIR/bin/$CHAT_BINARY_NAME" "$HOME/.local/bin/" + install -m 755 "$SCRIPT_DIR/bin/$PTY_BINARY_NAME" "$HOME/.local/bin/" if [ -z "${Q_SKIP_SETUP:-}" ]; then - "$HOME/.local/bin/q" setup "$@" + "$HOME/.local/bin/$CLI_BINARY_NAME" setup "$@" fi fi diff --git a/crates/chat-cli/src/cli/chat/context.rs b/crates/chat-cli/src/cli/chat/context.rs index 9727ed928..4aff145fc 100644 --- a/crates/chat-cli/src/cli/chat/context.rs +++ b/crates/chat-cli/src/cli/chat/context.rs @@ -251,6 +251,7 @@ impl ContextManager { /// /// # Returns /// A Result containing a vector of profile names, with "default" always first + #[cfg_attr(target_os = "windows", allow(dead_code))] pub fn list_profiles_blocking(&self, os: &Os) -> Result> { let _ = self; diff --git a/crates/chat-cli/src/cli/mod.rs b/crates/chat-cli/src/cli/mod.rs index 3e0fb43ad..637b86968 100644 --- a/crates/chat-cli/src/cli/mod.rs +++ b/crates/chat-cli/src/cli/mod.rs @@ -48,6 +48,7 @@ use crate::logging::{ use crate::os::Os; use crate::util::directories::logs_dir; use crate::util::{ + CHAT_BINARY_NAME, CLI_BINARY_NAME, GOV_REGIONS, }; @@ -216,7 +217,11 @@ impl Cli { }, log_to_stdout: std::env::var_os("Q_LOG_STDOUT").is_some() || self.verbose > 0, log_file_path: match subcommand { - RootSubcommand::Chat { .. } => Some(logs_dir().expect("home dir must be set").join("qchat.log")), + RootSubcommand::Chat { .. } => Some( + logs_dir() + .expect("home dir must be set") + .join(format!("{CHAT_BINARY_NAME}.log")), + ), _ => None, }, delete_old_log_file: false, diff --git a/crates/chat-cli/src/logging.rs b/crates/chat-cli/src/logging.rs index 60edfd9e9..3f8dbd811 100644 --- a/crates/chat-cli/src/logging.rs +++ b/crates/chat-cli/src/logging.rs @@ -14,6 +14,7 @@ use tracing_subscriber::{ fmt, }; +use crate::util::consts::CHAT_BINARY_NAME; use crate::util::env_var::Q_LOG_LEVEL; const MAX_FILE_SIZE: u64 = 10 * 1024 * 1024; @@ -76,7 +77,7 @@ pub fn initialize_logging>(args: LogArgs) -> Result>(args: LogArgs) -> Result /dev/null 2>&1 & + "$macos_bin/$DESKTOP_BINARY_NAME" --no-dashboard > /dev/null 2>&1 & } # Install on Linux