jasper/deps/buildcore/scripts/setup-build.py
Gary Talent 9caa925f20 Squashed 'deps/nostalgia/' changes from e7a66390..a0c81463
a0c81463 [nostalgia/core/studio] East const some function args
d5b232f5 [olympic/studio] Fix array bounds issue
c79fe3be [buildcore] Make CMake configure failure trigger failed return code
1df4e780 [olympic/studio] Add new project menu, make file creation open file
ffbdb09c [olympic/turbine/glfw] Add shift key support
b35a956e [olympic/studio] Cleanup unused expression
d3847caa [olympic/studio] Make Project::writeObj only write descriptor if it does not already exist or if debug build
ae066a91 [olympic/studio] Fix Project::writeObj to ensure parent directory of file exists
67543af8 [ox/oc] Remove some unnecessary code
6b774ec2 [ox/oc] Fix array writing to write all values
4b9758f4 [nostalgia/core] Move most TileSheet member functions out of class
bf12b15f [nostalgia/sample_project] Update some tilesheets to version 4 format
a7328eb5 [nostalgia/core/studio] Reduce indent for Subsheet editor
b52124a0 [nostalgia/core/studio] Revert new subsheet index increment to happen after index assignment
eae9972f [nostalgia/sample_project] Add missing type descriptors
d83e3929 [nostalgia/core] Cleanup, revert CompactTileSheet version to 1
e2d0a784 [olympic/keel] Cleanup
f0882142 [nostalgia/core/studio] Change TileSheets to back to MC
6a2954f8 [nostalgia/core] Remove id from TileSheetV3::Subsheet, add TileSheetV4
9c19655c [nostalgia/core] Fix build, add SubSheet ID to SubSheet Editor view
087c834b [nostalgia/core/studio] Fix Add SubSheet to increment idIt before using it
79bdbf2e [nostalgia/core] Add id to TileSheetV3::SubSheet model
2bdc3def [nostalgia/core/opengl] Implement flip X and flip Y for BG tiles

git-subtree-dir: deps/nostalgia
git-subtree-split: a0c8146396a9e9c0dc48a2564f4e9870a212ed59
2023-12-29 00:37:47 -06:00

124 lines
3.5 KiB
Python
Executable File

#! /usr/bin/env python3
#
# Copyright 2016 - 2021 gary@drinkingtea.net
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
import argparse
import os
import platform
import shutil
import subprocess
import sys
import util
def main() -> int:
parser = argparse.ArgumentParser()
parser.add_argument(
'--target',
help='Platform target',
default=f'{util.get_os()}-{util.get_arch()}')
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(
'--build_root',
help='Path to the root build directory (must be in project dir)',
default='build')
parser.add_argument(
'--toolchain',
help='Path to CMake toolchain file',
default='')
parser.add_argument(
'--current_build',
help='Indicates whether or not to make this the active build',
default=1)
args = parser.parse_args()
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'
else:
print('Error: Invalid build tool')
return 1
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 'QTDIR' in os.environ:
qt_path = '-DQTDIR={:s}'.format(os.environ['QTDIR'])
else:
qt_path = ''
if args.build_tool == '' or args.build_tool == 'default':
if shutil.which('ninja') is None:
build_tool = ''
else:
build_tool = '-GNinja'
elif args.build_tool == 'xcode':
build_tool = '-GXcode'
else:
print('Error: Invalid build tool')
return 1
project_dir = os.getcwd()
build_dir = f'{project_dir}/{args.build_root}/{build_config}'
util.rm(build_dir)
cmake_cmd = [
'cmake', '-S', project_dir, '-B', build_dir,
'-DCMAKE_EXPORT_COMPILE_COMMANDS=ON',
'-DCMAKE_TOOLCHAIN_FILE={:s}'.format(args.toolchain),
'-DCMAKE_BUILD_TYPE={:s}'.format(build_type_arg),
'-DUSE_ASAN={:s}'.format(sanitizer_status),
'-DBUILDCORE_BUILD_CONFIG={:s}'.format(build_config),
'-DBUILDCORE_TARGET={:s}'.format(args.target),
]
if build_tool != '':
cmake_cmd.append(build_tool)
if qt_path != '':
cmake_cmd.append(qt_path)
if platform.system() == 'Windows':
cmake_cmd.append('-A x64')
cmake_err = subprocess.run(cmake_cmd).returncode
if cmake_err != 0:
return cmake_err
util.mkdir_p('dist')
if int(args.current_build) != 0:
cb = open('.current_build', 'w')
cb.write(args.build_type)
cb.close()
util.rm('compile_commands.json')
if platform.system() != 'Windows':
os.symlink(f'{build_dir}/compile_commands.json',
'compile_commands.json')
return 0
if __name__ == '__main__':
try:
sys.exit(main())
except KeyboardInterrupt:
sys.exit(1)