Changeset 9371c30 in mainline for tools


Ignore:
Timestamp:
2005-12-06T20:53:03Z (20 years ago)
Author:
Ondrej Palkovsky <ondrap@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
36e7b6c3
Parents:
090e7ea1
Message:

Completely reworked configuration system.

Location:
tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tools/build

    r090e7ea1 r9371c30  
    33function syntax {
    44        echo "Syntax:"
    5         echo " build.<arch> [-compiler <compiler>] [-cpu <cpu>] [-machine <machine>]"
    6         echo
    7         echo "<arch>     ... amd64, ia32, ia64, mips32, ppc32, sparc64"
    8         echo "<compiler> ... native, *cross"
    9         echo "<cpu>      ... for ia32: athlon-xp, athlon-mp, pentium3, *pentium4, prescott"
    10         echo "<machine>  ... for mips32: *msim, msim4kc, simics, lgxemul, bgxemul, indy"
     5        echo " build "
    116        echo
    127}
    13 
    14 ARCH="`basename "$0" | awk -F. '{ if (NF > 1) print \$NF }'`"
    15 if [ -z "$ARCH" ]; then
    16         syntax
    17         exit 1
    18 fi
    198
    209ARGS=""
    2110while [ "$#" -gt 0 ]; do
    2211        case "$1" in
    23                 -compiler)
    24                         if [ -z "$2" ]; then
    25                                 syntax
    26                                 exit 1
    27                         fi
    28                         ARGS="$ARGS COMPILER=$2"
    29                         shift
    30                         ;;
    31                 -cpu)
    32                         if [ -z "$2" ]; then
    33                                 syntax
    34                                 exit 1
    35                         fi
    36                         ARGS="$ARGS CPU=$2"
    37                         shift
    38                         ;;
    39                 -machine)
    40                         if [ -z "$2" ]; then
    41                                 syntax
    42                                 exit 1
    43                         fi
    44                         ARGS="$ARGS MACHINE=$2"
    45                         shift
    46                         ;;
    4712                *)
    4813                        syntax
     
    6126fi
    6227
    63 tools/config.py $ARCH default
    64 make all "ARCH=$ARCH" "TAG=$TAG" $ARGS
     28tools/config.py default
     29make all "TAG=$TAG" $ARGS
  • tools/config.py

    r090e7ea1 r9371c30  
    187187
    188188def check_condition(text, defaults):
    189     "Check that the condition specified on input line is True"
    190     result = False
     189    result = True
     190    conds = text.split('&')
     191    for cond in conds:
     192        if cond.startswith('(') and cond.endswith(')'):
     193            cond = cond[1:-1]
     194        if not check_dnf(cond, defaults):
     195            return False
     196    return True
     197
     198def check_dnf(text, defaults):
     199    """
     200    Check that the condition specified on input line is True
     201
     202    only CNF is supported
     203    """
    191204    conds = text.split('|')
    192205    for cond in conds:
    193         condname,condval = cond.split('=')
     206        res = re.match(r'^(.*?)(!?=)(.*)$', cond)
     207        if not res:
     208            raise RuntimeError("Invalid condition: %s" % cond)
     209        condname = res.group(1)
     210        oper = res.group(2)
     211        condval = res.group(3)
    194212        if not defaults.has_key(condname):
    195213            raise RuntimeError("Condition var %s does not exist: %s" % \
    196                                (condname,line))
    197         # None means wildcard
    198         if defaults[condname] is None:
     214                               (condname,text))
     215
     216        if oper=='=' and  condval == defaults[condname]:
    199217            return True
    200         if  condval == defaults[condname]:
     218        if oper == '!=' and condval != defaults[condname]:
    201219            return True
    202220    return False
     
    214232    default = None
    215233    choices = []
    216     for line in f:       
     234    for line in f:
     235        if line.startswith('%'):
     236            res = re.match(r'^%\s*(?:\[(.*?)\])?\s*(.*)$', line)
     237            if not res:
     238                raise RuntimeError('Invalid command: %s' % line)
     239            if res.group(1):
     240                if not check_condition(res.group(1), defaults):
     241                    continue
     242            args = res.group(2).strip().split(' ')
     243            cmd = args[0].lower()
     244            args = args[1:]
     245            if cmd == 'askdefault':
     246                if isinstance(dlg, DefaultDialog):
     247                    continue
     248                res = dlg.noyes('Change kernel configuration')
     249                if res == 'n':
     250                    dlg = DefaultDialog(dlg)
     251            elif cmd == 'saveas':
     252                outf.write('%s = %s\n' % (args[1],defaults[args[0]]))
     253               
     254            continue
     255           
    217256        if line.startswith('!'):
    218257            # Ask a question
     
    229268                    if default is not None:
    230269                        outf.write('#!# %s = %s\n' % (varname, default))
     270                    # Clear cumulated values
     271                    comment = ''
     272                    default = None
     273                    choices = []
    231274                    continue
    232275
     
    278321
    279322def main():
    280     defaults = {'ARCH':None}
     323    defaults = {}
    281324    try:
    282325        dlg = Dialog()
     
    286329    # Default run will update the configuration file
    287330    # with newest options
    288     if len(sys.argv) >= 2:
    289         defaults['ARCH'] = sys.argv[1]
    290     if len(sys.argv) == 3 and sys.argv[2]=='default':
     331    if len(sys.argv) == 2 and sys.argv[1]=='default':
    291332        dlg = DefaultDialog(dlg)
    292333
Note: See TracChangeset for help on using the changeset viewer.