nostalgia/Makefile

142 lines
3.6 KiB
Makefile
Raw Normal View History

ifeq (${OS},Windows_NT)
SHELL := powershell.exe
.SHELLFLAGS := -NoProfile -Command
OS=windows
HOST_ENV=${OS}
else
OS=$(shell uname | tr [:upper:] [:lower:])
HOST_ENV=${OS}-$(shell uname -m)
endif
DEVENV=devenv$(shell pwd | sed 's/\//-/g')
DEVENV_IMAGE=nostalgia-devenv
SETUP_BUILD=python3 ./scripts/setup-build.py
PYBB=python3 scripts/pybb.py
CMAKE_BUILD=${PYBB} cmake-build
RM_RF=${PYBB} rm
ifndef VCPKG_DIR_BASE
VCPKG_DIR_BASE=.vcpkg
endif
VCPKG_VERSION=2020.06
VCPKG_DIR=$(VCPKG_DIR_BASE)/$(VCPKG_VERSION)-$(HOST_ENV)
CURRENT_BUILD=$(HOST_ENV)-$(file < .current_build)
2018-03-05 23:09:50 -06:00
ifneq ($(shell which docker 2> /dev/null),)
ifeq ($(shell docker inspect --format="{{.State.Status}}" ${DEVENV} 2>&1),running)
2017-04-10 17:45:32 -05:00
ENV_RUN=docker exec -i -t --user $(shell id -u ${USER}) ${DEVENV}
endif
endif
2016-12-18 15:54:13 -06:00
2019-11-13 20:37:23 -06:00
ifeq ($(OS),darwin)
NOSTALGIA_STUDIO=./dist/${CURRENT_BUILD}/nostalgia-studio.app/Contents/MacOS/nostalgia-studio
2019-12-30 22:51:35 -06:00
MGBA=/Applications/mGBA.app/Contents/MacOS/mGBA
2019-11-13 20:37:23 -06:00
else
NOSTALGIA_STUDIO=./dist/${CURRENT_BUILD}/bin/nostalgia-studio
2019-12-30 22:51:35 -06:00
MGBA=mgba-qt
2019-11-13 20:37:23 -06:00
endif
.PHONY: build
build:
${ENV_RUN} ${CMAKE_BUILD} build
.PHONY: pkg-gba
pkg-gba:
${ENV_RUN} ${CMAKE_BUILD} build install
2020-06-20 05:27:03 -05:00
${ENV_RUN} ./scripts/pkg-gba sample_project
.PHONY: install
2016-03-26 15:49:05 -05:00
install:
${ENV_RUN} ${CMAKE_BUILD} build install
.PHONY: clean
2016-03-26 15:49:05 -05:00
clean:
${ENV_RUN} ${CMAKE_BUILD} build clean
.PHONY: purge
2016-12-23 17:29:19 -06:00
purge:
${ENV_RUN} ${RM_RF} .current_build
${ENV_RUN} ${RM_RF} build
${ENV_RUN} ${RM_RF} dist
.PHONY: test
test: build
${ENV_RUN} ${CMAKE_BUILD} build test
2016-12-23 18:06:27 -06:00
.PHONY: run
2017-05-16 13:53:57 -05:00
run: install
${ENV_RUN} ./dist/${CURRENT_BUILD}/bin/nostalgia sample_project
.PHONY: run-studio
2017-05-16 13:53:57 -05:00
run-studio: install
${ENV_RUN} ${NOSTALGIA_STUDIO}
.PHONY: gba-run
gba-run: pkg-gba
2019-12-30 22:51:35 -06:00
${MGBA} nostalgia.gba
.PHONY: gdb
gdb: install
${ENV_RUN} gdb --args ./dist/${CURRENT_BUILD}/bin/nostalgia sample_project
.PHONY: gdb-studio
2018-01-28 00:26:50 -06:00
gdb-studio: install
${ENV_RUN} gdb --args ${NOSTALGIA_STUDIO}
2016-12-23 18:06:27 -06:00
.PHONY: devenv-image
2017-10-14 19:38:10 -05:00
devenv-image:
2017-04-21 06:12:17 -05:00
docker build . -t ${DEVENV_IMAGE}
.PHONY: devenv-create
devenv-create:
docker run -d \
-e LOCAL_USER_ID=$(shell id -u ${USER}) \
2017-04-04 19:21:29 -05:00
-e DISPLAY=$(DISPLAY) \
-e QT_AUTO_SCREEN_SCALE_FACTOR=1 \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v /run/dbus/:/run/dbus/ \
-v $(shell pwd):/usr/src/project \
2017-04-04 19:21:29 -05:00
-v /dev/shm:/dev/shm \
--restart=always \
--name ${DEVENV} \
2016-12-24 00:41:57 -06:00
-t ${DEVENV_IMAGE} bash
.PHONY: devenv-destroy
2016-12-18 15:54:13 -06:00
devenv-destroy:
docker rm -f ${DEVENV}
.PHONY: devenv-shell
devenv-shell:
2017-04-10 17:45:32 -05:00
${ENV_RUN} bash
2020-08-05 20:17:53 -05:00
.PHONY: vcpkg
vcpkg: ${VCPKG_DIR} vcpkg-install
${VCPKG_DIR}:
${ENV_RUN} ${RM_RF} ${VCPKG_DIR}
${ENV_RUN} mkdir -p ${VCPKG_DIR_BASE}
${ENV_RUN} git clone -b release --depth 1 --branch ${VCPKG_VERSION} https://github.com/microsoft/vcpkg.git ${VCPKG_DIR}
ifneq (${OS},windows)
${ENV_RUN} ${VCPKG_DIR}/bootstrap-vcpkg.sh
else
${ENV_RUN} ${VCPKG_DIR}/bootstrap-vcpkg.bat
endif
.PHONY: vcpkg-install
vcpkg-install:
ifneq (${OS},windows)
2020-08-05 20:17:53 -05:00
${VCPKG_DIR}/vcpkg install sdl2 jsoncpp
else
${VCPKG_DIR}/vcpkg install --triplet x64-windows sdl2 jsoncpp
endif
.PHONY: configure-xcode
configure-xcode:
${ENV_RUN} ${SETUP_BUILD} --vcpkg_dir ${VCPKG_DIR} --build_tool xcode
.PHONY: configure-release
configure-release:
${ENV_RUN} ${SETUP_BUILD} --vcpkg_dir ${VCPKG_DIR} --build_type release
2016-03-26 15:49:05 -05:00
.PHONY: configure-debug
configure-debug:
${ENV_RUN} ${SETUP_BUILD} --vcpkg_dir ${VCPKG_DIR} --build_type debug
2016-12-23 17:29:19 -06:00
.PHONY: configure-asan
configure-asan:
${ENV_RUN} ${SETUP_BUILD} --vcpkg_dir ${VCPKG_DIR} --build_type asan
2017-12-20 22:41:14 -06:00
.PHONY: configure-gba
configure-gba:
${ENV_RUN} ${SETUP_BUILD} --target gba --build_type release
2016-12-24 13:06:44 -06:00
.PHONY: configure-gba-debug
configure-gba-debug:
${ENV_RUN} ${SETUP_BUILD} --target gba --build_type debug