Files
monkey/Makefile
Chuck Smith 4c9ec5aaaa
Some checks failed
Build / build (push) Failing after 6m4s
Test / build (push) Failing after 6m33s
server
2024-04-02 12:21:41 -04:00

91 lines
2.4 KiB
Makefile

.PHONY: dev build cli server install image release profile compare bench test clean
CGO_ENABLED=0
VERSION ?= $(shell git describe)
DESTDIR ?= $(GOBIN)
ifeq ($(LOCAL), 1)
IMAGE := r.unflavoredmeson.com/UnflavoredMeson/monkey
TAG := dev
else
ifeq ($(BRANCH), master)
IMAGE := UnflavoredMeson/monkey
TAG := latest
else
IMAGE := UnflavoredMeson/monkey
TAG := dev
endif
endif
all: help
help: ## Show this help message
@echo "monkey - Monkey Lang"
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[$$()% a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
dev: cli ## Build monkey and run the REPL
@./monkey
build: clean cli server ## Build monkey
cli: ## Build monkey CLI
@go build \
-tags "netgo static_build" -installsuffix netgo \
-ldflags "-w -X go.unflavoredmeson.com/monkey/MonkeyVersion=$(VERSION)" \
./cmd/monkey/...
server: ## Build Monkey server
@go build \
-tags "netgo static_build" -installsuffix netgo \
-ldflags "-w -X go.unflavoredmeson.com/monkey/MonkeyVersion=$(VERSION)" \
./cmd/monkey/...
install: cli server ## Install monkey to $DESTDIR
@install -D -m 755 monkey $(DESTDIR)/monkey
@install -D -m 755 monkey-server $(DESTDIR)monkey-server
ifeq ($(PUBLISH), 1)
image: ## Build and Publish the Docker image
@docker buildx build \
--build-arg VERSION="$(VERSION)" \
--build-arg COMMIT="$(COMMIT)" \
--build-arg BUILD="$(BUILD)" \
--platform linux/amd64,linux/arm64 --push -t $(IMAGE):$(TAG) .
else
image: ## Build the Docker image
@docker build \
--build-arg VERSION="$(VERSION)" -t $(IMAGE):$(TAG) .
endif
release: ## Release monkey
@./tools/release.sh
profile: ## Run tests with profiling enabled
@go test -cpuprofile cpu.prof -memprofile mem.prof -v -bench ./...
compare: ## Run benchmarks comparing Monkey with other languages
@hyperfine -w 3 -p 'make build; gcc -o examples/fib examples/fib.c' \
-n c -n go -n tengo -n python -n monkey \
--sort mean-time --export-markdown Benchmark.md \
'./examples/fib' \
'go run examples/fib.go' \
'tengo examples/fib.tengo' \
'python3 examples/fib.py' \
'./monkey examples/fib.m'
bench: # Run test benchmarks
@go test -v -benchmem -bench=. ./...
test: ## Run unit tests
@go test -v \
-cover \
-coverprofile coverage.out \
-covermode atomic \
-coverpkg ./... \
-race \
./...
clean: ## Cleanup untrakced files
@git clean -f -d -X 2> /dev/null || true