Skip to content

Commit

Permalink
feat: setup build process (#1)
Browse files Browse the repository at this point in the history
Signed-off-by: Artur Troian <[email protected]>
  • Loading branch information
troian authored May 9, 2024
1 parent 9b24bbf commit db89925
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
GO111MODULE=on
ROOT_DIR=${VANITY_ROOT}
DEVCACHE_BASE=${VANITY_ROOT}/.cache
DEVCACHE=${DEVCACHE_BASE}
DEVCACHE_BIN=${DEVCACHE}/bin
DEVCACHE_VERSIONS=${DEVCACHE}/versions
10 changes: 10 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
VANITY_ROOT=$(pwd)
export VANITY_ROOT

dotenv

VANITY_DIRENV_SET=1

export VANITY_DIRENV_SET

make cache
42 changes: 42 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
ifeq (0, $(shell id -u))
$(warning "make was started with superuser privileges. it may cause issues with direnv")
endif

ifeq (, $(shell which direnv))
$(error "No direnv in $(PATH), consider installing. https://direnv.net")
endif

ifneq (1, $(VANITY_DIRENV_SET))
$(error "no envrc detected. might need to run \"direnv allow\"")
endif

# VANITY_ROOT may not be set if environment does not support/use direnv
# in this case define it manually as well as all required env variables
ifndef VANITY_ROOT
$(error "VANITY_ROOT is not set. might need to run \"direnv allow\"")
endif

VANGEN_VERSION ?= latest
VANGEN := $(DEVCACHE_BIN)/vangen
VANGEN_VERSION_FILE := $(DEVCACHE_VERSIONS)/vangen/$(VANGEN_VERSION)

$(VANGEN_VERSION_FILE): $(DEVCACHE)
@echo "installing vangen $(VANGEN_VERSION) ..."
rm -f $(VANGEN)
GOBIN=$(DEVCACHE_BIN) go install 4d63.com/vangen@$(VANGEN_VERSION)
rm -rf "$(dir $@)"
mkdir -p "$(dir $@)"
touch $@
$(VANGEN): $(VANGEN_VERSION_FILE)


$(DEVCACHE):
@echo "creating .cache dir structure..."
mkdir -p $@
mkdir -p $(DEVCACHE_BIN)
mkdir -p $(DEVCACHE_VERSIONS)

cache: $(DEVCACHE)

vangen: $(VANGEN)
$(VANGEN) -config vangen.json -out .

0 comments on commit db89925

Please sign in to comment.