blob: f4d4c1b123f3988531eef7696b429f0b0501a8bc [file] [log] [blame]
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001#!/usr/bin/env python3
Patrick Williamsc124f4f2015-09-15 14:41:29 -05002# ex:ts=4:sw=4:sts=4:et
3# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
4#
5# Copyright (C) 2012 Wind River Systems, Inc.
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License version 2 as
9# published by the Free Software Foundation.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License along
17# with this program; if not, write to the Free Software Foundation, Inc.,
18# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20#
21# This is used for dumping the bb_cache.dat, the output format is:
22# recipe_path PN PV PACKAGES
23#
24import os
25import sys
26import warnings
27
28# For importing bb.cache
29sys.path.insert(0, os.path.join(os.path.abspath(os.path.dirname(sys.argv[0])), '../lib'))
30from bb.cache import CoreRecipeInfo
31
Patrick Williamsc0f7c042017-02-23 20:41:17 -060032import pickle as pickle
Patrick Williamsc124f4f2015-09-15 14:41:29 -050033
34def main(argv=None):
35 """
36 Get the mapping for the target recipe.
37 """
38 if len(argv) != 1:
Patrick Williamsc0f7c042017-02-23 20:41:17 -060039 print("Error, need one argument!", file=sys.stderr)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050040 return 2
41
42 cachefile = argv[0]
43
44 with open(cachefile, "rb") as cachefile:
45 pickled = pickle.Unpickler(cachefile)
46 while cachefile:
47 try:
48 key = pickled.load()
49 val = pickled.load()
50 except Exception:
51 break
52 if isinstance(val, CoreRecipeInfo) and (not val.skipped):
53 pn = val.pn
54 # Filter out the native recipes.
55 if key.startswith('virtual:native:') or pn.endswith("-native"):
56 continue
57
58 # 1.0 is the default version for a no PV recipe.
Patrick Williamsc0f7c042017-02-23 20:41:17 -060059 if "pv" in val.__dict__:
Patrick Williamsc124f4f2015-09-15 14:41:29 -050060 pv = val.pv
61 else:
62 pv = "1.0"
63
64 print("%s %s %s %s" % (key, pn, pv, ' '.join(val.packages)))
65
66if __name__ == "__main__":
67 sys.exit(main(sys.argv[1:]))
68