Updated/fixed init script.

This commit is contained in:
Patrick 2025-06-06 17:40:48 +02:00
parent d9371e9cd4
commit b3a0e68100
3 changed files with 35 additions and 13 deletions

View File

@ -1,5 +1,5 @@
config = { config = {
'PROJECT_NAME': 'spp_template' 'PROJECT_NAME': '@PROJECT_NAME@'
} }
env = SConscript('external/scons-plus-plus/SConscript', exports = ['config']) env = SConscript('external/scons-plus-plus/SConscript', exports = ['config'])
env.Append(CPPPATH = [Dir('private'), Dir('public')]) env.Append(CPPPATH = [Dir('private'), Dir('public')])
@ -9,6 +9,6 @@ env.RecipeRepo('mewin-stable', 'https://git.mewin.de/mewin/spp_recipes.git', 'st
# env.RecipeRepo('mewin-testing', 'https://git.mewin.de/mewin/spp_recipes.git', 'testing') # env.RecipeRepo('mewin-testing', 'https://git.mewin.de/mewin/spp_recipes.git', 'testing')
# app # app
env = env.Module('private/spp_template/SModule') env = env.Module('private/@MODULE_FOLDER_NAME@/SModule')
env.Finalize() env.Finalize()

View File

@ -6,8 +6,8 @@ src_files = Split("""
""") """)
prog_app = env.UnityProgram( prog_app = env.UnityProgram(
name = 'Template', name = '@MODULE_NAME@',
target = env['BIN_DIR'] + '/spp_template', target = env['BIN_DIR'] + '/@EXE_NAME@',
source = src_files, source = src_files,
dependencies = { dependencies = {
'mijin': {} 'mijin': {}

View File

@ -64,6 +64,11 @@ def update_spp() -> None:
_logger.info('Changes in SCons++ detected, creating commit.') _logger.info('Changes in SCons++ detected, creating commit.')
_exec_checked(['git', 'commit', '-m', 'Updated Scons++', 'external/scons-plus-plus']) _exec_checked(['git', 'commit', '-m', 'Updated Scons++', 'external/scons-plus-plus'])
def verify_unchanged() -> None:
output = _exec_get_output(['git', 'status', '--porcelain'])
if output != '':
raise RuntimeError('There are uncommitted changes. Commit, stash or revert them before running this script.')
def _replace_in_file(file: Path, **replacements) -> None: def _replace_in_file(file: Path, **replacements) -> None:
_logger.debug('Patching file "%s"...', file) _logger.debug('Patching file "%s"...', file)
bakfile = file.with_suffix(f'{file.suffix}.bak') bakfile = file.with_suffix(f'{file.suffix}.bak')
@ -107,19 +112,36 @@ def setup_project() -> None:
template_folder = _root / 'private/spp_template' template_folder = _root / 'private/spp_template'
module_folder = _root / 'private' / module_folder_name module_folder = _root / 'private' / module_folder_name
_logger.debug(f'Moving {template_folder} to {module_folder}.') _logger.debug(f'Moving {template_folder} to {module_folder}.')
shutil.move(template_folder, module_folder)
_logger.info('Creating a git commit for the setup.') _logger.info('Creating a git commit for the setup.')
_exec_checked(['git', 'commit', '-m', 'Project setup', 'SConstruct', 'private']) _exec_checked(['git', 'add', '.'])
_exec_checked(['git', 'commit', '-m', 'Project setup'])
def setup_git_remote() -> None:
current_url = _exec_get_output(['git', 'remote', 'get-url', 'origin'])
if 'spp_template' not in current_url:
_logger.debug('Remote already set up.')
return
remote_url = ''
while remote_url == '':
print('Please enter a new URL for your git remote.')
remote_url = _prompt().strip()
_exec_checked(['git', 'remote', 'set-url', 'origin', remote_url])
if __name__ == '__main__': if __name__ == '__main__':
logging.basicConfig(level=logging.DEBUG, format='%(message)s') logging.basicConfig(level=logging.DEBUG, format='%(message)s')
_root = Path(__file__).parent.parent _root = Path(__file__).parent.parent
os.chdir(_root) os.chdir(_root)
#try: try:
verify_tools() verify_tools()
download_spp() download_spp()
update_spp() update_spp()
setup_project() verify_unchanged()
#except Exception as e: setup_project()
# _logger.error('There was an error running the script: %s.', e) setup_git_remote()
# sys.exit(1) except Exception as e:
_logger.error('There was an error running the script: %s', e)
sys.exit(1)