blob: 900244004ec5cd67a0597dc29bbcfb6ada713c77 [file] [log] [blame]
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001# avoids build breaks when using no-static-libs.inc
2DISABLE_STATIC = ""
3
Brad Bishop19323692019-04-05 15:28:33 -04004B = "${WORKDIR}/build"
5
Brad Bishop6e60e8b2018-02-01 10:27:11 -05006EXTRA_OECONF_append = " ${PACKAGECONFIG_CONFARGS}"
7
Brad Bishopc342db32019-05-15 21:57:59 -04008def waflock_hash(d):
9 # Calculates the hash used for the waf lock file. This should include
10 # all of the user controllable inputs passed to waf configure. Note
11 # that the full paths for ${B} and ${S} are used; this is OK and desired
12 # because a change to either of these should create a unique lock file
13 # to prevent collisions.
14 import hashlib
15 h = hashlib.sha512()
16 def update(name):
17 val = d.getVar(name)
18 if val is not None:
19 h.update(val.encode('utf-8'))
20 update('S')
21 update('B')
22 update('prefix')
23 update('EXTRA_OECONF')
24 return h.hexdigest()
25
26# Use WAFLOCK to specify a separate lock file. The build is already
27# sufficiently isolated by setting the output directory, this ensures that
28# bitbake won't step on toes of any other configured context in the source
29# directory (e.g. if the source is coming from externalsrc and was previously
30# configured elsewhere).
31export WAFLOCK = ".lock-waf_oe_${@waflock_hash(d)}_build"
32BB_HASHBASE_WHITELIST += "WAFLOCK"
33
Brad Bishopd7bf8c12018-02-25 22:55:05 -050034python waf_preconfigure() {
Brad Bishop316dfdd2018-06-25 12:45:53 -040035 import subprocess
Brad Bishopd7bf8c12018-02-25 22:55:05 -050036 from distutils.version import StrictVersion
Brad Bishop316dfdd2018-06-25 12:45:53 -040037 subsrcdir = d.getVar('S')
38 wafbin = os.path.join(subsrcdir, 'waf')
39 try:
40 result = subprocess.check_output([wafbin, '--version'], cwd=subsrcdir, stderr=subprocess.STDOUT)
41 version = result.decode('utf-8').split()[1]
42 if StrictVersion(version) >= StrictVersion("1.8.7"):
43 d.setVar("WAF_EXTRA_CONF", "--bindir=${bindir} --libdir=${libdir}")
44 except subprocess.CalledProcessError as e:
45 bb.warn("Unable to execute waf --version, exit code %d. Assuming waf version without bindir/libdir support." % e.returncode)
46 except FileNotFoundError:
47 bb.fatal("waf does not exist in %s" % subsrcdir)
Brad Bishopd7bf8c12018-02-25 22:55:05 -050048}
49
50do_configure[prefuncs] += "waf_preconfigure"
51
Patrick Williamsc124f4f2015-09-15 14:41:29 -050052waf_do_configure() {
Brad Bishop19323692019-04-05 15:28:33 -040053 (cd ${S} && ./waf configure -o ${B} --prefix=${prefix} ${WAF_EXTRA_CONF} ${EXTRA_OECONF})
Patrick Williamsc124f4f2015-09-15 14:41:29 -050054}
55
Brad Bishop316dfdd2018-06-25 12:45:53 -040056do_compile[progress] = "outof:^\[\s*(\d+)/\s*(\d+)\]\s+"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050057waf_do_compile() {
Brad Bishop19323692019-04-05 15:28:33 -040058 (cd ${S} && ./waf build ${@oe.utils.parallel_make_argument(d, '-j%d', limit=64)})
Patrick Williamsc124f4f2015-09-15 14:41:29 -050059}
60
61waf_do_install() {
Brad Bishop19323692019-04-05 15:28:33 -040062 (cd ${S} && ./waf install --destdir=${D})
Patrick Williamsc124f4f2015-09-15 14:41:29 -050063}
64
65EXPORT_FUNCTIONS do_configure do_compile do_install