|
include config.mk |
|
|
|
MAKEFILE := $(firstword $(MAKEFILE_LIST)) |
|
|
|
MSYS = $(shell uname | grep MSYS) |
|
WSL = $(shell uname -a | grep WSL2) |
|
LINUX = $(shell uname | grep Linux) |
|
DARWIN = $(shell uname | grep Darwin) |
|
|
|
ifneq ($(WSL),) |
|
UE4DIR = $(UE4DIR_WSL) |
|
UE4EDITOR = $(shell wslpath -w $(UE4DIR)/Engine/Binaries/Win64/UnrealEditor-Cmd.exe) |
|
MONO = /mnt/c/Windows/System32/cmd.exe /C |
|
PLATFORM = WIN64 |
|
GIT = git.exe |
|
else ifneq ($(MSYS),) |
|
UE4DIR = $(UE4DIR_MSYS) |
|
UE4EDITOR = $(UE4DIR)\Engine\Binaries\Win64\UnrealEditor-Cmd.exe |
|
MONO = |
|
PLATFORM = WIN64 |
|
GIT = git.exe |
|
else ifneq ($(LINUX),) |
|
UE4DIR = $(UE4DIR_LINUX) |
|
UE4EDITOR = $(UE4DIR)/Engine/Binaries/Linux/UnrealEditor |
|
MONO = $(UE4DIR)/Engine/Binaries/ThirdParty/DotNet/6.0.302/linux/dotnet |
|
PLATFORM = Linux |
|
GIT = git |
|
else # Mac |
|
UE4DIR = $(UE4DIR_MAC) |
|
UE4EDITOR = $(UE4DIR)/Engine/Binaries/Mac/UnrealEditor.app/Contents/MacOS/UnrealEditor |
|
MONO = dotnet |
|
PLATFORM = Mac |
|
GIT = git |
|
endif |
|
|
|
ifneq ($(WSL),) |
|
PWD = $(shell pwd) |
|
PROJECT = $(shell wslpath -w $(PROJECT_DIR)/$(PROJECT_NAME).uproject) |
|
AUTOMATIONTOOL = $(shell wslpath -w $(UE4DIR)/Engine/Binaries/DotNET/AutomationTool/AutomationTool.exe) |
|
ARCHIVE_FULLPATH = $(shell wslpath -w $(PWD)/$(ARCHIVE_DIR)) |
|
else |
|
PROJECT = $(PROJECT_DIR)/$(PROJECT_NAME).uproject |
|
AUTOMATIONTOOL = $(UE4DIR)/Engine/Binaries/DotNET/AutomationTool/AutomationTool.dll |
|
PWD = $(shell pwd) |
|
ARCHIVE_FULLPATH = $(PWD)/$(ARCHIVE_DIR) |
|
endif |
|
|
|
ifneq ($(MAP),) |
|
MAP_ARG = -map=$(MAP) |
|
else |
|
LEVEL_ASSETS = $(shell find $(LEVEL_DIR) -name '*.umap') |
|
LEVELS = $(basename $(notdir $(LEVEL_ASSETS))) |
|
EMPTY := |
|
SPACE := $(EMPTY) $(EMPTY) |
|
LEVELS_JOINED = $(subst $(SPACE),+,$(LEVELS)) |
|
MAP_ARG = -map=$(LEVELS_JOINED) |
|
endif |
|
|
|
VERSION_FILE = CURRENT_VERSION.txt |
|
VERSION = $(shell cat $(VERSION_FILE)) |
|
NEXT_VERSION = $(shell ./node_modules/.bin/semver -i prerelease $(VERSION)) |
|
|
|
BUILD_DIR = Build |
|
BUILD_NAME = $(PROJECT_NAME)_$(PLATFORM)_$(CONFIG)_$(VERSION) |
|
ARCHIVE_DIR = $(BUILD_DIR)/$(BUILD_NAME) |
|
ZIP = $(ARCHIVE_DIR).zip |
|
|
|
.PHONY: build bump zip copy-spine-runtime clean update-proj update-config |
|
|
|
help: |
|
@echo usage: make -f $(MAKEFILE) PROJECT_NAME=MyGame build |
|
@echo usage: make -f $(MAKEFILE) PROJECT_NAME=MyGame zip |
|
|
|
run: |
|
$(UE4EDITOR) $(PROJECT_DIR)/$(PROJECT_NAME).uproject |
|
|
|
bump: |
|
echo $(NEXT_VERSION) > $(VERSION_FILE) |
|
$(GIT) commit -m 'version bumped $(NEXT_VERSION)' $(VERSION_FILE) |
|
$(GIT) tag -m 'version bumped $(NEXT_VERSION)' $(NEXT_VERSION) |
|
$(GIT) push |
|
$(GIT) push --tags |
|
|
|
build: $(BUILD_DIR) build-xcode update-config |
|
$(GIT) submodule update || echo Ignoreing git error... |
|
$(MONO) "$(AUTOMATIONTOOL)" \ |
|
-ScriptsForProject="$(PROJECT)" \ |
|
BuildCookRun \ |
|
-nocompileeditor \ |
|
-nop4 \ |
|
-project="$(PROJECT)" \ |
|
$(MAP_ARG) \ |
|
-cook \ |
|
-stage \ |
|
-archive \ |
|
-archivedirectory="$(ARCHIVE_FULLPATH)" \ |
|
-package \ |
|
-unrealexe="$(UE4EDITOR)" \ |
|
-compressed \ |
|
-ddc=DerivedDataBackendGraph \ |
|
-pak \ |
|
-prereqs \ |
|
-nodebuginfo \ |
|
-targetplatform=$(PLATFORM) \ |
|
-build \ |
|
-target=$(PROJECT_NAME) \ |
|
-clientconfig=$(CONFIG) \ |
|
-utf8output \ |
|
-compile \ |
|
-CookCultures=$(CULTURES) |
|
find $(PWD)/$(ARCHIVE_DIR) -name '*.dSYM' -print -delete |
|
find $(PWD)/$(ARCHIVE_DIR) -name '*.pdb' -print -delete |
|
git restore $(PROJECT_DIR)/Config/DefaultEngine.ini || echo Ignoreing git error... |
|
|
|
update-config: |
|
sed 's/^BuildVersion=.*/BuildVersion=$(BUILD_NAME)\r/' $(PROJECT_DIR)/Config/DefaultEngine.ini > tmp$$$$ && mv tmp$$$$ $(PROJECT_DIR)/Config/DefaultEngine.ini |
|
|
|
build-xcode: |
|
ifneq ($(DARWIN),) |
|
if [ -f $(PROJECT_NAME).xcworkspace ]; then \ |
|
xcodebuild -workspace $(PROJECT_NAME).xcworkspace -scheme $(PROJECT_NAME) ;\ |
|
fi |
|
endif |
|
|
|
zip: $(ZIP) |
|
|
|
$(ARCHIVE_DIR): |
|
$(MAKE) -f $(MAKEFILE) build |
|
|
|
$(BUILD_DIR): |
|
mkdir -p $(BUILD_DIR) |
|
|
|
$(ZIP): $(ARCHIVE_DIR) |
|
zip -r $@ $(ARCHIVE_DIR) |
|
|
|
SPINECPP = Plugins/SpinePlugin/Source/SpinePlugin/Public/spine-cpp |
|
|
|
copy-spine-runtime: clean |
|
$(MAKE) -f $(MAKEFILE) $(SPINECPP) |
|
|
|
clean: |
|
rm -rf Plugins/SpinePlugin |
|
|
|
Plugins/SpinePlugin: |
|
mkdir -p Plugins |
|
cp -R ../../spine-runtimes/spine-ue4/Plugins/SpinePlugin Plugins |
|
|
|
$(SPINECPP): Plugins/SpinePlugin |
|
if [ -d $@ ]; then rm -rf $@; fi |
|
cp -R ../../spine-runtimes/spine-cpp/spine-cpp $@ |
|
|
|
update-proj: |
|
ifneq ($(WSL),) |
|
/mnt/c/Windows/System32/cmd.exe /C \ |
|
$(subst /,\\,$(subst /mnt/e,E:,$(UE4DIR))/Engine/Build/BatchFiles/GenerateProjectFiles.bat) \ |
|
-project $(subst /,\\,$(subst /mnt/e,E:,$(shell pwd)))\\$(PROJECT_NAME).uproject -game -2017 |
|
else ifneq ($(MSYS),) |
|
(UE4DIR)/Engine/Build/BatchFiles/GenerateProjectFiles.bat -project $(PROJECT) -game |
|
else ifneq ($(DARWIN),) |
|
$(UE4DIR)/Engine/Build/BatchFiles/Mac/GenerateProjectFiles.sh -project $(PROJECT) -game |
|
else |
|
$(UE4DIR)/Engine/Build/BatchFiles/Linux/GenerateProjectFiles.sh -project $(PROJECT) -game |
|
endif |
|
|
|
upload-build: $(ZIP) |
|
gdrive files upload --parent $(GDRIVE_BUILD_DIRECTORY_ID) $(ZIP) |