Added update_repositories command line argument to refresh git repositories. And added recipe for Criterion.
This commit is contained in:
parent
acffaa9928
commit
1988bcc99b
@ -140,12 +140,19 @@ AddOption(
|
|||||||
default = 'auto'
|
default = 'auto'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
AddOption(
|
||||||
|
'--update_repositories',
|
||||||
|
dest = 'update_repositories',
|
||||||
|
action = 'store_true'
|
||||||
|
)
|
||||||
|
|
||||||
build_type = GetOption('build_type')
|
build_type = GetOption('build_type')
|
||||||
unity_mode = GetOption('unity_mode')
|
unity_mode = GetOption('unity_mode')
|
||||||
variant = GetOption('variant')
|
variant = GetOption('variant')
|
||||||
enable_asan = GetOption('enable_asan')
|
enable_asan = GetOption('enable_asan')
|
||||||
config_file = GetOption('config_file')
|
config_file = GetOption('config_file')
|
||||||
compiler = GetOption('compiler')
|
compiler = GetOption('compiler')
|
||||||
|
update_repositories = GetOption('update_repositories')
|
||||||
|
|
||||||
default_CC = {
|
default_CC = {
|
||||||
'gcc': 'gcc',
|
'gcc': 'gcc',
|
||||||
@ -170,6 +177,7 @@ env = Environment(tools = ['default', 'compilation_db', 'unity_build'], variable
|
|||||||
env['RECIPES_FOLDERS'] = [Dir('recipes')]
|
env['RECIPES_FOLDERS'] = [Dir('recipes')]
|
||||||
env['SYSTEM_CACHE_DIR'] = os.path.join(_find_system_cache_dir(), 'spp_cache')
|
env['SYSTEM_CACHE_DIR'] = os.path.join(_find_system_cache_dir(), 'spp_cache')
|
||||||
env['CLONE_DIR'] = os.path.join(env['SYSTEM_CACHE_DIR'], 'cloned')
|
env['CLONE_DIR'] = os.path.join(env['SYSTEM_CACHE_DIR'], 'cloned')
|
||||||
|
env['UPDATE_REPOSITORIES'] = update_repositories
|
||||||
|
|
||||||
print(f'Detected system cache directory: {env["SYSTEM_CACHE_DIR"]}')
|
print(f'Detected system cache directory: {env["SYSTEM_CACHE_DIR"]}')
|
||||||
try:
|
try:
|
||||||
|
@ -11,15 +11,23 @@ def cook(env: Environment, repo_name: str, remote_url: str, git_ref: str = "main
|
|||||||
repo = Repo(repo_dir)
|
repo = Repo(repo_dir)
|
||||||
origin = repo.remotes['origin']
|
origin = repo.remotes['origin']
|
||||||
except GitError:
|
except GitError:
|
||||||
print(f'Initializing git repository for SDL at {repo_dir}.')
|
print(f'Initializing git repository at {repo_dir}.')
|
||||||
repo = Repo.init(repo_dir, bare=True)
|
repo = Repo.init(repo_dir, bare=True)
|
||||||
origin = repo.create_remote('origin', remote_url)
|
origin = repo.create_remote('origin', remote_url)
|
||||||
worktree_dir = os.path.join(env['CLONE_DIR'], 'git', repo_name, hashlib.shake_128(git_ref.encode('utf-8')).hexdigest(6)) # TODO: commit hash would be better, right?
|
worktree_dir = os.path.join(env['CLONE_DIR'], 'git', repo_name, hashlib.shake_128(git_ref.encode('utf-8')).hexdigest(6)) # TODO: commit hash would be better, right? -> not if it's a branch!
|
||||||
if not os.path.exists(worktree_dir):
|
if not os.path.exists(worktree_dir):
|
||||||
print(f'Checking out into {worktree_dir}.')
|
print(f'Checking out into {worktree_dir}.')
|
||||||
origin.fetch()
|
origin.fetch()
|
||||||
os.makedirs(worktree_dir)
|
os.makedirs(worktree_dir)
|
||||||
repo.git.worktree('add', worktree_dir, git_ref)
|
repo.git.worktree('add', worktree_dir, git_ref)
|
||||||
|
elif env['UPDATE_REPOSITORIES']:
|
||||||
|
worktree_repo = Repo(worktree_dir)
|
||||||
|
if not worktree_repo.head.is_detached:
|
||||||
|
print(f'Updating git repository at {worktree_dir}')
|
||||||
|
worktree_origin = worktree_repo.remotes['origin']
|
||||||
|
worktree_origin.pull()
|
||||||
|
else:
|
||||||
|
print(f'Not updating git repository {worktree_dir} as it is not on a branch.')
|
||||||
return {
|
return {
|
||||||
'checkout_root': worktree_dir
|
'checkout_root': worktree_dir
|
||||||
}
|
}
|
||||||
|
35
recipes/criterion/recipe.py
Normal file
35
recipes/criterion/recipe.py
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
from SCons.Script import *
|
||||||
|
|
||||||
|
def cook(env: Environment, git_ref: str = "master") -> dict:
|
||||||
|
repo = env.Cook('GitBranch', repo_name = 'criterion', remote_url = 'https://github.com/Snaipe/Criterion.git', git_ref = git_ref)
|
||||||
|
checkout_root = repo['checkout_root']
|
||||||
|
|
||||||
|
config = env['BUILD_TYPE']
|
||||||
|
build_dir = os.path.join(checkout_root, f'build_{config}')
|
||||||
|
install_dir = os.path.join(checkout_root, f'install_{config}')
|
||||||
|
lib_fname = 'libcriterion.a' # TODO: who cares about windows?
|
||||||
|
is_built = os.path.exists(os.path.join(install_dir, 'lib', lib_fname)) # TODO!
|
||||||
|
if not is_built:
|
||||||
|
print(f'Building Criterion, config {config}')
|
||||||
|
os.makedirs(build_dir, exist_ok=True)
|
||||||
|
build_type = {
|
||||||
|
'debug': 'debug',
|
||||||
|
'release_debug': 'debugoptimized',
|
||||||
|
'release': 'release',
|
||||||
|
'profile': 'debugoptimized'
|
||||||
|
}.get(env['BUILD_TYPE'], 'debugoptimized')
|
||||||
|
subprocess.run(['meson', 'setup', '--prefix', install_dir, '--buildtype', build_type, build_dir, checkout_root], stdout=sys.stdout, stderr=sys.stderr, check=True)
|
||||||
|
subprocess.run(['meson', 'install', '-C', build_dir], stdout=sys.stdout, stderr=sys.stderr, check=True)
|
||||||
|
|
||||||
|
|
||||||
|
lib_name = 'criterion'
|
||||||
|
return {
|
||||||
|
'LIBPATH': [os.path.join(install_dir, 'lib')],
|
||||||
|
'CPPPATH': [os.path.join(install_dir, 'include')],
|
||||||
|
'LIBS': [lib_name]
|
||||||
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user