Compare commits
3 Commits
d9f3d03e4d
...
911c5cd674
Author | SHA1 | Date | |
---|---|---|---|
911c5cd674 | |||
9abb3ba39f | |||
4f7f516015 |
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -1,3 +0,0 @@
|
|||||||
[submodule "scons-plus-plus"]
|
|
||||||
path = external/scons-plus-plus
|
|
||||||
url = https://git.mewin.de/mewin/scons-plus-plus.git
|
|
@ -5,8 +5,8 @@ env = SConscript('external/scons-plus-plus/SConscript', exports = ['config'])
|
|||||||
env.Append(CPPPATH = [Dir('private'), Dir('public')])
|
env.Append(CPPPATH = [Dir('private'), Dir('public')])
|
||||||
|
|
||||||
# add the default recipe repository
|
# add the default recipe repository
|
||||||
env.RecipeRepo('mewin-stable', 'https://git.mewin.de/mewin/spp_recipes.git', 'stable')
|
env.RecipeRepo('mewin', 'https://git.mewin.de/mewin/spp_recipes.git', 'stable')
|
||||||
# env.RecipeRepo('mewin-testing', 'https://git.mewin.de/mewin/spp_recipes.git', 'testing')
|
# env.RecipeRepo('mewin', 'https://git.mewin.de/mewin/spp_recipes.git', 'testing')
|
||||||
|
|
||||||
# app
|
# app
|
||||||
env = env.Module('private/@MODULE_FOLDER_NAME@/SModule')
|
env = env.Module('private/@MODULE_FOLDER_NAME@/SModule')
|
||||||
|
1
external/scons-plus-plus
vendored
1
external/scons-plus-plus
vendored
@ -1 +0,0 @@
|
|||||||
Subproject commit 75c626c235a2d364159e340c1a7b7b02363104e0
|
|
84
external/scons-plus-plus/SConscript
vendored
Normal file
84
external/scons-plus-plus/SConscript
vendored
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
"""
|
||||||
|
SCons++ Bootstrapper
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
import shutil
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
from SCons.Environment import Environment
|
||||||
|
|
||||||
|
|
||||||
|
Import('config')
|
||||||
|
|
||||||
|
|
||||||
|
_SPP_FOLDER_NAME = 'scons-plus-plus'
|
||||||
|
_SPP_DEFAULT_REPOSITORY = 'https://git.mewin.de/mewin/scons-plus-plus.git'
|
||||||
|
_SPP_DEFAULT_BRANCH = 'master'
|
||||||
|
|
||||||
|
|
||||||
|
spp_root: Path
|
||||||
|
spp_repository: str
|
||||||
|
spp_branch: str
|
||||||
|
|
||||||
|
def _main() -> Environment:
|
||||||
|
global spp_root, spp_repository, spp_branch
|
||||||
|
|
||||||
|
spp_root = config.get('SPP_ROOT')
|
||||||
|
if spp_root is None:
|
||||||
|
spp_root = _get_default_spp_root()
|
||||||
|
elif not isinstance(spp_root, Path):
|
||||||
|
spp_root = Path(str(spp_root))
|
||||||
|
spp_root = spp_root.absolute()
|
||||||
|
|
||||||
|
spp_repository = config.get('SPP_REPOSITORY', _SPP_DEFAULT_REPOSITORY)
|
||||||
|
spp_branch = config.get('SPP_BRANCH', _SPP_DEFAULT_BRANCH)
|
||||||
|
|
||||||
|
_printinfo(f'Using SCons++ root at: {spp_root}')
|
||||||
|
|
||||||
|
if not spp_root.exists():
|
||||||
|
_printinfo('SCons++ does not yet exist, downloading it.')
|
||||||
|
_install_spp()
|
||||||
|
|
||||||
|
spp_script = spp_root / 'SConscript'
|
||||||
|
if not spp_script.exists():
|
||||||
|
_printerr(f'SCons++ main script not found at {spp_script}!')
|
||||||
|
sys.exit(1)
|
||||||
|
return SConscript(spp_script, exports=['config'])
|
||||||
|
|
||||||
|
def _get_default_spp_root() -> Path:
|
||||||
|
if os.name == 'posix':
|
||||||
|
# follow XDG specification -> first try $XDG_DATA_HOME, then $HOME/.local/share
|
||||||
|
data_home = os.environ.get('XDG_DATA_HOME')
|
||||||
|
if data_home is not None:
|
||||||
|
return Path(data_home, _SPP_FOLDER_NAME)
|
||||||
|
home = os.environ.get('HOME')
|
||||||
|
if home is not None:
|
||||||
|
return Path(home, '.local', 'share', _SPP_FOLDER_NAME)
|
||||||
|
elif os.name == 'nt':
|
||||||
|
# just use LocalAppData, which should always be set on Windows
|
||||||
|
return Path(os.environ['LocalAppData'], _SPP_FOLDER_NAME)
|
||||||
|
_printinfo(f'Could not detect SCons++ root directory, falling back to ./{_SPP_FOLDER_NAME}.')
|
||||||
|
return Path(_SPP_FOLDER_NAME)
|
||||||
|
|
||||||
|
def _install_spp() -> None:
|
||||||
|
git_exe = shutil.which('git')
|
||||||
|
if git_exe is None:
|
||||||
|
_printerr('No git executable found, cannot install SCons++.')
|
||||||
|
sys.exit(1)
|
||||||
|
_exec_checked((git_exe, 'clone', '-b', spp_branch, '--progress', spp_repository, spp_root))
|
||||||
|
|
||||||
|
def _exec_checked(args: Sequence[str], **kwargs) -> None:
|
||||||
|
subprocess.run(args, stdout=sys.stdout, stderr=sys.stderr, check=True, **kwargs)
|
||||||
|
|
||||||
|
if not GetOption('silent'):
|
||||||
|
_printinfo = print
|
||||||
|
else:
|
||||||
|
def _printinfo(*args): ...
|
||||||
|
def _printerr(*args) -> None:
|
||||||
|
print(*args, file=sys.stderr)
|
||||||
|
|
||||||
|
env = _main()
|
||||||
|
Return('env')
|
@ -28,36 +28,6 @@ def verify_tools() -> None:
|
|||||||
if not success:
|
if not success:
|
||||||
raise RuntimeError('one or more required tools could not be found')
|
raise RuntimeError('one or more required tools could not be found')
|
||||||
|
|
||||||
def download_spp() -> None:
|
|
||||||
_logger.debug('Checking if Scons++ is checked out...')
|
|
||||||
output = exec_get_output(['git', 'submodule', 'status', 'external/scons-plus-plus'])
|
|
||||||
if output[0] in ('+', ' '):
|
|
||||||
return
|
|
||||||
assert output[0] == '-'
|
|
||||||
_logger.info('SCons++ not checkout out yet, doing it now.')
|
|
||||||
exec_checked(['git', 'submodule', 'init'])
|
|
||||||
exec_checked(['git', 'submodule', 'update', 'external/scons-plus-plus'])
|
|
||||||
|
|
||||||
def update_spp() -> None:
|
|
||||||
_logger.debug('Updating SCons++ submodule...')
|
|
||||||
os.chdir(_root / 'external/scons-plus-plus')
|
|
||||||
try:
|
|
||||||
exec_checked(['git', 'fetch', 'origin', 'master'])
|
|
||||||
exec_checked(['git', 'checkout', 'master'])
|
|
||||||
exec_checked(['git', 'pull'])
|
|
||||||
finally:
|
|
||||||
os.chdir(_root)
|
|
||||||
output = exec_get_output(['git', 'status', '--porcelain'])
|
|
||||||
if output.strip() == '':
|
|
||||||
return
|
|
||||||
_logger.info('Changes in SCons++ detected, creating commit.')
|
|
||||||
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 setup_project() -> None:
|
def setup_project() -> None:
|
||||||
project_name = ''
|
project_name = ''
|
||||||
while project_name == '':
|
while project_name == '':
|
||||||
@ -111,9 +81,6 @@ def script_main():
|
|||||||
global _root
|
global _root
|
||||||
_root = get_root()
|
_root = get_root()
|
||||||
verify_tools()
|
verify_tools()
|
||||||
download_spp()
|
|
||||||
update_spp()
|
|
||||||
verify_unchanged()
|
|
||||||
setup_project()
|
setup_project()
|
||||||
setup_git_remote()
|
setup_git_remote()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user