initial commit
This commit is contained in:
60
Makefile
Normal file
60
Makefile
Normal file
@@ -0,0 +1,60 @@
|
||||
APP_NAME := autoattendance
|
||||
SRC_DIR := src
|
||||
BUILD_DIR := bin
|
||||
CMD_PATH := ./cmd
|
||||
|
||||
GOCMD := go
|
||||
GOBUILD := $(GOCMD) build
|
||||
GOTEST := $(GOCMD) test
|
||||
GOCLEAN := $(GOCMD) clean
|
||||
GOTIDY := $(GOCMD) mod tidy
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
BINARY_EXT := .exe
|
||||
RM := del /Q
|
||||
MKDIR := mkdir
|
||||
else
|
||||
BINARY_EXT :=
|
||||
RM := rm -f
|
||||
MKDIR := mkdir -p
|
||||
endif
|
||||
|
||||
BINARY_NAME := $(BUILD_DIR)/$(APP_NAME)$(BINARY_EXT)
|
||||
|
||||
$(shell $(MKDIR) $(BUILD_DIR))
|
||||
|
||||
.PHONY: all build run clean test tidy help
|
||||
|
||||
all: tidy test build
|
||||
|
||||
build:
|
||||
@cd $(SRC_DIR) && $(GOBUILD) -o ../$(BINARY_NAME) $(CMD_PATH)
|
||||
@echo "Build complete: $(BINARY_NAME)"
|
||||
|
||||
run: build
|
||||
@./$(BINARY_NAME)
|
||||
|
||||
test:
|
||||
@cd $(SRC_DIR) && $(GOTEST) ./...
|
||||
|
||||
tidy:
|
||||
@cd $(SRC_DIR) && $(GOTIDY)
|
||||
|
||||
clean:
|
||||
@$(RM) $(BINARY_NAME)
|
||||
@echo "Clean complete"
|
||||
|
||||
help:
|
||||
@echo "Available targets:"
|
||||
@awk '/^## / {sub(/^## /, "", $$0); getline desc; print " " $$0 ": " desc;}' $(MAKEFILE_LIST)
|
||||
|
||||
build-linux:
|
||||
@$(MKDIR) $(BUILD_DIR)
|
||||
@cd $(SRC_DIR) && GOOS=linux GOARCH=amd64 $(GOBUILD) -o ../$(BUILD_DIR)/$(APP_NAME)-linux $(CMD_PATH)
|
||||
|
||||
build-windows:
|
||||
@$(MKDIR) $(BUILD_DIR)
|
||||
@cd $(SRC_DIR) && GOOS=windows GOARCH=amd64 $(GOBUILD) -o ../$(BUILD_DIR)/$(APP_NAME).exe $(CMD_PATH)
|
||||
|
||||
build-all: build-linux build-windows
|
||||
@echo "Cross-compilation complete"
|
||||
Reference in New Issue
Block a user