[nostalgia] Get Makefile working on Windows
This commit is contained in:
parent
3430e228c8
commit
ef85eea691
50
Makefile
50
Makefile
@ -1,5 +1,15 @@
|
|||||||
OS=$(shell uname | tr [:upper:] [:lower:])
|
ifeq (${OS},Windows_NT)
|
||||||
HOST_ENV=${OS}-$(shell uname -m)
|
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
|
||||||
|
|
||||||
DEVENV=devenv$(shell pwd | sed 's/\//-/g')
|
DEVENV=devenv$(shell pwd | sed 's/\//-/g')
|
||||||
DEVENV_IMAGE=nostalgia-devenv
|
DEVENV_IMAGE=nostalgia-devenv
|
||||||
ifndef VCPKG_DIR_BASE
|
ifndef VCPKG_DIR_BASE
|
||||||
@ -14,12 +24,6 @@ ifneq ($(shell which docker 2> /dev/null),)
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(OS),windows)
|
|
||||||
RM_RF=Remove-Item -ErrorAction Ignore -Path -Recurse
|
|
||||||
else
|
|
||||||
RM_RF=rm -rf
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(OS),darwin)
|
ifeq ($(OS),darwin)
|
||||||
NOSTALGIA_STUDIO=./dist/${CURRENT_BUILD}/nostalgia-studio.app/Contents/MacOS/nostalgia-studio
|
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
|
NOSTALGIA_STUDIO_PROFILE=dist/${CURRENT_BUILD}/nostalgia-studio.app/Contents/Resources/nostalgia-studio.json
|
||||||
@ -93,36 +97,56 @@ devenv-shell:
|
|||||||
vcpkg: ${VCPKG_DIR} vcpkg-install
|
vcpkg: ${VCPKG_DIR} vcpkg-install
|
||||||
|
|
||||||
${VCPKG_DIR}:
|
${VCPKG_DIR}:
|
||||||
|
ifneq (,$(wildcard ${VCPKG_DIR}))
|
||||||
${ENV_RUN} ${RM_RF} ${VCPKG_DIR}
|
${ENV_RUN} ${RM_RF} ${VCPKG_DIR}
|
||||||
|
endif
|
||||||
${ENV_RUN} mkdir -p ${VCPKG_DIR_BASE}
|
${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}
|
${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
|
${ENV_RUN} ${VCPKG_DIR}/bootstrap-vcpkg.sh
|
||||||
|
else
|
||||||
|
${ENV_RUN} ${VCPKG_DIR}/bootstrap-vcpkg.bat
|
||||||
|
endif
|
||||||
|
|
||||||
.PHONY: vcpkg-install
|
.PHONY: vcpkg-install
|
||||||
vcpkg-install:
|
vcpkg-install:
|
||||||
|
ifneq (${OS},windows)
|
||||||
${VCPKG_DIR}/vcpkg install sdl2 jsoncpp
|
${VCPKG_DIR}/vcpkg install sdl2 jsoncpp
|
||||||
|
else
|
||||||
|
${VCPKG_DIR}/vcpkg install --triplet x64-windows sdl2 jsoncpp
|
||||||
|
endif
|
||||||
|
|
||||||
.PHONY: configure-release
|
.PHONY: configure-release
|
||||||
configure-release:
|
configure-release:
|
||||||
|
ifneq (,$(wildcard build/${HOST_ENV}-release))
|
||||||
${ENV_RUN} ${RM_RF} build/${HOST_ENV}-release
|
${ENV_RUN} ${RM_RF} build/${HOST_ENV}-release
|
||||||
${ENV_RUN} ./scripts/setup-build ${HOST_ENV} release ${VCPKG_DIR}
|
endif
|
||||||
|
${ENV_RUN} python ./scripts/setup-build.py ${HOST_ENV} release ${VCPKG_DIR}
|
||||||
|
|
||||||
.PHONY: configure-debug
|
.PHONY: configure-debug
|
||||||
configure-debug:
|
configure-debug:
|
||||||
|
ifneq (,$(wildcard build/${HOST_ENV}-debug))
|
||||||
${ENV_RUN} ${RM_RF} build/${HOST_ENV}-debug
|
${ENV_RUN} ${RM_RF} build/${HOST_ENV}-debug
|
||||||
${ENV_RUN} ./scripts/setup-build ${HOST_ENV} debug ${VCPKG_DIR}
|
endif
|
||||||
|
${ENV_RUN} python ./scripts/setup-build.py ${HOST_ENV} debug ${VCPKG_DIR}
|
||||||
|
|
||||||
.PHONY: configure-asan
|
.PHONY: configure-asan
|
||||||
configure-asan:
|
configure-asan:
|
||||||
|
ifneq (,$(wildcard build/${HOST_ENV}-asan))
|
||||||
${ENV_RUN} ${RM_RF} build/${HOST_ENV}-asan
|
${ENV_RUN} ${RM_RF} build/${HOST_ENV}-asan
|
||||||
${ENV_RUN} ./scripts/setup-build ${HOST_ENV} asan ${VCPKG_DIR}
|
endif
|
||||||
|
${ENV_RUN} python ./scripts/setup-build.py ${HOST_ENV} asan ${VCPKG_DIR}
|
||||||
|
|
||||||
.PHONY: configure-gba
|
.PHONY: configure-gba
|
||||||
configure-gba:
|
configure-gba:
|
||||||
|
ifneq (,$(wildcard build/gba-release))
|
||||||
${ENV_RUN} ${RM_RF} build/gba-release
|
${ENV_RUN} ${RM_RF} build/gba-release
|
||||||
${ENV_RUN} ./scripts/setup-build gba release ${VCPKG_DIR}
|
endif
|
||||||
|
${ENV_RUN} python ./scripts/setup-build.py gba release ${VCPKG_DIR}
|
||||||
|
|
||||||
.PHONY: configure-gba-debug
|
.PHONY: configure-gba-debug
|
||||||
configure-gba-debug:
|
configure-gba-debug:
|
||||||
|
ifneq (,$(wildcard build/gba-debug))
|
||||||
${ENV_RUN} ${RM_RF} build/gba-debug
|
${ENV_RUN} ${RM_RF} build/gba-debug
|
||||||
${ENV_RUN} ./scripts/setup-build gba debug ${VCPKG_DIR}
|
endif
|
||||||
|
${ENV_RUN} python ./scripts/setup-build.py gba debug ${VCPKG_DIR}
|
||||||
|
74
scripts/setup-build.py
Normal file
74
scripts/setup-build.py
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
#! /usr/bin/env python3
|
||||||
|
|
||||||
|
import os
|
||||||
|
import platform
|
||||||
|
import shutil
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
|
target = sys.argv[1]
|
||||||
|
build_type = sys.argv[2]
|
||||||
|
vcpkg_dir = sys.argv[3]
|
||||||
|
|
||||||
|
project = os.getcwd()
|
||||||
|
|
||||||
|
def mkdir(path):
|
||||||
|
if not os.path.exists(path) and os.path.isdir(path):
|
||||||
|
os.mkdir(path)
|
||||||
|
|
||||||
|
def rm(path):
|
||||||
|
if os.path.exists(path) or os.path.islink(path):
|
||||||
|
os.remove(path)
|
||||||
|
|
||||||
|
if target == 'gba':
|
||||||
|
toolchain = '-DCMAKE_TOOLCHAIN_FILE=cmake/modules/GBA.cmake'
|
||||||
|
nostalgia_build_type = 'GBA'
|
||||||
|
else:
|
||||||
|
toolchain = '-DCMAKE_TOOLCHAIN_FILE={:s}/scripts/buildsystems/vcpkg.cmake'.format(vcpkg_dir)
|
||||||
|
nostalgia_build_type = 'Native'
|
||||||
|
|
||||||
|
if build_type == 'asan':
|
||||||
|
build_type_arg = 'Debug'
|
||||||
|
sanitizer_status = 'ON'
|
||||||
|
elif build_type == 'debug':
|
||||||
|
build_type_arg = 'Debug'
|
||||||
|
sanitizer_status = 'OFF'
|
||||||
|
elif build_type == 'release':
|
||||||
|
build_type_arg = 'Release'
|
||||||
|
sanitizer_status = 'OFF'
|
||||||
|
|
||||||
|
|
||||||
|
build_config = '{:s}-{:s}'.format(target, build_type)
|
||||||
|
|
||||||
|
if 'NOSTALGIA_QT_PATH' in os.environ:
|
||||||
|
qt_path = '-DNOSTALGIA_QT_PATH={:s}'.format(os.environ['NOSTALGIA_QT_PATH'])
|
||||||
|
else:
|
||||||
|
qt_path = ''
|
||||||
|
|
||||||
|
if shutil.which('ninja') == None:
|
||||||
|
build_tool = ''
|
||||||
|
else:
|
||||||
|
build_tool = '-GNinja'
|
||||||
|
|
||||||
|
build_dir = '{:s}/build/{:s}'.format(project, build_config)
|
||||||
|
mkdir(build_dir)
|
||||||
|
subprocess.run(['cmake', '-S', project, '-B', build_dir, build_tool,
|
||||||
|
'-DCMAKE_EXPORT_COMPILE_COMMANDS=ON',
|
||||||
|
'-DCMAKE_BUILD_TYPE={:s}'.format(build_type_arg),
|
||||||
|
'-DUSE_ASAN={:s}'.format(sanitizer_status),
|
||||||
|
'-DNOSTALGIA_IDE_BUILD=OFF',
|
||||||
|
'-DNOSTALGIA_BUILD_CONFIG={:s}'.format(build_config),
|
||||||
|
'-DNOSTALGIA_BUILD_TYPE={:s}'.format(nostalgia_build_type),
|
||||||
|
qt_path,
|
||||||
|
toolchain,
|
||||||
|
])
|
||||||
|
|
||||||
|
mkdir('dist')
|
||||||
|
if target != 'gba':
|
||||||
|
cb = open('.current_build', 'w')
|
||||||
|
cb.write(build_type)
|
||||||
|
cb.close()
|
||||||
|
|
||||||
|
rm('compile_commands.json')
|
||||||
|
if platform.system() != 'Windows':
|
||||||
|
os.symlink('build/{:s}/compile_commands.json'.format(build_config), 'compile_commands.json')
|
Loading…
Reference in New Issue
Block a user