Skip to content

Makefile buff-ification #3700

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Sep 2, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: buff makefile pt. 4 make install
  • Loading branch information
deansheather committed Aug 26, 2022
commit 29de6ced14e27f4e08ebe754695676ea850cea98
31 changes: 11 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ ifndef VERBOSE
.SILENT:
endif

# Create the build directory if it does not exist.
$(shell mkdir -p build)
# Create the output directories if they do not exist.
$(shell mkdir -p build site/out/bin)

INSTALL_DIR := $(shell go env GOPATH)/bin
GOOS := $(shell go env GOOS)
GOARCH := $(shell go env GOARCH)
GOOS_BIN_EXT := $(if $(filter windows, $(GOOS)),.exe,)
VERSION := $(shell ./scripts/version.sh)

# All ${OS}_${ARCH} combos we build for. Windows binaries have the .exe suffix.
Expand Down Expand Up @@ -63,8 +63,9 @@ CODER_ALL_NOVERSION_IMAGES_PUSHED := $(addprefix push/, $(CODER_ALL_NOVERSION_IM


clean:
rm -rf build
mkdir -p build
rm -rf build site/out
mkdir -p build site/out/bin
git restore site/out
.PHONY: clean

build-slim bin: $(CODER_SLIM_BINARIES)
Expand Down Expand Up @@ -320,22 +321,12 @@ fmt: fmt/prettier fmt/terraform fmt/shfmt
gen: coderd/database/querier.go peerbroker/proto/peerbroker.pb.go provisionersdk/proto/provisioner.pb.go provisionerd/proto/provisionerd.pb.go site/src/api/typesGenerated.ts
.PHONY: gen

install: site/out/index.html $(shell find . -not -path './vendor/*' -type f -name '*.go') go.mod go.sum $(shell find ./examples/templates)
output_file="$(INSTALL_DIR)/coder"
install: build/coder_$(VERSION)_$(GOOS)_$(GOARCH)$(GOOS_BIN_EXT)
install_dir="$$(go env GOPATH)/bin"
output_file="$${install_dir}/coder$(GOOS_BIN_EXT)"

if [[ "$(GOOS)" == "windows" ]]; then
output_file="$${output_file}.exe"
fi

echo "-- Building CLI for $(GOOS) $(GOARCH) at $$output_file"

./scripts/build_go.sh \
--version "$(VERSION)" \
--output "$$output_file" \
--os "$(GOOS)" \
--arch "$(GOARCH)"

echo
mkdir -p "$$install_dir"
cp "$<" "$$output_file"
.PHONY: install

lint: lint/shellcheck lint/go
Expand Down