36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
|
|
import re
|
|
from SCons.Script import *
|
|
|
|
_REPO_NAME = 'libpng'
|
|
_REPO_URL = 'https://git.code.sf.net/p/libpng/code.git'
|
|
_TAG_PATTERN = re.compile(r'^v([0-9])+\.([0-9])+\.([0-9])$')
|
|
|
|
def available(env: Environment) -> bool:
|
|
return hasattr(env, 'GitBranch') and hasattr(env, 'GitTags')
|
|
|
|
def versions(env: Environment, update: bool = False) -> 'list[str]':
|
|
tags = env.GitTags(repo_name = _REPO_NAME, remote_url = _REPO_URL, 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])))
|
|
return result
|
|
|
|
def dependencies(env: Environment, version) -> 'list[dict]':
|
|
return {
|
|
'zlib': {}
|
|
}
|
|
|
|
def cook(env: Environment, git_ref = 'master') -> dict:
|
|
lib_z = env.Cook('zlib')
|
|
repo = env.GitBranch(repo_name = 'libpng', remote_url = 'https://git.code.sf.net/p/libpng/code.git', git_ref = git_ref)
|
|
checkout_root = repo['checkout_root']
|
|
build_result = env.AutotoolsProject(checkout_root)
|
|
return {
|
|
'CPPPATH': build_result['CPPPATH'],
|
|
'LIBS': [env.FindLib('png16', paths=build_result['LIBPATH'])],
|
|
'DEPENDENCIES': [lib_z]
|
|
}
|