[nostalgia] Cleanup build scripts and add support for configuring Xcode project
This commit is contained in:
parent
b3aa0eb59d
commit
d50551cc74
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,6 +1,7 @@
|
||||
.clangd
|
||||
.current_build
|
||||
.vcpkg
|
||||
scripts/__pycache__
|
||||
compile_commands.json
|
||||
build
|
||||
conanbuild
|
||||
|
34
Makefile
34
Makefile
@ -10,7 +10,8 @@ endif
|
||||
|
||||
DEVENV=devenv$(shell pwd | sed 's/\//-/g')
|
||||
DEVENV_IMAGE=nostalgia-devenv
|
||||
PYBB=python3 scripts/pybb
|
||||
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
|
||||
@ -98,9 +99,7 @@ devenv-shell:
|
||||
vcpkg: ${VCPKG_DIR} vcpkg-install
|
||||
|
||||
${VCPKG_DIR}:
|
||||
ifneq (,$(wildcard ${VCPKG_DIR}))
|
||||
${ENV_RUN} ${RM_RF} ${VCPKG_DIR}
|
||||
endif
|
||||
${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)
|
||||
@ -117,37 +116,26 @@ 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:
|
||||
ifneq (,$(wildcard build/${HOST_ENV}-release))
|
||||
${ENV_RUN} ${RM_RF} build/${HOST_ENV}-release
|
||||
endif
|
||||
${ENV_RUN} python3 ./scripts/setup-build.py ${HOST_ENV} release ${VCPKG_DIR}
|
||||
${ENV_RUN} ${SETUP_BUILD} --vcpkg_dir ${VCPKG_DIR} --build_type release
|
||||
|
||||
.PHONY: configure-debug
|
||||
configure-debug:
|
||||
ifneq (,$(wildcard build/${HOST_ENV}-debug))
|
||||
${ENV_RUN} ${RM_RF} build/${HOST_ENV}-debug
|
||||
endif
|
||||
${ENV_RUN} python3 ./scripts/setup-build.py ${HOST_ENV} debug ${VCPKG_DIR}
|
||||
${ENV_RUN} ${SETUP_BUILD} --vcpkg_dir ${VCPKG_DIR} --build_type debug
|
||||
|
||||
.PHONY: configure-asan
|
||||
configure-asan:
|
||||
ifneq (,$(wildcard build/${HOST_ENV}-asan))
|
||||
${ENV_RUN} ${RM_RF} build/${HOST_ENV}-asan
|
||||
endif
|
||||
${ENV_RUN} python3 ./scripts/setup-build.py ${HOST_ENV} asan ${VCPKG_DIR}
|
||||
${ENV_RUN} ${SETUP_BUILD} --vcpkg_dir ${VCPKG_DIR} --build_type asan
|
||||
|
||||
.PHONY: configure-gba
|
||||
configure-gba:
|
||||
ifneq (,$(wildcard build/gba-release))
|
||||
${ENV_RUN} ${RM_RF} build/gba-release
|
||||
endif
|
||||
${ENV_RUN} python3 ./scripts/setup-build.py gba release ${VCPKG_DIR}
|
||||
${ENV_RUN} ${SETUP_BUILD} --target gba --build_type release
|
||||
|
||||
.PHONY: configure-gba-debug
|
||||
configure-gba-debug:
|
||||
ifneq (,$(wildcard build/gba-debug))
|
||||
${ENV_RUN} ${RM_RF} build/gba-debug
|
||||
endif
|
||||
${ENV_RUN} python3 ./scripts/setup-build.py gba debug ${VCPKG_DIR}
|
||||
${ENV_RUN} ${SETUP_BUILD} --target gba --build_type debug
|
||||
|
@ -1,74 +1,85 @@
|
||||
#! /usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import platform
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
target = sys.argv[1]
|
||||
build_type = sys.argv[2]
|
||||
vcpkg_dir = sys.argv[3]
|
||||
from pybb import mkdir, rm
|
||||
|
||||
project = os.getcwd()
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--target', help='Platform target ({OS}-{Arch},gba)', default='{:s}-{:s}'.format(sys.platform, platform.machine()))
|
||||
parser.add_argument('--build_type', help='Build type (asan,debug,release)', default='release')
|
||||
parser.add_argument('--build_tool', help='Build tool (default,xcode)', default='')
|
||||
parser.add_argument('--vcpkg_dir', help='Path to VCPKG')
|
||||
args = parser.parse_args()
|
||||
|
||||
def mkdir(path):
|
||||
if not os.path.exists(path) and os.path.isdir(path):
|
||||
os.mkdir(path)
|
||||
if args.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(args.vcpkg_dir)
|
||||
nostalgia_build_type = 'Native'
|
||||
|
||||
def rm(path):
|
||||
if os.path.exists(path) or os.path.islink(path):
|
||||
os.remove(path)
|
||||
if args.build_type == 'asan':
|
||||
build_type_arg = 'Debug'
|
||||
sanitizer_status = 'ON'
|
||||
elif args.build_type == 'debug':
|
||||
build_type_arg = 'Debug'
|
||||
sanitizer_status = 'OFF'
|
||||
elif args.build_type == 'release':
|
||||
build_type_arg = 'Release'
|
||||
sanitizer_status = 'OFF'
|
||||
|
||||
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 args.build_tool == 'xcode':
|
||||
build_config = '{:s}-{:s}'.format(args.target, args.build_tool)
|
||||
else:
|
||||
build_config = '{:s}-{:s}'.format(args.target, args.build_type)
|
||||
|
||||
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'
|
||||
if 'NOSTALGIA_QT_PATH' in os.environ:
|
||||
qt_path = '-DNOSTALGIA_QT_PATH={:s}'.format(os.environ['NOSTALGIA_QT_PATH'])
|
||||
else:
|
||||
qt_path = ''
|
||||
|
||||
if args.build_tool == '' or args.build_tool == 'default':
|
||||
if shutil.which('ninja') == None:
|
||||
build_tool = ''
|
||||
else:
|
||||
build_tool = '-GNinja'
|
||||
elif args.build_tool == 'xcode':
|
||||
build_tool = '-GXcode'
|
||||
|
||||
build_config = '{:s}-{:s}'.format(target, build_type)
|
||||
project_dir = os.getcwd()
|
||||
build_dir = '{:s}/build/{:s}'.format(project_dir, build_config)
|
||||
rm(build_dir)
|
||||
mkdir(build_dir)
|
||||
subprocess.run(['cmake', '-S', project_dir, '-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,
|
||||
])
|
||||
|
||||
if 'NOSTALGIA_QT_PATH' in os.environ:
|
||||
qt_path = '-DNOSTALGIA_QT_PATH={:s}'.format(os.environ['NOSTALGIA_QT_PATH'])
|
||||
else:
|
||||
qt_path = ''
|
||||
mkdir('dist')
|
||||
if args.target != 'gba':
|
||||
cb = open('.current_build', 'w')
|
||||
cb.write(args.build_type)
|
||||
cb.close()
|
||||
|
||||
if shutil.which('ninja') == None:
|
||||
build_tool = ''
|
||||
else:
|
||||
build_tool = '-GNinja'
|
||||
rm('compile_commands.json')
|
||||
if platform.system() != 'Windows':
|
||||
os.symlink('build/{:s}/compile_commands.json'.format(build_config), 'compile_commands.json')
|
||||
|
||||
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,
|
||||
])
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
main()
|
||||
except KeyboardInterrupt:
|
||||
sys.exit(1)
|
||||
|
||||
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