Commit fa071f10 authored by Delisa Mason's avatar Delisa Mason

build: Add targets for exporting the game

parent b478cea6
......@@ -3,19 +3,69 @@ all: build
TILED:=~/bin/apps/Tiled.app/Contents/MacOS/Tiled
LOVE:=/usr/local/bin/love
.PHONY: run build add-map add-state add-system help test tiled-run tiled-edit-hooks
# ~ Packaging:
WINLOVE:=../love-win32/love.exe
MACLOVE:=~/bin/apps/love.app
GAME=$(shell perl -lne 'print $$1 if /title = "(.*)"/' conf.lua)
space :=
space +=
SAFEGAME=$(subst $(space),-,$(GAME))
BUNDLEID=me.delisa.$(SAFEGAME)
TARGET=target
ZIPFILE=$(TARGET)/$(SAFEGAME).love
WINZIPFILE=$(TARGET)/$(SAFEGAME)_win.zip
MACZIPFILE=$(TARGET)/$(SAFEGAME)_mac.zip
$(ZIPFILE): package-zip
$(TARGET)/$(SAFEGAME).exe: $(ZIPFILE)
@cat $(WINLOVE) "$(ZIPFILE)" > $@
$(TARGET)/$(SAFEGAME).app: $(ZIPFILE)
@cp -r $(MACLOVE) $@
@cp $(ZIPFILE) $@/Contents/Resources
@/usr/libexec/PlistBuddy -c "Delete UTExportedTypeDeclarations" $@/Contents/Info.plist
@/usr/libexec/PlistBuddy -c "Set CFBundleName '$(GAME)'" $@/Contents/Info.plist
@/usr/libexec/PlistBuddy -c "Set CFBundleIdentifier $(BUNDLEID)" $@/Contents/Info.plist
$(WINZIPFILE): $(TARGET)/$(SAFEGAME).exe
@cp $(shell dirname $(WINLOVE))/*.dll $(TARGET)
@cd $(TARGET) && zip -9rq "$(shell basename $(WINZIPFILE))" *.dll $(SAFEGAME).exe
$(MACZIPFILE): $(TARGET)/$(SAFEGAME).app
@cd $(TARGET) && zip -9rqy "$(SAFEGAME)_mac.zip" "$(SAFEGAME).app"
# ~ end Packaging
.PHONY: run build add-map add-state add-system help test tiled-run tiled-edit-hooks package
run: build
build: ## Build and run the project
@$(LOVE) .
clean: ## Remove build artifects
@rm -rf $(TARGET)
help: ## Show help text
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
test: ## Lint and run tests
@luacheck game/
package-zip: ## Generate .love game file
@mkdir -p $(TARGET)
@zip -9rq "$(ZIPFILE)" .
# See the guide for more info, etc:
# https://love2d.org/wiki/Game_Distribution#Linux_.2F_OS_X
package-win: $(WINZIPFILE) ## Generate windows executable
package-mac: $(MACZIPFILE) ## Generate mac app
package: package-mac package-win package-zip ## Generate distribution binaries
add-map: ## Create a new map asset
ifeq ($(name),)
@$(error name is not defined. Run with `make add-map name=[value]`)
......
......@@ -124,6 +124,13 @@ Additional documentation is available in the Makefile itself.
|`tiled-run` | Runs the game after exporting the map currently open |
|`tiled-edit-hooks` | Creates and/or opens the trigger script for the object selected in the map |
### Export/Packaging
| Make target | |
|-------------------|------------------------------------------------------|
|`package` | Build game distribution files for mac, windows, and linux |
## Resources
### Planning
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment