Changes in tools/config.py [3f1a481:3ef901d0] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/config.py
r3f1a481 r3ef901d0 42 42 import random 43 43 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] 44 RULES_FILE = sys.argv[1] 51 45 MAKEFILE = 'Makefile.config' 52 46 MACROS = 'config.h' 53 PRESETS_DIR = sys.argv[ARGPOS_PRESETS_DIR]47 PRESETS_DIR = 'defaults' 54 48 55 49 class BinaryOp: … … 538 532 539 533 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() 541 535 sys.stderr.write("ok\n") 542 536 except: … … 592 586 outmk.write('TIMESTAMP_UNIX = %d\n' % timestamp_unix) 593 587 outmc.write('#define TIMESTAMP_UNIX %d\n' % timestamp_unix) 594 defs += ' "-DTIMESTAMP_UNIX=%d" ' % timestamp_unix588 defs += ' "-DTIMESTAMP_UNIX=%d"\n' % timestamp_unix 595 589 596 590 outmk.write('TIMESTAMP = %s\n' % timestamp) 597 591 outmc.write('#define TIMESTAMP %s\n' % timestamp) 598 defs += ' "-DTIMESTAMP=%s" ' % timestamp599 600 outmk.write( '%s\n' %defs)592 defs += ' "-DTIMESTAMP=%s"\n' % timestamp 593 594 outmk.write(defs) 601 595 602 596 outmk.close() … … 682 676 parse_rules(RULES_FILE, rules) 683 677 684 if len(sys.argv) > ARGPOS_CHOICE:685 choice = sys.argv[ARGPOS_CHOICE]686 else:687 choice = None688 689 if len(sys.argv) > ARGPOS_PRESET:690 preset = sys.argv[ARGPOS_PRESET]691 else:692 preset = None693 694 mask_platform = (len(sys.argv) > ARGPOS_MASK_PLATFORM and sys.argv[ARGPOS_MASK_PLATFORM] == "--mask-platform")695 696 678 # Input configuration file can be specified on command line 697 679 # 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]) 700 682 read_presets(profile, config) 701 683 elif os.path.exists(MAKEFILE): … … 703 685 704 686 # Default mode: check values and regenerate configuration files 705 if choice == 'default':687 if (len(sys.argv) >= 3) and (sys.argv[2] == 'default'): 706 688 if (infer_verify_choices(config, rules)): 707 689 preprocess_config(config, rules) … … 711 693 # Hands-off mode: check values and regenerate configuration files, 712 694 # but no interactive fallback 713 if choice == 'hands-off':714 # We deliberately test thisbecause we do not want695 if (len(sys.argv) >= 3) and (sys.argv[2] == 'hands-off'): 696 # We deliberately test sys.argv >= 4 because we do not want 715 697 # to read implicitly any possible previous run configuration 716 if preset is None:698 if len(sys.argv) < 4: 717 699 sys.stderr.write("Configuration error: No presets specified\n") 718 700 return 2 … … 727 709 728 710 # Check mode: only check configuration 729 if choice == 'check':711 if (len(sys.argv) >= 3) and (sys.argv[2] == 'check'): 730 712 if infer_verify_choices(config, rules): 731 713 return 0 … … 733 715 734 716 # Random mode 735 if choice == 'random':717 if (len(sys.argv) == 3) and (sys.argv[2] == 'random'): 736 718 ok = random_choices(config, rules, 0) 737 719 if not ok: … … 759 741 options = [] 760 742 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 ... ") 766 746 767 747 for rule in rules: … … 770 750 if cond and not cond.evaluate(config): 771 751 continue 772 773 if mask_platform and (varname == "PLATFORM" or varname == "MACHINE" or varname == "COMPILER"):774 rule = varname, vartype, "(locked) " + name, choices, cond775 752 776 753 if varname == selname: … … 820 797 continue 821 798 822 if value == 0 and not mask_platform:799 if value == 0: 823 800 profile = choose_profile(PRESETS_DIR, MAKEFILE, screen, config) 824 801 if profile != None: … … 837 814 else: 838 815 value = config[selname] 839 840 if mask_platform and (selname == "PLATFORM" or selname == "MACHINE" or selname == "COMPILER"):841 continue842 816 843 817 if seltype == 'choice':
Note:
See TracChangeset
for help on using the changeset viewer.