-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
63 lines (48 loc) · 1.74 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
JQ = $(shell which jq 2> /dev/null)
ifeq ($(strip $(JQ)),)
$(error "jq program is required to parse info.json")
endif
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 := $(wildcard *.md) graphics locale blueprintstring
SED_FILES := $(shell find . -iname '*.json' -type f -not -path "./build/*") $(shell find . -iname '*.lua' -type f -not -path "./build/*") $(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 remove_mod install_mod
release: clean verify package remove_mod install_mod tag
package-copy: $(PKG_DIRS) $(PKG_FILES)
mkdir -p $(OUTPUT_DIR)
ifneq ($(PKG_COPY),)
cp -r $(PKG_COPY) build/$(OUTPUT_NAME)
endif
$(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 -r $(OUTPUT_NAME).zip $(OUTPUT_NAME)
clean:
rm -rf build/
verify:
luacheck . --exclude-files blueprintstring/ --exclude-files factorio_mods/ --exclude-files build/ --exclude-files data*.lua --exclude-files prototypes/ -d --globals Game game global remote serpent bit32 defines script table string log util
remove_mod:
if [ -L factorio_mods ];\
then \
for name in factorio_mods/$(PACKAGE_NAME)*; do \
echo "removing $$name"; \
rm -rf $$name; \
done \
fi;
install_mod:
if [ -L factorio_mods ] ; \
then \
cp -R build/$(OUTPUT_NAME) factorio_mods ; \
fi;
tag:
git tag -f $(VERSION_STRING)