-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
67 lines (48 loc) · 1.62 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# commands
LUAC := luac
LUACHECK := luacheck
ZIP := zip -r
# directories
FACTORIO_MODS := ~/.Factorio/mods
# override the above with local values in the optional local.mk
-include local.mk
PACKAGE_NAME := $(shell cat info.json|jq -r .name)
VERSION_STRING := $(shell cat info.json|jq -r .version)
OUTPUT_NAME := $(PACKAGE_NAME)_$(VERSION_STRING)
OUTPUT_DIR := build/$(OUTPUT_NAME)
PKG_COPY := $(shell find . -iname '*.cfg' -type f -not -path "./build/*")
PKG_COPY += $(shell find . -iname '*.png' -type f -not -path "./build/*")
SED_FILES := $(shell find . -iname '*.json' -type f -not -path "./build/*")
SED_FILES += $(shell find . -iname '*.lua' -type f -not -path "./build/*")
SED_FILES += $(shell find . -iname '*.md' -type f -not -path "./build/*")
SED_FILES += $(shell find . -iname 'changelog.txt' -type f -not -path "./build/*")
OUT_FILES := $(SED_FILES:%=$(OUTPUT_DIR)/%)
SED_EXPRS := -e 's/{{MOD_NAME}}/$(PACKAGE_NAME)/g'
SED_EXPRS += -e 's/{{VERSION}}/$(VERSION_STRING)/g'
all: clean verify package install_mod
release: clean verify package install_mod tag
package-copy:
mkdir -p $(OUTPUT_DIR)
for a in $(PKG_COPY) ; do \
cp --parents $$a $(OUTPUT_DIR) ; \
done
$(OUTPUT_DIR)/%.lua: %.lua
@mkdir -p $(@D)
@sed $(SED_EXPRS) $< > $@
$(LUAC) -p $@
$(OUTPUT_DIR)/%: %
mkdir -p $(@D)
sed $(SED_EXPRS) $< > $@
package: package-copy $(OUT_FILES)
cd build && $(ZIP) $(OUTPUT_NAME).zip $(OUTPUT_NAME)
clean:
rm -rf build/
verify:
$(LUACHECK) .
install_mod:
if [ -d $(FACTORIO_MODS) ]; then \
rm -rf $(FACTORIO_MODS)/$(OUTPUT_NAME) ; \
cp -R build/$(OUTPUT_NAME) $(FACTORIO_MODS) ; \
fi;
tag:
git tag -f $(VERSION_STRING)