forked from vysheng/tg
-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathx-autotools.py
65 lines (52 loc) · 2.02 KB
/
x-autotools.py
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
54
55
56
57
58
59
60
61
62
63
64
65
# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-
"""This is a modified version of snapcraft's autootools plugin.
This plugin uses the common plugin keywords as well as those for "sources".
For more information check the 'plugins' topic for the former and the
'sources' topic for the latter.
In addition, this plugin uses the following plugin-specific keywords:
- configflags:
(list of strings)
configure flags to pass to the build such as those shown by running
'./configure --help'
"""
import os
import snapcraft
class AutotoolsPlugin(snapcraft.BasePlugin):
@classmethod
def schema(cls):
schema = super().schema()
schema['properties']['configflags'] = {
'type': 'array',
'minitems': 1,
'uniqueItems': True,
'items': {
'type': 'string',
},
'default': [],
}
schema['properties']['artifacts'] = {
'type': 'array',
'minitems': 1,
'uniqueItems': True,
'items': {
'type': 'string',
},
'default': [],
}
# Inform Snapcraft of the properties associated with building. If these
# change in the YAML, Snapcraft will consider the build step dirty.
schema['build-properties'].extend(['configflags'])
return schema
def __init__(self, name, options, project):
super().__init__(name, options, project)
self.build_packages.append('make')
def build(self):
super().build()
self.run(['./configure'] + self.options.configflags)
self.run(['make', '-j{}'.format(self.parallel_build_count)])
for artifact in self.options.artifacts:
source_path = os.path.join(self.builddir, artifact)
destination_path = os.path.join(self.installdir, artifact)
os.makedirs(os.path.dirname(destination_path), exist_ok=True)
snapcraft.file_utils.link_or_copy(
source_path, destination_path)