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