Replaced S++ submodule with loader script.
This commit is contained in:
parent
d3b56d3fd0
commit
db09eb5e3a
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
|
1
external/scons-plus-plus
vendored
1
external/scons-plus-plus
vendored
@ -1 +0,0 @@
|
||||
Subproject commit 9436d2c48d91dc104099d8805c696a85d7bd37f2
|
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')
|
Loading…
x
Reference in New Issue
Block a user