Skip to content

Commit

Permalink
feat(Makefile): add Windows build target and refactor build commands
Browse files Browse the repository at this point in the history
- Introduced a `build-windows` target to build the Kion CLI for Windows (GOOS=windows, GOARCH=amd64).
- Refactored `build` target to utilize `LDFLAGS` for setting version information and compressing binaries.
- Added `GO` variable for the Go compiler to allow more flexible build commands.
- Updated the clean target to remove the Windows binary (`kion_windows.exe`).
  • Loading branch information
bshutterkion committed Sep 11, 2024
1 parent 49ea1a4 commit 9ca0bdc
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ CYN="$$(tput setaf 6)"
# reset terminal output
NRM="$$(tput sgr0)"

# Go compiler
GO := go

# LDFLAGS for compressing the binary or setting version information
LDFLAGS := -X main.kionCliVersion=$$(cat VERSION.md) -s -w

default:
@printf "\n\
\
Expand All @@ -32,6 +38,7 @@ default:
$(B)$(BLU)$(UN)Development:$(NRM)\n\n\
\
$(B)$(GRN)build$(NRM) $(GRN)Build the kion binary$(NRM)\n\
$(B)$(GRN)build-windows$(NRM) $(GRN)Build the kion binary for Windows$(NRM)\n\
$(B)$(GRN)gofmt$(NRM) $(GRN)Run gofmt against the repo$(NRM)\n\
$(B)$(GRN)lint$(NRM) $(GRN)Run golangci-lint against the repo$(NRM)\n\
$(B)$(GRN)test$(NRM) $(GRN)Run all go tests$(NRM)\n\
Expand All @@ -51,7 +58,11 @@ init:

build:
@printf "${B}${UN}${BLU}Building Kion CLI:${NRM}\n"
go build -ldflags "-X main.kionCliVersion=$$(cat VERSION.md)" -o kion
$(GO) build -ldflags "$(LDFLAGS)" -o kion

build-windows:
@printf "${B}${UN}${BLU}Building Kion CLI for Windows:${NRM}\n"
GOOS=windows GOARCH=amd64 $(GO) build -ldflags "$(LDFLAGS)" -o kion_windows.exe

gofmt:
@printf "${B}${UN}${BLU}Running gofmt:${NRM}\n"
Expand Down Expand Up @@ -83,5 +94,6 @@ install-symlink: build
clean:
@printf "${B}${UN}${BLU}Cleaning generated assets and helpers:${NRM}\n"
rm -f kion
rm -f kion_windows.exe
rm -f profile.cov
rm -f tools/golangci-lint

0 comments on commit 9ca0bdc

Please sign in to comment.