forked from Afforess/Factorio-Stdlib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
66 lines (51 loc) · 2.27 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
PACKAGE_NAME := $(shell cat 'mod/info.json'|jq -r .name)
VERSION_STRING := $(shell cat 'mod/info.json'|jq -r .version)
OUTPUT_DIR := $(PACKAGE_NAME)
OUTPUT_NAME := $(PACKAGE_NAME)_$(VERSION_STRING)
BUILD_DIR := build
FILES := $(shell find . -iname '*.json' -type f -path "./stdlib/*") $(shell find . -iname '*.lua' -type f -path "./stdlib/*")
DEP_FILES := $(shell find . -iname '*.lua' -type f -path "./deprecated/*")
MOD_FILES := $(shell find . -iname '*' -type f -path "./mod/*")
all: clean check test package mod-files deprecated ldoc luacheck release
nodeps: clean check test package mod-files ldoc luacheck release
mod: clean test package mod-files
nochecks: clean package deprecated release
doc: clean package deprecated ldoc
clean:
@rm -rf $(BUILD_DIR)
check:
@echo 'Checking lua files for errors'
@set -e; for file in $$(find . -iname '*.lua' -type f -not -path "./$(BUILD_DIR)/*"); do echo "Checking syntax: $$file" ; luac -p $$file; done;
test:
@echo 'Running tests'
@busted
package: $(FILES)
@echo 'Copying files'
@mkdir -p $(BUILD_DIR)/$(OUTPUT_NAME)
@cp -r $(PACKAGE_NAME) $(BUILD_DIR)/$(OUTPUT_NAME)/$(PACKAGE_NAME)
@cp README.md $(BUILD_DIR)/$(OUTPUT_NAME)/README.md
@cp LICENSE $(BUILD_DIR)/$(OUTPUT_NAME)/LICENSE.md
@cp CHANGELOG.md $(BUILD_DIR)/$(OUTPUT_NAME)/CHANGELOG.md
deprecated: $(DEP_FILES)
@echo 'Copying deprecated files'
@cp -rPn ./deprecated/* $(BUILD_DIR)/$(OUTPUT_NAME)/$(PACKAGE_NAME)
mod-files: $(MOD_FILES)
@echo 'Copying test mod files'
@cp -PRn ./mod/* $(BUILD_DIR)/$(OUTPUT_NAME)/
ldoc:
@echo 'Auto Generating with ldoc'
@mkdir -p $(BUILD_DIR)/doc
@cp README.md $(BUILD_DIR)/doc/readme.md
@cp doc/spectre.min.css $(BUILD_DIR)/doc/spectre.min.css
@cp doc/spectre-icons.min.css $(BUILD_DIR)/doc/spectre-icons.min.css
@cp -r examples/ $(BUILD_DIR)/doc/examples/
@cd $(BUILD_DIR) && ldoc -c ../doc/config.ld -l ../doc -s ../doc $(OUTPUT_NAME)/$(PACKAGE_NAME)
luacheck:
@echo 'Running luacheck on build directory'
@luacheck --version
@wget -q --no-check-certificate -O $(BUILD_DIR)/.luacheckrc https://raw.githubusercontent.com/Nexela/Factorio-luacheckrc/master/.luacheckrc
@cd $(BUILD_DIR)/$(OUTPUT_NAME) && luacheck .
release:
@echo 'Making Release'
@cd $(BUILD_DIR) && zip -rq $(OUTPUT_NAME).zip $(OUTPUT_NAME)
@echo $(OUTPUT_NAME).zip ready