|
23 | 23 |
|
24 | 24 | ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" |
25 | 25 |
|
| 26 | +cargo_target_dir() { |
| 27 | + if [ -n "${CARGO_TARGET_DIR:-}" ]; then |
| 28 | + case "${CARGO_TARGET_DIR}" in |
| 29 | + /*) printf '%s\n' "${CARGO_TARGET_DIR}" ;; |
| 30 | + *) printf '%s\n' "${ROOT}/${CARGO_TARGET_DIR}" ;; |
| 31 | + esac |
| 32 | + return 0 |
| 33 | + fi |
| 34 | + |
| 35 | + cargo metadata --format-version=1 --no-deps \ |
| 36 | + | python3 -c 'import json, sys; print(json.load(sys.stdin)["target_directory"])' |
| 37 | +} |
| 38 | + |
26 | 39 | github_actions_host_docker_tmpdir() { |
27 | 40 | if [ "${GITHUB_ACTIONS:-}" != "true" ] \ |
28 | 41 | || [ ! -S /var/run/docker.sock ] \ |
|
55 | 68 | fi |
56 | 69 | WORKDIR_PARENT="${WORKDIR_PARENT%/}" |
57 | 70 | WORKDIR="$(mktemp -d "${WORKDIR_PARENT}/openshell-e2e-gateway.XXXXXX")" |
58 | | -GATEWAY_BIN="${ROOT}/target/debug/openshell-gateway" |
59 | | -CLI_BIN="${ROOT}/target/debug/openshell" |
| 71 | +GATEWAY_BIN="" |
| 72 | +CLI_BIN="" |
60 | 73 | GATEWAY_PID="" |
61 | 74 | GATEWAY_LOG="${WORKDIR}/gateway.log" |
62 | 75 | GATEWAY_CONFIG_DIR="" |
@@ -333,18 +346,36 @@ if [ -n "${CARGO_BUILD_JOBS:-}" ]; then |
333 | 346 | CARGO_BUILD_JOBS_ARG=(-j "${CARGO_BUILD_JOBS}") |
334 | 347 | fi |
335 | 348 |
|
336 | | -echo "Building openshell-gateway and openshell-cli..." |
| 349 | +TARGET_DIR="$(cargo_target_dir)" |
| 350 | +GATEWAY_BIN="${TARGET_DIR}/debug/openshell-gateway" |
| 351 | +CLI_BIN="${TARGET_DIR}/debug/openshell" |
| 352 | + |
| 353 | +echo "Building openshell-gateway..." |
337 | 354 | cargo build ${CARGO_BUILD_JOBS_ARG[@]+"${CARGO_BUILD_JOBS_ARG[@]}"} \ |
338 | 355 | -p openshell-server --bin openshell-gateway \ |
339 | | - -p openshell-cli --features openshell-core/dev-settings |
| 356 | + --features openshell-core/dev-settings |
| 357 | + |
| 358 | +echo "Building openshell-cli..." |
| 359 | +cargo build ${CARGO_BUILD_JOBS_ARG[@]+"${CARGO_BUILD_JOBS_ARG[@]}"} \ |
| 360 | + -p openshell-cli --bin openshell \ |
| 361 | + --features openshell-core/dev-settings |
| 362 | + |
| 363 | +if [ ! -x "${GATEWAY_BIN}" ]; then |
| 364 | + echo "ERROR: expected openshell-gateway binary at ${GATEWAY_BIN}" >&2 |
| 365 | + exit 1 |
| 366 | +fi |
| 367 | +if [ ! -x "${CLI_BIN}" ]; then |
| 368 | + echo "ERROR: expected openshell CLI binary at ${CLI_BIN}" >&2 |
| 369 | + exit 1 |
| 370 | +fi |
340 | 371 |
|
341 | 372 | echo "Building openshell-sandbox for ${SUPERVISOR_TARGET}..." |
342 | 373 | mkdir -p "${SUPERVISOR_OUT_DIR}" |
343 | 374 | if [ "${HOST_OS}" = "Linux" ] && [ "${HOST_ARCH}" = "${DAEMON_ARCH}" ]; then |
344 | 375 | rustup target add "${SUPERVISOR_TARGET}" >/dev/null 2>&1 || true |
345 | 376 | cargo build ${CARGO_BUILD_JOBS_ARG[@]+"${CARGO_BUILD_JOBS_ARG[@]}"} \ |
346 | 377 | --release -p openshell-sandbox --target "${SUPERVISOR_TARGET}" |
347 | | - cp "${ROOT}/target/${SUPERVISOR_TARGET}/release/openshell-sandbox" "${SUPERVISOR_BIN}" |
| 378 | + cp "${TARGET_DIR}/${SUPERVISOR_TARGET}/release/openshell-sandbox" "${SUPERVISOR_BIN}" |
348 | 379 | else |
349 | 380 | CONTAINER_ENGINE=docker \ |
350 | 381 | DOCKER_PLATFORM="linux/${DAEMON_ARCH}" \ |
|
0 commit comments