53 lines
1.7 KiB
Python
53 lines
1.7 KiB
Python
|
|
import re
|
|
from SCons.Script import *
|
|
|
|
_REPO_NAMES = {
|
|
'default': 'glm',
|
|
'mewin': 'glm_mewin'
|
|
}
|
|
_REPO_URLS = {
|
|
'default': 'https://github.com/g-truc/glm.git',
|
|
'mewin': 'https://git.mewin.de/mewin/glm.git'
|
|
}
|
|
_TAG_PATTERN = re.compile(r'^([0-9]+)\.([0-9]+)\.([0-9]+)$')
|
|
_TAG_PATTERN_ALT = re.compile(r'^0\.([0-9]+)\.([0-9]+)\.([0-9]+)$')
|
|
|
|
def _get_repo_name(env: Environment) -> str:
|
|
return _REPO_NAMES[env.get('GLM_REMOTE', 'default')]
|
|
|
|
def _get_repo_url(env: Environment) -> str:
|
|
return _REPO_URLS[env.get('GLM_REMOTE', 'default')]
|
|
|
|
def versions(env: Environment, update: bool = False):
|
|
if env.get('GLM_REMOTE') == 'mewin':
|
|
return [(0, 0, 0)]
|
|
|
|
tags = env.GitTags(repo_name = _get_repo_name(env), remote_url = _get_repo_url(env), force_fetch=update)
|
|
result = []
|
|
for tag in tags:
|
|
match = _TAG_PATTERN.match(tag)
|
|
if match:
|
|
result.append((int(match.groups()[0]), int(match.groups()[1]), int(match.groups()[2])))
|
|
else:
|
|
match = _TAG_PATTERN_ALT.match(tag)
|
|
if match:
|
|
result.append((0, int(match.groups()[0]), int(match.groups()[1]) * 10 + int(match.groups()[2])))
|
|
return result
|
|
|
|
def dependencies(env: Environment, version) -> 'dict':
|
|
return {}
|
|
|
|
def cook(env: Environment, version) -> dict:
|
|
if env.get('GLM_REMOTE') == 'mewin':
|
|
git_ref = 'master'
|
|
elif version[0] == 0:
|
|
git_ref = f'refs/tags/0.{version[1]}.{int(version[2]/10)}.{version[2]%10}'
|
|
else:
|
|
git_ref = f'refs/tags/{version[0]}.{version[1]}.{version[2]}'
|
|
repo = env.GitBranch(repo_name = _get_repo_name(env), remote_url = _get_repo_url(env), git_ref = git_ref)
|
|
checkout_root = repo['checkout_root']
|
|
return {
|
|
'CPPPATH': [checkout_root],
|
|
}
|