Add makefile

This commit is contained in:
Layla 2021-01-28 07:44:20 -05:00
parent be0173ee44
commit 8532f8664a
3 changed files with 86 additions and 1 deletions

3
.gitignore vendored
View File

@ -4,6 +4,7 @@
*.dll
*.so
*.dylib
bin/
# Test binary, built with `go test -c`
*.test
@ -12,4 +13,4 @@
*.out
# Dependency directories (remove the comment below to include it)
# vendor/
vendor/

81
Makefile Normal file
View File

@ -0,0 +1,81 @@
#include .env
PROJECTNAME="OpenSkins-Standalone-Plugin"
# Go related variables.
GOBASE=$(shell pwd)
GOPATH=$(GOBASE)/vendor:$(GOBASE)
GOBIN=$(GOBASE)/bin
GOFILES=$(wildcard *.go)
# Redirect error output to a file, so we can show it in development mode.
STDERR=/tmp/.$(PROJECTNAME)-stderr.txt
# PID file will store the server process id when it's running on development mode
PID=/tmp/.$(PROJECTNAME)-api-server.pid
# Make is verbose in Linux. Make it silent.
MAKEFLAGS += --silent
go-compile: go-clean go-get go-build
go-build:
@echo " > Building binary..."
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go build -buildmode=plugin -o $(GOBIN)/$(PROJECTNAME) $(GOFILES)
go-generate:
@echo " > Generating dependency files..."
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go generate $(generate)
go-get:
@echo " > Checking if there is any missing dependencies..."
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go get $(get)
go-install:
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go install $(GOFILES)
go-clean:
@echo " > Cleaning build cache"
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go clean
go-test:
@echo " > Running tests..."
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go test
go-run:
@echo " > Running ${PROJECTNAME}"
@-(cd $(GOBIN); ./$(PROJECTNAME))
## install: downloads and installs dependencies
install: go-get
## clean: test
clean:
@(MAKEFILE) go-clean
## compile: cleans project, installs dependencies, and builds project
compile:
@-touch $(STDERR)
@-rm $(STDERR)
@-$(MAKE) -s go-compile 2> $(STDERR)
@cat $(STDERR) | sed -e '1s/.*/\nError:\n/' | sed 's/make\[.*/ /' | sed "/^/s/^/ /" 1>&2
## watch: Runs go clean
watch:
@yolo -i . -e vendor -e bin -c $(run)
## build: Runs go build
build: go-build
run: go-compile go-run
## test: Run unit tests
test: go-test
## help: Displays help text for make commands
.DEFAULT_GOAL := help
all: help
help: Makefile
@echo " Choose a command run in "$(PROJECTNAME)":"
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'

View File

@ -4,5 +4,8 @@ import (
"github.com/josephbmanley/OpenSkins-Standalone-Plugin/core"
)
func main() {
}
// SkinstoreModule is a thing
var SkinstoreModule = core.SkinstoreStandalone{}