blob: 464564afa1de4b48262a47a1a3ab0e6c4cc243e9 [file] [log] [blame]
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001# avoids build breaks when using no-static-libs.inc
2DISABLE_STATIC = ""
3
Andrew Geissler4c19ea12020-10-27 13:52:24 -05004# What Python interpretter to use. Defaults to Python 3 but can be
5# overridden if required.
6WAF_PYTHON ?= "python3"
7
Brad Bishop19323692019-04-05 15:28:33 -04008B = "${WORKDIR}/build"
Andrew Geissler4c19ea12020-10-27 13:52:24 -05009do_configure[cleandirs] += "${B}"
Brad Bishop19323692019-04-05 15:28:33 -040010
Patrick Williams213cb262021-08-07 19:21:33 -050011EXTRA_OECONF:append = " ${PACKAGECONFIG_CONFARGS}"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050012
Andrew Geisslerf0343792020-11-18 10:42:21 -060013EXTRA_OEWAF_BUILD ??= ""
14# In most cases, you want to pass the same arguments to `waf build` and `waf
15# install`, but you can override it if necessary
16EXTRA_OEWAF_INSTALL ??= "${EXTRA_OEWAF_BUILD}"
17
Brad Bishopc342db32019-05-15 21:57:59 -040018def waflock_hash(d):
19 # Calculates the hash used for the waf lock file. This should include
20 # all of the user controllable inputs passed to waf configure. Note
21 # that the full paths for ${B} and ${S} are used; this is OK and desired
22 # because a change to either of these should create a unique lock file
23 # to prevent collisions.
24 import hashlib
25 h = hashlib.sha512()
26 def update(name):
27 val = d.getVar(name)
28 if val is not None:
29 h.update(val.encode('utf-8'))
30 update('S')
31 update('B')
32 update('prefix')
33 update('EXTRA_OECONF')
34 return h.hexdigest()
35
36# Use WAFLOCK to specify a separate lock file. The build is already
37# sufficiently isolated by setting the output directory, this ensures that
38# bitbake won't step on toes of any other configured context in the source
39# directory (e.g. if the source is coming from externalsrc and was previously
40# configured elsewhere).
41export WAFLOCK = ".lock-waf_oe_${@waflock_hash(d)}_build"
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000042BB_BASEHASH_IGNORE_VARS += "WAFLOCK"
Brad Bishopc342db32019-05-15 21:57:59 -040043
Brad Bishopd7bf8c12018-02-25 22:55:05 -050044python waf_preconfigure() {
Brad Bishop316dfdd2018-06-25 12:45:53 -040045 import subprocess
Brad Bishop316dfdd2018-06-25 12:45:53 -040046 subsrcdir = d.getVar('S')
Andrew Geissler4c19ea12020-10-27 13:52:24 -050047 python = d.getVar('WAF_PYTHON')
Brad Bishop316dfdd2018-06-25 12:45:53 -040048 wafbin = os.path.join(subsrcdir, 'waf')
49 try:
Andrew Geissler4c19ea12020-10-27 13:52:24 -050050 result = subprocess.check_output([python, wafbin, '--version'], cwd=subsrcdir, stderr=subprocess.STDOUT)
Brad Bishop316dfdd2018-06-25 12:45:53 -040051 version = result.decode('utf-8').split()[1]
Andrew Geissler595f6302022-01-24 19:11:47 +000052 if bb.utils.vercmp_string_op(version, "1.8.7", ">="):
Brad Bishop316dfdd2018-06-25 12:45:53 -040053 d.setVar("WAF_EXTRA_CONF", "--bindir=${bindir} --libdir=${libdir}")
54 except subprocess.CalledProcessError as e:
55 bb.warn("Unable to execute waf --version, exit code %d. Assuming waf version without bindir/libdir support." % e.returncode)
56 except FileNotFoundError:
57 bb.fatal("waf does not exist in %s" % subsrcdir)
Brad Bishopd7bf8c12018-02-25 22:55:05 -050058}
59
60do_configure[prefuncs] += "waf_preconfigure"
61
Patrick Williamsc124f4f2015-09-15 14:41:29 -050062waf_do_configure() {
Andrew Geissler4c19ea12020-10-27 13:52:24 -050063 (cd ${S} && ${WAF_PYTHON} ./waf configure -o ${B} --prefix=${prefix} ${WAF_EXTRA_CONF} ${EXTRA_OECONF})
Patrick Williamsc124f4f2015-09-15 14:41:29 -050064}
65
Brad Bishop316dfdd2018-06-25 12:45:53 -040066do_compile[progress] = "outof:^\[\s*(\d+)/\s*(\d+)\]\s+"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050067waf_do_compile() {
Andrew Geissler4c19ea12020-10-27 13:52:24 -050068 (cd ${S} && ${WAF_PYTHON} ./waf build ${@oe.utils.parallel_make_argument(d, '-j%d', limit=64)} ${EXTRA_OEWAF_BUILD})
Patrick Williamsc124f4f2015-09-15 14:41:29 -050069}
70
71waf_do_install() {
Andrew Geissler4c19ea12020-10-27 13:52:24 -050072 (cd ${S} && ${WAF_PYTHON} ./waf install --destdir=${D} ${EXTRA_OEWAF_INSTALL})
Patrick Williamsc124f4f2015-09-15 14:41:29 -050073}
74
75EXPORT_FUNCTIONS do_configure do_compile do_install