55 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			55 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
 | 
						|
import re
 | 
						|
from SCons.Script import *
 | 
						|
 | 
						|
def _build_lib_name(env: Environment) -> str:
 | 
						|
    if os.name == 'posix':
 | 
						|
        return {
 | 
						|
            'debug': 'curl-d'
 | 
						|
        }.get(env['BUILD_TYPE'], 'curl')
 | 
						|
    elif os.name == 'nt':
 | 
						|
        return {
 | 
						|
            'debug': 'libcurl-d'
 | 
						|
        }.get(env['BUILD_TYPE'], 'libcurl')
 | 
						|
    else:
 | 
						|
        raise Exception('curl is not supported yet on this OS')
 | 
						|
 | 
						|
def _git_cook(env: Environment, repo: dict) -> dict:
 | 
						|
    checkout_root = repo['checkout_root']
 | 
						|
    build_result = env.CMakeProject(checkout_root, generate_args=['-DBUILD_CURL_EXE=OFF','-DBUILD_SHARED_LIBS=OFF',
 | 
						|
                                                                  '-DBUILD_STATIC_LIBS=ON', '-DHTTP_ONLY=ON',
 | 
						|
                                                                  '-DCURL_USE_LIBSSH2=OFF'])
 | 
						|
    lib_name = _build_lib_name(env)
 | 
						|
    return {
 | 
						|
        'CPPPATH': build_result['CPPPATH'],
 | 
						|
        'LIBS': [env.FindLib(lib_name, paths=build_result['LIBPATH'])],
 | 
						|
        'CPPDEFINES': ['CURL_STATICLIB=1']
 | 
						|
    }
 | 
						|
 | 
						|
def _git_dependencies(env: Environment, version) -> 'dict':
 | 
						|
    deps = {
 | 
						|
        'posix': {
 | 
						|
            'openssl': {},
 | 
						|
            'zlib': {},
 | 
						|
            'psl': {}
 | 
						|
        },
 | 
						|
        'nt': {
 | 
						|
            'wincrypt': {},
 | 
						|
            'winldap': {},
 | 
						|
            'winsock2': {}
 | 
						|
        }
 | 
						|
    }.get(os.name, {})
 | 
						|
    if os.name == 'posix' and version >= (8, 10, 0):
 | 
						|
        deps['nghttp2'] = {}
 | 
						|
    return deps
 | 
						|
 | 
						|
env.GitRecipe(
 | 
						|
    globals = globals(),
 | 
						|
    repo_name = 'curl',
 | 
						|
    repo_url = 'https://github.com/curl/curl.git',
 | 
						|
    tag_pattern = re.compile(r'^curl-([0-9]+)_([0-9]+)_([0-9]+)$'),
 | 
						|
    tag_fn = lambda version: f'curl-{version[0]}_{version[1]}_{version[2]}',
 | 
						|
    cook_fn = _git_cook,
 | 
						|
    dependencies = _git_dependencies
 | 
						|
)
 |