Changes in tools/config.py [3f1a481:3ef901d0] in mainline


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/config.py

    r3f1a481 r3ef901d0  
    4242import random
    4343
    44 ARGPOS_RULES = 1
    45 ARGPOS_PRESETS_DIR = 2
    46 ARGPOS_CHOICE = 3
    47 ARGPOS_PRESET = 4
    48 ARGPOS_MASK_PLATFORM = 3
    49 
    50 RULES_FILE = sys.argv[ARGPOS_RULES]
     44RULES_FILE = sys.argv[1]
    5145MAKEFILE = 'Makefile.config'
    5246MACROS = 'config.h'
    53 PRESETS_DIR = sys.argv[ARGPOS_PRESETS_DIR]
     47PRESETS_DIR = 'defaults'
    5448
    5549class BinaryOp:
     
    538532
    539533        try:
    540                 version = subprocess.Popen(['git', '-C', os.path.dirname(RULES_FILE), 'log', '-1', '--pretty=%h'], stdout = subprocess.PIPE).communicate()[0].decode().strip()
     534                version = subprocess.Popen(['git', 'log', '-1', '--pretty=%h'], stdout = subprocess.PIPE).communicate()[0].decode().strip()
    541535                sys.stderr.write("ok\n")
    542536        except:
     
    592586        outmk.write('TIMESTAMP_UNIX = %d\n' % timestamp_unix)
    593587        outmc.write('#define TIMESTAMP_UNIX %d\n' % timestamp_unix)
    594         defs += ' "-DTIMESTAMP_UNIX=%d"' % timestamp_unix
     588        defs += ' "-DTIMESTAMP_UNIX=%d"\n' % timestamp_unix
    595589
    596590        outmk.write('TIMESTAMP = %s\n' % timestamp)
    597591        outmc.write('#define TIMESTAMP %s\n' % timestamp)
    598         defs += ' "-DTIMESTAMP=%s"' % timestamp
    599 
    600         outmk.write('%s\n' % defs)
     592        defs += ' "-DTIMESTAMP=%s"\n' % timestamp
     593
     594        outmk.write(defs)
    601595
    602596        outmk.close()
     
    682676        parse_rules(RULES_FILE, rules)
    683677
    684         if len(sys.argv) > ARGPOS_CHOICE:
    685                 choice = sys.argv[ARGPOS_CHOICE]
    686         else:
    687                 choice = None
    688 
    689         if len(sys.argv) > ARGPOS_PRESET:
    690                 preset = sys.argv[ARGPOS_PRESET]
    691         else:
    692                 preset = None
    693 
    694         mask_platform = (len(sys.argv) > ARGPOS_MASK_PLATFORM and sys.argv[ARGPOS_MASK_PLATFORM] == "--mask-platform")
    695 
    696678        # Input configuration file can be specified on command line
    697679        # otherwise configuration from previous run is used.
    698         if preset is not None:
    699                 profile = parse_profile_name(preset)
     680        if len(sys.argv) >= 4:
     681                profile = parse_profile_name(sys.argv[3])
    700682                read_presets(profile, config)
    701683        elif os.path.exists(MAKEFILE):
     
    703685
    704686        # Default mode: check values and regenerate configuration files
    705         if choice == 'default':
     687        if (len(sys.argv) >= 3) and (sys.argv[2] == 'default'):
    706688                if (infer_verify_choices(config, rules)):
    707689                        preprocess_config(config, rules)
     
    711693        # Hands-off mode: check values and regenerate configuration files,
    712694        # but no interactive fallback
    713         if choice == 'hands-off':
    714                 # We deliberately test this because we do not want
     695        if (len(sys.argv) >= 3) and (sys.argv[2] == 'hands-off'):
     696                # We deliberately test sys.argv >= 4 because we do not want
    715697                # to read implicitly any possible previous run configuration
    716                 if preset is None:
     698                if len(sys.argv) < 4:
    717699                        sys.stderr.write("Configuration error: No presets specified\n")
    718700                        return 2
     
    727709
    728710        # Check mode: only check configuration
    729         if choice == 'check':
     711        if (len(sys.argv) >= 3) and (sys.argv[2] == 'check'):
    730712                if infer_verify_choices(config, rules):
    731713                        return 0
     
    733715
    734716        # Random mode
    735         if choice == 'random':
     717        if (len(sys.argv) == 3) and (sys.argv[2] == 'random'):
    736718                ok = random_choices(config, rules, 0)
    737719                if not ok:
     
    759741                        options = []
    760742                        opt2row = {}
    761                         cnt = 0
    762 
    763                         if not mask_platform:
    764                                 cnt += 1
    765                                 options.append("  --- Load preconfigured defaults ... ")
     743                        cnt = 1
     744
     745                        options.append("  --- Load preconfigured defaults ... ")
    766746
    767747                        for rule in rules:
     
    770750                                if cond and not cond.evaluate(config):
    771751                                        continue
    772 
    773                                 if mask_platform and (varname == "PLATFORM" or varname == "MACHINE" or varname == "COMPILER"):
    774                                         rule = varname, vartype, "(locked) " + name, choices, cond
    775752
    776753                                if varname == selname:
     
    820797                                        continue
    821798
    822                         if value == 0 and not mask_platform:
     799                        if value == 0:
    823800                                profile = choose_profile(PRESETS_DIR, MAKEFILE, screen, config)
    824801                                if profile != None:
     
    837814                        else:
    838815                                value = config[selname]
    839 
    840                         if mask_platform and (selname == "PLATFORM" or selname == "MACHINE" or selname == "COMPILER"):
    841                                         continue
    842816
    843817                        if seltype == 'choice':
Note: See TracChangeset for help on using the changeset viewer.