bedrocktool/Makefile

59 lines
1.3 KiB
Makefile
Raw Normal View History

2022-10-30 17:09:55 +00:00
TAG = $(shell git describe --exclude "r-*" --tags --always)
2022-08-14 14:12:33 +00:00
NAME = bedrocktool-${TAG}
2022-09-05 21:57:11 +00:00
SRCS = $(wildcard **/*.go)
2022-02-12 22:27:49 +00:00
2022-09-05 22:41:15 +00:00
GC = go build -ldflags "-s -w -X github.com/bedrock-tool/bedrocktool/utils.Version=${TAG}"
2022-09-05 21:57:11 +00:00
.PHONY: dists clean updates
2022-08-12 17:55:51 +00:00
2022-08-21 17:31:16 +00:00
# check if packs are supported
2022-08-12 17:55:51 +00:00
HAVE_PACKS = false
2022-09-05 21:57:11 +00:00
ifeq ($(shell head -c 7 ./utils/resourcepack-ace.go.ignore),package)
2022-08-12 17:55:51 +00:00
HAVE_PACKS = true
endif
2022-09-01 20:55:25 +00:00
2022-08-12 17:55:51 +00:00
$(info pack support: ${HAVE_PACKS})
2022-09-01 20:55:25 +00:00
ifeq ($(HAVE_PACKS),true)
2022-08-12 17:55:51 +00:00
GC += -overlay overlay.json
endif
2022-09-05 21:57:11 +00:00
bedrocktool: $(SRCS)
$(GC) -o $@ ./cmd/bedrocktool
2022-08-14 14:12:33 +00:00
BUILDS=\
2022-08-18 01:58:35 +00:00
windows_386.exe\
2022-08-14 14:12:33 +00:00
windows_amd64.exe\
windows_arm64.exe\
2022-08-17 20:12:40 +00:00
windows_arm.exe\
2022-08-14 14:12:33 +00:00
darwin_amd64\
darwin_arm64\
2022-08-18 01:58:35 +00:00
linux_386\
2022-08-14 14:12:33 +00:00
linux_amd64\
2022-08-17 18:04:13 +00:00
linux_arm64\
2022-08-21 17:31:16 +00:00
linux_arm
2022-08-12 17:55:51 +00:00
2022-08-21 17:31:16 +00:00
DISTS=$(BUILDS:%=dist/$(NAME)_%)
2022-09-05 21:57:11 +00:00
dists: $(DISTS)
$(DISTS): OS = $(word 2,$(subst _, ,$@))
$(DISTS): ARCH = $(word 1,$(subst ., ,$(word 3,$(subst _, ,$@))))
$(DISTS): BUILD = builds/$(OS)-$(ARCH)
2022-08-11 20:22:39 +00:00
2022-09-05 21:57:11 +00:00
dist builds:
mkdir -p dist builds
2022-08-11 20:22:39 +00:00
2022-09-05 21:57:11 +00:00
$(DISTS): dist builds $(SRCS)
$(info building: $@)
GOOS=$(OS) GOARCH=$(ARCH) $(GC) -o $(BUILD) ./cmd/bedrocktool
cp $(BUILD) $@
2022-02-12 22:27:49 +00:00
2022-09-05 21:57:11 +00:00
UPDATES=$(BUILDS)
$(UPDATES): OS = $(word 1,$(subst _, ,$@))
$(UPDATES): ARCH = $(word 1,$(subst ., ,$(word 2,$(subst _, ,$@))))
updates: $(UPDATES)
2022-08-21 17:31:16 +00:00
2022-09-05 21:57:11 +00:00
$(UPDATES): $(DISTS)
go-selfupdate -platform $(OS)-$(ARCH) builds/ $(TAG)
2022-02-12 22:27:49 +00:00
clean:
2022-09-05 21:57:11 +00:00
rm -r dist builds public