()
| 41 | """ |
| 42 | |
| 43 | def main(): |
| 44 | o = options.Options(optspec) |
| 45 | (opt, flags, extra) = o.parse(sys.argv[1:]) |
| 46 | |
| 47 | targets = extra |
| 48 | |
| 49 | if opt.version: |
| 50 | from . import version |
| 51 | print version.TAG |
| 52 | sys.exit(0) |
| 53 | if opt.debug: |
| 54 | os.environ['REDO_DEBUG'] = str(opt.debug or 0) |
| 55 | if opt.verbose: |
| 56 | os.environ['REDO_VERBOSE'] = str(opt.verbose) |
| 57 | if opt.xtrace: |
| 58 | os.environ['REDO_XTRACE'] = str(opt.xtrace) |
| 59 | if opt.keep_going: |
| 60 | os.environ['REDO_KEEP_GOING'] = '1' |
| 61 | if opt.shuffle: |
| 62 | os.environ['REDO_SHUFFLE'] = '1' |
| 63 | if opt.debug_locks: |
| 64 | os.environ['REDO_DEBUG_LOCKS'] = '1' |
| 65 | if opt.debug_pids: |
| 66 | os.environ['REDO_DEBUG_PIDS'] = '1' |
| 67 | # These might get overridden in subprocesses in builder.py |
| 68 | def _set_defint(name, val): |
| 69 | os.environ[name] = os.environ.get(name, str(int(val))) |
| 70 | _set_defint('REDO_LOG', opt.log) |
| 71 | _set_defint('REDO_PRETTY', opt.pretty) |
| 72 | _set_defint('REDO_COLOR', opt.color) |
| 73 | |
| 74 | try: |
| 75 | state.init(targets) |
| 76 | if env.is_toplevel and not targets: |
| 77 | targets = ['all'] |
| 78 | j = atoi(opt.jobs) |
| 79 | if env.is_toplevel and (env.v.LOG or j > 1): |
| 80 | builder.close_stdin() |
| 81 | if env.is_toplevel and env.v.LOG: |
| 82 | builder.start_stdin_log_reader( |
| 83 | status=opt.status, details=opt.details, |
| 84 | pretty=env.v.PRETTY, color=env.v.COLOR, |
| 85 | debug_locks=opt.debug_locks, debug_pids=opt.debug_pids) |
| 86 | else: |
| 87 | logs.setup( |
| 88 | tty=sys.stderr, parent_logs=env.v.LOG, |
| 89 | pretty=env.v.PRETTY, color=env.v.COLOR) |
| 90 | if (env.is_toplevel or j > 1) and env.v.LOCKS_BROKEN: |
| 91 | warn('detected broken fcntl locks; parallelism disabled.\n') |
| 92 | warn(' ...details: https://github.com/Microsoft/WSL/issues/1927\n') |
| 93 | if j > 1: |
| 94 | j = 1 |
| 95 | |
| 96 | for t in targets: |
| 97 | if os.path.exists(t): |
| 98 | f = state.File(name=t) |
| 99 | if not f.is_generated: |
| 100 | warn(('%s: exists and not marked as generated; ' + |
no test coverage detected