Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1 | # avoids build breaks when using no-static-libs.inc |
| 2 | DISABLE_STATIC = "" |
| 3 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 4 | B = "${WORKDIR}/build" |
| 5 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 6 | EXTRA_OECONF_append = " ${PACKAGECONFIG_CONFARGS}" |
| 7 | |
Andrew Geissler | f034379 | 2020-11-18 10:42:21 -0600 | [diff] [blame] | 8 | EXTRA_OEWAF_BUILD ??= "" |
| 9 | # In most cases, you want to pass the same arguments to `waf build` and `waf |
| 10 | # install`, but you can override it if necessary |
| 11 | EXTRA_OEWAF_INSTALL ??= "${EXTRA_OEWAF_BUILD}" |
| 12 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 13 | def waflock_hash(d): |
| 14 | # Calculates the hash used for the waf lock file. This should include |
| 15 | # all of the user controllable inputs passed to waf configure. Note |
| 16 | # that the full paths for ${B} and ${S} are used; this is OK and desired |
| 17 | # because a change to either of these should create a unique lock file |
| 18 | # to prevent collisions. |
| 19 | import hashlib |
| 20 | h = hashlib.sha512() |
| 21 | def update(name): |
| 22 | val = d.getVar(name) |
| 23 | if val is not None: |
| 24 | h.update(val.encode('utf-8')) |
| 25 | update('S') |
| 26 | update('B') |
| 27 | update('prefix') |
| 28 | update('EXTRA_OECONF') |
| 29 | return h.hexdigest() |
| 30 | |
| 31 | # Use WAFLOCK to specify a separate lock file. The build is already |
| 32 | # sufficiently isolated by setting the output directory, this ensures that |
| 33 | # bitbake won't step on toes of any other configured context in the source |
| 34 | # directory (e.g. if the source is coming from externalsrc and was previously |
| 35 | # configured elsewhere). |
| 36 | export WAFLOCK = ".lock-waf_oe_${@waflock_hash(d)}_build" |
| 37 | BB_HASHBASE_WHITELIST += "WAFLOCK" |
| 38 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 39 | python waf_preconfigure() { |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 40 | import subprocess |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 41 | from distutils.version import StrictVersion |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 42 | subsrcdir = d.getVar('S') |
| 43 | wafbin = os.path.join(subsrcdir, 'waf') |
| 44 | try: |
| 45 | result = subprocess.check_output([wafbin, '--version'], cwd=subsrcdir, stderr=subprocess.STDOUT) |
| 46 | version = result.decode('utf-8').split()[1] |
| 47 | if StrictVersion(version) >= StrictVersion("1.8.7"): |
| 48 | d.setVar("WAF_EXTRA_CONF", "--bindir=${bindir} --libdir=${libdir}") |
| 49 | except subprocess.CalledProcessError as e: |
| 50 | bb.warn("Unable to execute waf --version, exit code %d. Assuming waf version without bindir/libdir support." % e.returncode) |
| 51 | except FileNotFoundError: |
| 52 | bb.fatal("waf does not exist in %s" % subsrcdir) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | do_configure[prefuncs] += "waf_preconfigure" |
| 56 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 57 | waf_do_configure() { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 58 | (cd ${S} && ./waf configure -o ${B} --prefix=${prefix} ${WAF_EXTRA_CONF} ${EXTRA_OECONF}) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 59 | } |
| 60 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 61 | do_compile[progress] = "outof:^\[\s*(\d+)/\s*(\d+)\]\s+" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 62 | waf_do_compile() { |
Andrew Geissler | f034379 | 2020-11-18 10:42:21 -0600 | [diff] [blame] | 63 | (cd ${S} && ./waf build ${@oe.utils.parallel_make_argument(d, '-j%d', limit=64)} ${EXTRA_OEWAF_BUILD}) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | waf_do_install() { |
Andrew Geissler | f034379 | 2020-11-18 10:42:21 -0600 | [diff] [blame] | 67 | (cd ${S} && ./waf install --destdir=${D} ${EXTRA_OEWAF_INSTALL}) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | EXPORT_FUNCTIONS do_configure do_compile do_install |