def run_subcommand(command, options, targets, blade_path, build_dir): if command == 'query' and options.depended: targets = ['.:...'] build_manager.initialize(targets, blade_path, _WORKING_DIR, build_dir, _BLADE_ROOT_DIR, options, command) # Build the targets build_manager.instance.load_targets() if options.stop_after == 'load': return 0 build_manager.instance.analyze_targets() if options.stop_after == 'analyze': return 0 build_manager.instance.generate() if options.stop_after == 'generate': return 0 # Switch case due to different sub command action = { 'build': build, 'run': run, 'test': test, 'clean': clean, 'query': query }[command] try: returncode = action(options) finally: clear_build_script() return returncode
def run_subcommand(command, options, targets, blade_path, build_dir): """Run particular commands before loading""" # The 'dump' command is special, some kind of dump items should be ran before loading. if command == 'dump' and options.dump_config: output_file_name = os.path.join(_WORKING_DIR, options.dump_to_file) config.dump(output_file_name) return _check_error_log('dump') load_targets = targets if command == 'query' and options.dependents: # In query dependents mode, we must load all targets in workspace to get a whole view load_targets = ['.:...'] build_manager.initialize(targets, load_targets, blade_path, _WORKING_DIR, build_dir, _BLADE_ROOT_DIR, options, command) # Build the targets build_manager.instance.load_targets() if _check_error_log('load'): return 1 if options.stop_after == 'load': return 0 build_manager.instance.analyze_targets() if _check_error_log('analyze'): return 1 if options.stop_after == 'analyze': return 0 build_manager.instance.generate() if _check_error_log('generate'): return 1 if options.stop_after == 'generate': return 0 # Switch case due to different sub command action = { 'build': build, 'clean': clean, 'dump': dump, 'query': query, 'run': run, 'test': test, }[command] returncode = action(options) if returncode != 0: return returncode return _check_error_log(command)
def run_subcommand(blade_path, command, options, ws, targets): """Run particular subcommands.""" # The 'dump' command is special, some kind of dump items should be ran before loading. if command == 'dump' and options.dump_config: output_file_name = os.path.join(ws.working_dir(), options.dump_to_file) config.dump(output_file_name) return _check_error_log('dump') builder = build_manager.initialize(blade_path, command, options, ws, targets) # Prepare the targets stages = [ ('load', builder.load_targets), ('analyze', builder.analyze_targets), ('generate', builder.generate), ] for stage, action in stages: action() if _check_error_log(stage): return 1 if options.stop_after == stage: return 0 # Run sub command returncode = getattr(builder, command)() if returncode != 0: return returncode return _check_error_log(command)
def run_subcommand(command, options, targets, blade_path, build_dir): """Run particular commands before loading""" # The 'dump' command is special, some kind of dump items should be ran before loading. if command == 'dump' and options.dump_config: output_file_name = os.path.join(_WORKING_DIR, options.dump_to_file) config.dump(output_file_name) return 0 load_targets = targets if command == 'query' and options.dependents: # In query dependents mode, we must load all targets in workspace to get a whole view load_targets = ['.:...'] build_manager.initialize(targets, load_targets, blade_path, _WORKING_DIR, build_dir, _BLADE_ROOT_DIR, options, command) # Build the targets build_manager.instance.load_targets() if options.stop_after == 'load': return 0 build_manager.instance.analyze_targets() if options.stop_after == 'analyze': return 0 build_manager.instance.generate() if options.stop_after == 'generate': return 0 # Switch case due to different sub command action = { 'build': build, 'clean': clean, 'dump': dump, 'query': query, 'run': run, 'test': test, }[command] try: returncode = action(options) finally: clear_build_script() return returncode