Skip to content

Commit 8217d75

Browse files
felixhaedickeMaxKellermann
authored andcommitted
build/python: refactoring: introduce new class MakeProject
This introduces a the new class MakeProject, which is used as a base class for all Makefile based thirdparty libraries.
1 parent 1ca70d9 commit 8217d75

File tree

2 files changed

+37
-10
lines changed

2 files changed

+37
-10
lines changed

python/build/autotools.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
import os.path, subprocess, sys
22

3-
from build.project import Project
3+
from build.makeproject import MakeProject
44

5-
class AutotoolsProject(Project):
5+
class AutotoolsProject(MakeProject):
66
def __init__(self, url, md5, installed, configure_args=[],
77
autogen=False,
88
cppflags='',
99
ldflags='',
1010
libs='',
11-
install_target='install',
1211
**kwargs):
13-
Project.__init__(self, url, md5, installed, **kwargs)
12+
MakeProject.__init__(self, url, md5, installed, **kwargs)
1413
self.configure_args = configure_args
1514
self.autogen = autogen
1615
self.cppflags = cppflags
1716
self.ldflags = ldflags
1817
self.libs = libs
19-
self.install_target = install_target
2018

21-
def build(self, toolchain):
19+
def configure(self, toolchain):
2220
src = self.unpack(toolchain)
2321
if self.autogen:
2422
if sys.platform == 'darwin':
@@ -49,7 +47,8 @@ def build(self, toolchain):
4947
] + self.configure_args
5048

5149
subprocess.check_call(configure, cwd=build, env=toolchain.env)
52-
subprocess.check_call(['/usr/bin/make', '--quiet', '-j12'],
53-
cwd=build, env=toolchain.env)
54-
subprocess.check_call(['/usr/bin/make', '--quiet', self.install_target],
55-
cwd=build, env=toolchain.env)
50+
return build
51+
52+
def build(self, toolchain):
53+
build = self.configure(toolchain)
54+
MakeProject.build(self, toolchain, build)

python/build/makeproject.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import subprocess
2+
3+
from build.project import Project
4+
5+
class MakeProject(Project):
6+
def __init__(self, url, md5, installed,
7+
install_target='install',
8+
**kwargs):
9+
Project.__init__(self, url, md5, installed, **kwargs)
10+
self.install_target = install_target
11+
12+
def get_simultaneous_jobs(self):
13+
return 12
14+
15+
def get_make_args(self, toolchain):
16+
return ['--quiet', '-j' + str(self.get_simultaneous_jobs())]
17+
18+
def get_make_install_args(self, toolchain):
19+
return ['--quiet', self.install_target]
20+
21+
def make(self, toolchain, wd, args):
22+
subprocess.check_call(['/usr/bin/make'] + args,
23+
cwd=wd, env=toolchain.env)
24+
25+
def build(self, toolchain, wd, install=True):
26+
self.make(toolchain, wd, self.get_make_args(toolchain))
27+
if install:
28+
self.make(toolchain, wd, self.get_make_install_args(toolchain))

0 commit comments

Comments
 (0)