OpenCores
URL https://opencores.org/ocsvn/radiohdl/radiohdl/trunk

Subversion Repositories radiohdl

[/] [radiohdl/] [trunk/] [base/] [export_hdllib_variables.py] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 danv
#!/usr/bin/env python
2
###############################################################################
3
#
4
# Copyright (C) 2018
5
# ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
6
# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
7
#
8
# This program is free software: you can redistribute it and/or modify
9
# it under the terms of the GNU General Public License as published by
10
# the Free Software Foundation, either version 3 of the License, or
11
# (at your option) any later version.
12
#
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
# GNU General Public License for more details.
17
#
18
# You should have received a copy of the GNU General Public License
19
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
#
21
# $Id: export_hdllib_variables.py 18844 2018-08-29 12:41:53Z overeem $
22
#
23
###############################################################################
24
import sys
25
import os
26
from os.path import expandvars, dirname, basename
27
from argparse import ArgumentParser
28
from hdl_configfile import HdlBuildset
29
from hdl_configtree import HdlLibTree
30
 
31
if __name__ == '__main__':
32
    # setup parser and parse the arguments.
33
    argparser = ArgumentParser(description='Options and arguments for exporting hdllib keys values')
34
    argparser.add_argument('buildset', help="Filename like 'hdl_buildset_<boardtype>.cfg'")
35
    argparser.add_argument('libname',  help="Name of the library to search in.")
36
    argparser.add_argument('keys',     help="Name of variable(s) to export.")
37
    args = argparser.parse_args()
38
 
39
    # read the buildset file
40
    full_buildsetfile_name = expandvars("${HDL_CONFIG_DIR}/hdl_buildset_%s.cfg" % (args.buildset))
41
    buildset_info = HdlBuildset(full_buildsetfile_name)
42
    buildset_info.resolve_key_references()
43
 
44
    # find out where the hdllibs files are and read them in
45
    root_dirs = [ expandvars(rootdir) for rootdir in buildset_info.lib_root_dirs.replace("\t"," ").split(" ")
46
                                                     if rootdir != '' ]
47
    lib_tree = HdlLibTree(rootdirs=root_dirs, filename="hdllib.cfg")
48
    for key in args.keys.split(','):
49
        print "export {}='{}'\n".format(key.lower(),
50
                os.path.expandvars(lib_tree.configfiles[args.libname].get_value(key=key, must_exist=True)))
51
 
52
 

powered by: WebSVN 2.1.0

© copyright 1999-2019 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.