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.
This commit is contained in:
parent
1ca70d9759
commit
8217d75ca1
|
@ -1,24 +1,22 @@
|
||||||
import os.path, subprocess, sys
|
import os.path, subprocess, sys
|
||||||
|
|
||||||
from build.project import Project
|
from build.makeproject import MakeProject
|
||||||
|
|
||||||
class AutotoolsProject(Project):
|
class AutotoolsProject(MakeProject):
|
||||||
def __init__(self, url, md5, installed, configure_args=[],
|
def __init__(self, url, md5, installed, configure_args=[],
|
||||||
autogen=False,
|
autogen=False,
|
||||||
cppflags='',
|
cppflags='',
|
||||||
ldflags='',
|
ldflags='',
|
||||||
libs='',
|
libs='',
|
||||||
install_target='install',
|
|
||||||
**kwargs):
|
**kwargs):
|
||||||
Project.__init__(self, url, md5, installed, **kwargs)
|
MakeProject.__init__(self, url, md5, installed, **kwargs)
|
||||||
self.configure_args = configure_args
|
self.configure_args = configure_args
|
||||||
self.autogen = autogen
|
self.autogen = autogen
|
||||||
self.cppflags = cppflags
|
self.cppflags = cppflags
|
||||||
self.ldflags = ldflags
|
self.ldflags = ldflags
|
||||||
self.libs = libs
|
self.libs = libs
|
||||||
self.install_target = install_target
|
|
||||||
|
|
||||||
def build(self, toolchain):
|
def configure(self, toolchain):
|
||||||
src = self.unpack(toolchain)
|
src = self.unpack(toolchain)
|
||||||
if self.autogen:
|
if self.autogen:
|
||||||
if sys.platform == 'darwin':
|
if sys.platform == 'darwin':
|
||||||
|
@ -49,7 +47,8 @@ class AutotoolsProject(Project):
|
||||||
] + self.configure_args
|
] + self.configure_args
|
||||||
|
|
||||||
subprocess.check_call(configure, cwd=build, env=toolchain.env)
|
subprocess.check_call(configure, cwd=build, env=toolchain.env)
|
||||||
subprocess.check_call(['/usr/bin/make', '--quiet', '-j12'],
|
return build
|
||||||
cwd=build, env=toolchain.env)
|
|
||||||
subprocess.check_call(['/usr/bin/make', '--quiet', self.install_target],
|
def build(self, toolchain):
|
||||||
cwd=build, env=toolchain.env)
|
build = self.configure(toolchain)
|
||||||
|
MakeProject.build(self, toolchain, build)
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
from build.project import Project
|
||||||
|
|
||||||
|
class MakeProject(Project):
|
||||||
|
def __init__(self, url, md5, installed,
|
||||||
|
install_target='install',
|
||||||
|
**kwargs):
|
||||||
|
Project.__init__(self, url, md5, installed, **kwargs)
|
||||||
|
self.install_target = install_target
|
||||||
|
|
||||||
|
def get_simultaneous_jobs(self):
|
||||||
|
return 12
|
||||||
|
|
||||||
|
def get_make_args(self, toolchain):
|
||||||
|
return ['--quiet', '-j' + str(self.get_simultaneous_jobs())]
|
||||||
|
|
||||||
|
def get_make_install_args(self, toolchain):
|
||||||
|
return ['--quiet', self.install_target]
|
||||||
|
|
||||||
|
def make(self, toolchain, wd, args):
|
||||||
|
subprocess.check_call(['/usr/bin/make'] + args,
|
||||||
|
cwd=wd, env=toolchain.env)
|
||||||
|
|
||||||
|
def build(self, toolchain, wd, install=True):
|
||||||
|
self.make(toolchain, wd, self.get_make_args(toolchain))
|
||||||
|
if install:
|
||||||
|
self.make(toolchain, wd, self.get_make_install_args(toolchain))
|
Loading…
Reference in New Issue