aboutsummaryrefslogtreecommitdiff
path: root/lib/targetdb.exp
blob: c92573ded3b239e2511bf1202c093819d545d5e3 (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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
# 2002, 2003, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
#
# This file is part of DejaGnu.
#
# DejaGnu is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# DejaGnu is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with DejaGnu; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.

# Searches in the appropriate place (the board_info array) for the specified
# information.
#
proc board_info { machine op args } {
    global target_info
    global board_info

    verbose "board_info $machine $op $args" 3

    if {[info exists target_info($machine,name)]} {
	set machine $target_info($machine,name)
    }
    if { $op == "exists" } {
	if { [llength $args] == 0 } {
	    return [info exists board_info($machine,name)]
	} else {
	    return [info exists board_info($machine,[lindex $args 0])]
	}
    }
    if { [llength $args] == 0 } {
	verbose "getting $machine $op" 3
	if {[info exists board_info($machine,$op)]} {
	    return $board_info($machine,$op)
	} else {
	    return ""
	}
    }
    return ""
}

proc target_info { op args } {
    return [eval "board_info target \"$op\" $args"]
}

proc host_info { op args } {
    return [eval "board_info host \"$op\" $args"]
}

# Fill in ENTRY with VALUE for the current board being defined.
#
proc set_board_info { entry value } {
    global board_info board

    if {![info exists board_info($board,$entry)]} {
	set board_info($board,$entry) $value
    }
}

#
# Add VALUE to ENTRY for the current board being defined.
#
proc add_board_info { entry value } {
    global board_info board

    lappend board_info($board,$entry) $value
}

# Fill in ENTRY with VALUE for the current target.
#
proc set_currtarget_info { entry value } {
    global board_info

    set board [target_info name]

    if {![info exists board_info($board,$entry)]} {
	set board_info($board,$entry) $value
    }
}

# Unset ENTRY for the current board being defined.
#
proc unset_board_info { entry } {
    global board_info board

    if {[info exists board_info($board,$entry)]} {
	unset board_info($board,$entry)
    }
}

# Unset ENTRY for the current board being defined.
#
proc unset_currtarget_info { entry } {
    global board_info

    set board [target_info name]

    if {[info exists board_info($board,$entry)]} {
	unset board_info($board,$entry)
    }
}