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 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 8 | def 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). |
| 31 | export WAFLOCK = ".lock-waf_oe_${@waflock_hash(d)}_build" |
| 32 | BB_HASHBASE_WHITELIST += "WAFLOCK" |
| 33 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 34 | python waf_preconfigure() { |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 35 | import subprocess |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 36 | from distutils.version import StrictVersion |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 37 | 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 Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | do_configure[prefuncs] += "waf_preconfigure" |
| 51 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 52 | waf_do_configure() { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 53 | (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] | 54 | } |
| 55 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 56 | do_compile[progress] = "outof:^\[\s*(\d+)/\s*(\d+)\]\s+" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 57 | waf_do_compile() { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 58 | (cd ${S} && ./waf build ${@oe.utils.parallel_make_argument(d, '-j%d', limit=64)}) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | waf_do_install() { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 62 | (cd ${S} && ./waf install --destdir=${D}) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | EXPORT_FUNCTIONS do_configure do_compile do_install |