2020-11-07 17:38:41 -06:00
|
|
|
ifeq (${OS},Windows_NT)
|
|
|
|
SHELL := powershell.exe
|
|
|
|
.SHELLFLAGS := -NoProfile -Command
|
|
|
|
OS=windows
|
|
|
|
HOST_ENV=${OS}
|
|
|
|
RM_RF=Remove-Item -ErrorAction Ignore -Recurse -Path
|
|
|
|
else
|
|
|
|
OS=$(shell uname | tr [:upper:] [:lower:])
|
|
|
|
HOST_ENV=${OS}-$(shell uname -m)
|
|
|
|
RM_RF=rm -rf
|
|
|
|
endif
|
|
|
|
|
2016-12-22 13:16:05 -06:00
|
|
|
DEVENV=devenv$(shell pwd | sed 's/\//-/g')
|
2017-04-14 04:08:13 -05:00
|
|
|
DEVENV_IMAGE=nostalgia-devenv
|
2020-08-15 20:24:38 -05:00
|
|
|
ifndef VCPKG_DIR_BASE
|
|
|
|
VCPKG_DIR_BASE=.vcpkg
|
|
|
|
endif
|
|
|
|
VCPKG_VERSION=2020.06
|
|
|
|
VCPKG_DIR=$(VCPKG_DIR_BASE)/$(VCPKG_VERSION)-$(HOST_ENV)
|
2020-08-14 20:47:30 -05:00
|
|
|
CURRENT_BUILD=$(HOST_ENV)-$(file < .current_build)
|
2018-03-05 23:09:50 -06:00
|
|
|
ifneq ($(shell which docker 2> /dev/null),)
|
2017-04-09 03:16:20 -05:00
|
|
|
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}
|
2017-04-09 03:16:20 -05:00
|
|
|
endif
|
2016-12-22 20:28:48 -06:00
|
|
|
endif
|
2016-12-18 15:54:13 -06:00
|
|
|
|
2019-11-13 20:37:23 -06:00
|
|
|
ifeq ($(OS),darwin)
|
2020-01-09 18:30:35 -06:00
|
|
|
NOSTALGIA_STUDIO=./dist/${CURRENT_BUILD}/nostalgia-studio.app/Contents/MacOS/nostalgia-studio
|
|
|
|
NOSTALGIA_STUDIO_PROFILE=dist/${CURRENT_BUILD}/nostalgia-studio.app/Contents/Resources/nostalgia-studio.json
|
2019-12-30 22:51:35 -06:00
|
|
|
MGBA=/Applications/mGBA.app/Contents/MacOS/mGBA
|
2019-11-13 20:37:23 -06:00
|
|
|
else
|
2020-01-09 18:30:35 -06:00
|
|
|
NOSTALGIA_STUDIO=./dist/${CURRENT_BUILD}/bin/nostalgia-studio
|
|
|
|
NOSTALGIA_STUDIO_PROFILE=dist/${CURRENT_BUILD}/share/nostalgia-studio.json
|
2019-12-30 22:51:35 -06:00
|
|
|
MGBA=mgba-qt
|
2019-11-13 20:37:23 -06:00
|
|
|
endif
|
|
|
|
|
2020-01-03 20:00:58 -06:00
|
|
|
.PHONY: build
|
|
|
|
build:
|
2020-08-28 18:58:03 -05:00
|
|
|
$(foreach file, $(wildcard build/*), ${ENV_RUN} cmake --build $(file) --target;)
|
2020-01-03 20:00:58 -06:00
|
|
|
.PHONY: pkg-gba
|
2019-02-27 23:23:10 -06:00
|
|
|
pkg-gba:
|
2020-08-28 18:58:03 -05:00
|
|
|
$(foreach file, $(wildcard build/*), ${ENV_RUN} cmake --build $(file) --target install;)
|
2020-06-20 05:27:03 -05:00
|
|
|
${ENV_RUN} ./scripts/pkg-gba sample_project
|
2020-01-03 20:00:58 -06:00
|
|
|
.PHONY: install
|
2016-03-26 15:49:05 -05:00
|
|
|
install:
|
2020-08-28 18:58:03 -05:00
|
|
|
$(foreach file, $(wildcard build/*), ${ENV_RUN} cmake --build $(file) --target install;)
|
2020-01-03 20:00:58 -06:00
|
|
|
.PHONY: clean
|
2016-03-26 15:49:05 -05:00
|
|
|
clean:
|
2020-08-28 18:58:03 -05:00
|
|
|
$(foreach file, $(wildcard build/*), ${ENV_RUN} cmake --build $(file) --target clean;)
|
2020-01-03 20:00:58 -06:00
|
|
|
.PHONY: purge
|
2016-12-23 17:29:19 -06:00
|
|
|
purge:
|
2020-06-15 23:40:52 -05:00
|
|
|
${ENV_RUN} ${RM_RF} build .current_build dist
|
2020-01-03 20:00:58 -06:00
|
|
|
.PHONY: test
|
2020-05-04 18:21:48 -05:00
|
|
|
test: build
|
2020-08-28 18:58:03 -05:00
|
|
|
$(foreach file, $(wildcard build/*), ${ENV_RUN} cmake --build $(file) --target test;)
|
2016-12-23 18:06:27 -06:00
|
|
|
|
2020-01-03 20:00:58 -06:00
|
|
|
.PHONY: run
|
2017-05-16 13:53:57 -05:00
|
|
|
run: install
|
2020-01-09 18:30:35 -06:00
|
|
|
${ENV_RUN} ./dist/${CURRENT_BUILD}/bin/nostalgia sample_project
|
2020-01-03 20:00:58 -06:00
|
|
|
.PHONY: run-studio
|
2017-05-16 13:53:57 -05:00
|
|
|
run-studio: install
|
2019-11-13 20:37:23 -06:00
|
|
|
${ENV_RUN} ${NOSTALGIA_STUDIO} -profile ${NOSTALGIA_STUDIO_PROFILE}
|
2020-01-03 20:00:58 -06:00
|
|
|
.PHONY: gba-run
|
2019-02-27 23:23:10 -06:00
|
|
|
gba-run: pkg-gba
|
2019-12-30 22:51:35 -06:00
|
|
|
${MGBA} nostalgia.gba
|
2020-01-03 20:00:58 -06:00
|
|
|
.PHONY: gdb
|
2019-11-03 23:31:47 -06:00
|
|
|
gdb: install
|
2020-01-09 18:30:35 -06:00
|
|
|
${ENV_RUN} gdb --args ./dist/${CURRENT_BUILD}/bin/nostalgia sample_project
|
2020-01-03 20:00:58 -06:00
|
|
|
.PHONY: gdb-studio
|
2018-01-28 00:26:50 -06:00
|
|
|
gdb-studio: install
|
2019-12-30 22:51:35 -06:00
|
|
|
${ENV_RUN} gdb --args ${NOSTALGIA_STUDIO} -profile ${NOSTALGIA_STUDIO_PROFILE}
|
2016-12-23 18:06:27 -06:00
|
|
|
|
2020-01-03 20:00:58 -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}
|
2020-01-03 20:00:58 -06:00
|
|
|
.PHONY: devenv-create
|
2018-04-13 19:24:45 -05:00
|
|
|
devenv-create:
|
2017-04-18 17:49:35 -05:00
|
|
|
docker run -d \
|
2016-12-22 20:28:48 -06:00
|
|
|
-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/ \
|
2017-04-18 17:49:35 -05:00
|
|
|
-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
|
2020-01-03 20:00:58 -06:00
|
|
|
.PHONY: devenv-destroy
|
2016-12-18 15:54:13 -06:00
|
|
|
devenv-destroy:
|
|
|
|
docker rm -f ${DEVENV}
|
2020-01-03 20:00:58 -06:00
|
|
|
.PHONY: devenv-shell
|
2019-02-27 23:23:10 -06:00
|
|
|
devenv-shell:
|
2017-04-10 17:45:32 -05:00
|
|
|
${ENV_RUN} bash
|
|
|
|
|
2020-08-05 20:17:53 -05:00
|
|
|
.PHONY: vcpkg
|
2020-08-15 20:24:38 -05:00
|
|
|
vcpkg: ${VCPKG_DIR} vcpkg-install
|
|
|
|
|
|
|
|
${VCPKG_DIR}:
|
2020-11-07 17:38:41 -06:00
|
|
|
ifneq (,$(wildcard ${VCPKG_DIR}))
|
2020-08-28 18:58:03 -05:00
|
|
|
${ENV_RUN} ${RM_RF} ${VCPKG_DIR}
|
2020-11-07 17:38:41 -06:00
|
|
|
endif
|
2020-08-28 18:58:03 -05:00
|
|
|
${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}
|
2020-11-07 17:38:41 -06:00
|
|
|
ifneq (${OS},windows)
|
2020-08-28 18:58:03 -05:00
|
|
|
${ENV_RUN} ${VCPKG_DIR}/bootstrap-vcpkg.sh
|
2020-11-07 17:38:41 -06:00
|
|
|
else
|
|
|
|
${ENV_RUN} ${VCPKG_DIR}/bootstrap-vcpkg.bat
|
|
|
|
endif
|
2020-08-15 20:24:38 -05:00
|
|
|
|
|
|
|
.PHONY: vcpkg-install
|
|
|
|
vcpkg-install:
|
2020-11-07 17:38:41 -06:00
|
|
|
ifneq (${OS},windows)
|
2020-08-05 20:17:53 -05:00
|
|
|
${VCPKG_DIR}/vcpkg install sdl2 jsoncpp
|
2020-11-07 17:38:41 -06:00
|
|
|
else
|
|
|
|
${VCPKG_DIR}/vcpkg install --triplet x64-windows sdl2 jsoncpp
|
|
|
|
endif
|
2019-12-31 17:42:48 -06:00
|
|
|
|
2020-01-03 20:00:58 -06:00
|
|
|
.PHONY: configure-release
|
2019-03-07 18:04:25 -06:00
|
|
|
configure-release:
|
2020-11-07 17:38:41 -06:00
|
|
|
ifneq (,$(wildcard build/${HOST_ENV}-release))
|
2020-01-14 20:38:26 -06:00
|
|
|
${ENV_RUN} ${RM_RF} build/${HOST_ENV}-release
|
2020-11-07 17:38:41 -06:00
|
|
|
endif
|
|
|
|
${ENV_RUN} python ./scripts/setup-build.py ${HOST_ENV} release ${VCPKG_DIR}
|
2016-03-26 15:49:05 -05:00
|
|
|
|
2020-01-03 20:00:58 -06:00
|
|
|
.PHONY: configure-debug
|
2019-03-07 18:04:25 -06:00
|
|
|
configure-debug:
|
2020-11-07 17:38:41 -06:00
|
|
|
ifneq (,$(wildcard build/${HOST_ENV}-debug))
|
2020-01-14 20:38:26 -06:00
|
|
|
${ENV_RUN} ${RM_RF} build/${HOST_ENV}-debug
|
2020-11-07 17:38:41 -06:00
|
|
|
endif
|
|
|
|
${ENV_RUN} python ./scripts/setup-build.py ${HOST_ENV} debug ${VCPKG_DIR}
|
2016-12-23 17:29:19 -06:00
|
|
|
|
2020-01-03 20:00:58 -06:00
|
|
|
.PHONY: configure-asan
|
2019-03-07 18:04:25 -06:00
|
|
|
configure-asan:
|
2020-11-07 17:38:41 -06:00
|
|
|
ifneq (,$(wildcard build/${HOST_ENV}-asan))
|
2020-01-14 20:38:26 -06:00
|
|
|
${ENV_RUN} ${RM_RF} build/${HOST_ENV}-asan
|
2020-11-07 17:38:41 -06:00
|
|
|
endif
|
|
|
|
${ENV_RUN} python ./scripts/setup-build.py ${HOST_ENV} asan ${VCPKG_DIR}
|
2017-12-20 22:41:14 -06:00
|
|
|
|
2020-01-03 20:00:58 -06:00
|
|
|
.PHONY: configure-gba
|
2019-03-07 18:04:25 -06:00
|
|
|
configure-gba:
|
2020-11-07 17:38:41 -06:00
|
|
|
ifneq (,$(wildcard build/gba-release))
|
2020-01-14 20:38:26 -06:00
|
|
|
${ENV_RUN} ${RM_RF} build/gba-release
|
2020-11-07 17:38:41 -06:00
|
|
|
endif
|
|
|
|
${ENV_RUN} python ./scripts/setup-build.py gba release ${VCPKG_DIR}
|
2016-12-24 13:06:44 -06:00
|
|
|
|
2020-01-03 20:00:58 -06:00
|
|
|
.PHONY: configure-gba-debug
|
2019-03-07 18:04:25 -06:00
|
|
|
configure-gba-debug:
|
2020-11-07 17:38:41 -06:00
|
|
|
ifneq (,$(wildcard build/gba-debug))
|
2020-01-14 20:38:26 -06:00
|
|
|
${ENV_RUN} ${RM_RF} build/gba-debug
|
2020-11-07 17:38:41 -06:00
|
|
|
endif
|
|
|
|
${ENV_RUN} python ./scripts/setup-build.py gba debug ${VCPKG_DIR}
|