summaryrefslogtreecommitdiffstats
path: root/classes/amend.bbclass
blob: fb67b4ebb1386fc0242345114ad2362fb1214326 (plain)
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
# Allows tweaks to be amended to a recipe via a .inc in its FILESPATH
#
# Simply drop amend.inc into an appropriate place in a recipe's FILESPATH and
# it'll be parsed in after the recipe itself is.
#
# Copyright (c) 2009 MontaVista Software, Inc.  All rights reserved.
#
# Released under the MIT license (see LICENSE.MIT for the terms)

python () {
    import bb, os

    filespath = d.getVar("FILESPATH", 1).split(":")
    amendfiles = [os.path.join(fpath, "amend.inc")
                  for fpath in filespath]

    # Adding all amend.incs that can exist to the __depends, to ensure that
    # creating one of them invalidates the bitbake cache.  Note that it
    # requires a fix in bitbake.  Without the bitbake fix, the cache will be
    # completely invalidated on every bitbake execution.
    depends = d.getVar("__depends", 0) or []
    d.setVar("__depends", depends + [(file, 0) for file in amendfiles if not os.path.exists(file)])

    # Make sure we don't parse the same amend.inc file more than once, if
    # there are duplicates in FILESPATH
    seen = set()

    for file in amendfiles:
        if os.path.exists(file):
            if file not in seen:
                bb.parse.handle(file, d, 1)
                seen.add(file)
}