blob: e1f23090b995edbb487329e36e0ca15cd20771e8 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001#!/usr/bin/env python
2# 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
32import cPickle as pickle
33
34def main(argv=None):
35 """
36 Get the mapping for the target recipe.
37 """
38 if len(argv) != 1:
39 print >>sys.stderr, "Error, need one argument!"
40 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.
59 if val.__dict__.has_key("pv"):
60 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