-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathautotools_package.py
More file actions
53 lines (43 loc) · 1.79 KB
/
autotools_package.py
File metadata and controls
53 lines (43 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from hashdist import build_stage
from os.path import join as pjoin
def rpath_flag(ctx, path):
if ctx.parameters['platform'] == 'linux':
return '-Wl,-rpath=%s' % path
else:
return ''
@build_stage()
def configure(ctx, stage_args):
"""
Generates configure line.
Example::
- name: configure
extra: ['--enable-foo', '--with-zlib=${ZLIB_DIR}']
set_env_flags: true # default
append: {'LDFLAGS': '-Wl,-rpath=${ARTIFACT}/lib'} # only meaningful if set_env_flags: true
configure_path: . # default
global_flags: false # default
If set_env_flags is set, CPPFLAGS and LDFLAGS will be set, as appropriate for the
platform.
"""
configure_path = stage_args.get('configure_path', '.')
conf_lines = [pjoin(configure_path, 'configure') + ' --prefix="${ARTIFACT}"']
if 'extra' in stage_args:
conf_lines.append(' '.join('"%s"' % arg for arg in stage_args['extra']))
for i in range(len(conf_lines) - 1):
conf_lines[i] = conf_lines[i] + ' \\'
conf_lines[i + 1] = ' ' + conf_lines[i + 1]
env_lines = []
if stage_args.get('set_env_flags', True):
env = {'CPPFLAGS': [], 'LDFLAGS': []}
for dep_var in ctx.dependency_dir_vars:
env['CPPFLAGS'].append('-I${%s_DIR}/include' % dep_var)
env['LDFLAGS'].append('-L${%s_DIR}/lib' % dep_var)
env['LDFLAGS'].append(rpath_flag(ctx, '${%s_DIR}/lib' % dep_var))
for var, value in stage_args.get('append', {}).items():
env.get(var, []).append(value)
for env_var, value in env.items():
env_lines.append('export %s="%s"' % (env_var, ' '.join(value)))
r = env_lines + conf_lines
if not stage_args.get('global_flags', False):
r = ['('] + r + [')']
return r