From 1ff3bc723928b6468969b21ad2cbb7fff0c01f0a Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Tue, 11 Jul 2023 11:45:08 +0000 Subject: [PATCH 1/3] chore(scripts): use slim and always run make in `coder-dev.sh` --- scripts/coder-dev.sh | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/scripts/coder-dev.sh b/scripts/coder-dev.sh index 5c3de4e310d13..98a67b9dcb612 100755 --- a/scripts/coder-dev.sh +++ b/scripts/coder-dev.sh @@ -10,7 +10,7 @@ source "${SCRIPT_DIR}/lib.sh" GOOS="$(go env GOOS)" GOARCH="$(go env GOARCH)" -RELATIVE_BINARY_PATH="build/coder_${GOOS}_${GOARCH}" +RELATIVE_BINARY_PATH="build/coder-slim_${GOOS}_${GOARCH}" # To preserve the CWD when running the binary, we need to use pushd and popd to # get absolute paths to everything. @@ -20,10 +20,6 @@ CODER_DEV_BIN="$(realpath "$RELATIVE_BINARY_PATH")" CODER_DEV_DIR="$(realpath ./.coderv2)" popd -if [[ ! -x "${CODER_DEV_BIN}" ]]; then - echo "Run this command first:" - echo " make $RELATIVE_BINARY_PATH" - exit 1 -fi +make -j "${RELATIVE_BINARY_PATH}" exec "${CODER_DEV_BIN}" --global-config "${CODER_DEV_DIR}" "$@" From 36a03004c2df8d05b3a81c8c404b5b96533be65b Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Wed, 12 Jul 2023 18:48:49 +0000 Subject: [PATCH 2/3] enable coder server usage via coder-dev.sh, with caveat --- scripts/coder-dev.sh | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/scripts/coder-dev.sh b/scripts/coder-dev.sh index 98a67b9dcb612..8919505f69211 100755 --- a/scripts/coder-dev.sh +++ b/scripts/coder-dev.sh @@ -10,7 +10,11 @@ source "${SCRIPT_DIR}/lib.sh" GOOS="$(go env GOOS)" GOARCH="$(go env GOARCH)" -RELATIVE_BINARY_PATH="build/coder-slim_${GOOS}_${GOARCH}" +BINARY_TYPE=coder-slim +if [[ $1 == server ]]; then + BINARY_TYPE=coder +fi +RELATIVE_BINARY_PATH="build/${BINARY_TYPE}_${GOOS}_${GOARCH}" # To preserve the CWD when running the binary, we need to use pushd and popd to # get absolute paths to everything. @@ -20,6 +24,26 @@ CODER_DEV_BIN="$(realpath "$RELATIVE_BINARY_PATH")" CODER_DEV_DIR="$(realpath ./.coderv2)" popd -make -j "${RELATIVE_BINARY_PATH}" +case $BINARY_TYPE in +coder-slim) + # Ensure the coder slim binary is always up-to-date with local + # changes, this simplifies usage of this script for development. + make -j "${RELATIVE_BINARY_PATH}" + ;; +coder) + if [[ ! -x "${CODER_DEV_BIN}" ]]; then + # A feature requiring the full binary was requested and the + # binary is missing, normally it's built by `develop.sh`, but + # it's an expensive operation, so we require manual action here. + echo "Running \"coder $1\" requires the full binary, please run \"develop.sh\" first or build the binary manually:" + echo " make $RELATIVE_BINARY_PATH" + exit 1 + fi + ;; +*) + echo "Unknown binary type: $BINARY_TYPE" + exit 1 + ;; +esac exec "${CODER_DEV_BIN}" --global-config "${CODER_DEV_DIR}" "$@" From 4b719e1a6539ea26a7f6580e95ec3c926ad3e3e8 Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Wed, 12 Jul 2023 18:56:47 +0000 Subject: [PATCH 3/3] print to stderr --- scripts/coder-dev.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/coder-dev.sh b/scripts/coder-dev.sh index 8919505f69211..9d3d6e7f74233 100755 --- a/scripts/coder-dev.sh +++ b/scripts/coder-dev.sh @@ -35,8 +35,8 @@ coder) # A feature requiring the full binary was requested and the # binary is missing, normally it's built by `develop.sh`, but # it's an expensive operation, so we require manual action here. - echo "Running \"coder $1\" requires the full binary, please run \"develop.sh\" first or build the binary manually:" - echo " make $RELATIVE_BINARY_PATH" + echo "Running \"coder $1\" requires the full binary, please run \"develop.sh\" first or build the binary manually:" 1>&2 + echo " make $RELATIVE_BINARY_PATH" 1>&2 exit 1 fi ;;