MCPcopy Index your code
hub / github.com/aws/amazon-q-developer-cli / build_chat_bin

Function build_chat_bin

scripts/build.py:67–113  ·  view source on GitHub ↗
(
    release: bool,
    output_name: str | None = None,
    targets: Sequence[str] = [],
)

Source from the content-addressed store, hash-verified

65
66
67def build_chat_bin(
68 release: bool,
69 output_name: str | None = None,
70 targets: Sequence[str] = [],
71):
72 package = CHAT_PACKAGE_NAME
73
74 args = [cargo_cmd_name(), "build", "--locked", "--package", package]
75
76 for target in targets:
77 args.extend(["--target", target])
78
79 if release:
80 args.append("--release")
81 target_subdir = "release"
82 else:
83 target_subdir = "debug"
84
85 run_cmd(
86 args,
87 env={
88 **os.environ,
89 **rust_env(release=release),
90 },
91 )
92
93 # create "universal" binary for macos
94 if isDarwin():
95 out_path = BUILD_DIR / f"{output_name or package}-universal-apple-darwin"
96 args = [
97 "lipo",
98 "-create",
99 "-output",
100 out_path,
101 ]
102 for target in targets:
103 args.append(pathlib.Path("target") / target / target_subdir / package)
104 run_cmd(args)
105 return out_path
106 else:
107 # linux does not cross compile arch
108 target = targets[0]
109 target_path = pathlib.Path("target") / target / target_subdir / package
110 out_path = BUILD_DIR / "bin" / f"{(output_name or package)}-{target}"
111 out_path.parent.mkdir(parents=True, exist_ok=True)
112 shutil.copy2(target_path, out_path)
113 return out_path
114
115
116@cache

Callers 1

buildFunction · 0.85

Calls 5

cargo_cmd_nameFunction · 0.90
run_cmdFunction · 0.90
rust_envFunction · 0.90
isDarwinFunction · 0.90
appendMethod · 0.80

Tested by

no test coverage detected