forked from conan-io/conan
/
autotools.py
68 lines (56 loc) · 2.6 KB
/
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
66
67
68
import os
from conan.tools.files import load_toolchain_args
from conan.tools.gnu.make import make_jobs_cmd_line_arg
from conan.tools.microsoft import unix_path
from conans.client.build import join_arguments
class Autotools(object):
def __init__(self, conanfile):
self._conanfile = conanfile
toolchain_file_content = load_toolchain_args(self._conanfile.generators_folder)
self._configure_args = toolchain_file_content.get("configure_args")
self._make_args = toolchain_file_content.get("make_args")
def configure(self, build_script_folder=None):
"""
http://jingfenghanmax.blogspot.com.es/2010/09/configure-with-host-target-and-build.html
https://gcc.gnu.org/onlinedocs/gccint/Configure-Terms.html
"""
# FIXME: Conan 2.0 Are we keeping the "should_XXX" properties???
if not self._conanfile.should_configure:
return
source = self._conanfile.source_folder
if build_script_folder:
source = os.path.join(self._conanfile.source_folder, build_script_folder)
configure_cmd = "{}/configure".format(source)
configure_cmd = unix_path(self._conanfile, configure_cmd)
cmd = "{} {}".format(configure_cmd, self._configure_args)
self._conanfile.output.info("Calling:\n > %s" % cmd)
self._conanfile.run(cmd)
def make(self, target=None):
make_program = self._conanfile.conf["tools.gnu:make_program"]
if make_program is None:
make_program = "mingw32-make" if self._use_win_mingw() else "make"
str_args = self._make_args
jobs = ""
if "-j" not in str_args and "nmake" not in make_program.lower():
jobs = make_jobs_cmd_line_arg(self._conanfile) or ""
command = join_arguments([make_program, target, str_args, jobs])
self._conanfile.run(command)
def install(self):
if not self._conanfile.should_install:
return
self.make(target="install")
def _use_win_mingw(self):
if hasattr(self._conanfile, 'settings_build'):
os_build = self._conanfile.settings_build.get_safe('os')
else:
os_build = self._conanfile.settings.get_safe("os")
if os_build == "Windows":
compiler = self._conanfile.settings.get_safe("compiler")
sub = self._conanfile.settings.get_safe("os.subsystem")
if sub in ("cygwin", "msys2", "msys") or compiler == "qcc":
return False
else:
if self._conanfile.win_bash:
return False
return True
return False