Beispiel #1
0
def main():
    sys.stdout = Unbuffered(sys.stdout)
    try:
        parameters = CmdLine.analyse_cmdline(sys.argv)
        if len(parameters) == 0:
            print("Usage: "+ sys.argv[0] + " PROJECT BRANCH [CONFIGS...]\n")
            print("PROJECT: the name of a project to be compiled.")
            print("BRANCH: branch to select for compilation.")
            print("CONFIGS: list of configuration to compile - if ignored all configurations will be used")
            return
        
        begin = time.perf_counter()
        total = 0
        successful = 0
        successful_details = {}
        
        project_info = JsonInfo.load_project_info(parameters)
        
        print("Compiling project \""+parameters[0]+"\" on branch \""+parameters[1]+"\".")
        
        selected_configs=select_configurations(project_info, parameters[2])
        print("The following configurations have being selected:")
        for machine, dic in selected_configs.items():
            configlist = ""
            for config in dic:
                configlist = configlist + " " + config
            print("- for machine \""+machine+"\":"+configlist)
        print()
        
        print("Starting compilation process...")
        for machine, dic in selected_configs.items():
            print("- Compiling on machine \""+machine+"\"...")
            print("  -> Starting machine")
            if not Machine.start_machine(project_info["machines"], machine):
                print("     FAILED to launch machine")
                for config, desc in dic.items():
                    total = total+1
                    successful_details[config] = (False, 0)
                continue
            print("  -> Testing connection")
            if not Machine.test_connection_to_machine(project_info["machines"], machine):
                print("     FAILED to connect to machine")
                for config, desc in dic.items():
                    total = total+1
                    successful_details[config] = (False, 0)
            else:
                for config, desc in dic.items():
                    print("  -> Compiling configuration \""+config+"\"...")
                    begin_local = time.perf_counter()
                    successful_local = Machine.compile_config(project_info["machines"], desc, parameters[1])
                    end_local = time.perf_counter()
                    total = total + 1
                    successful_details[config] = (successful_local, end_local-begin_local)
                    if successful_local:
                        successful = successful + 1
            
            print("  -> Stopping machine")
            if not Machine.stop_machine(project_info["machines"], machine):
                print("     FAILED to stop machine")
                print("     To prevent possible multiple vm execution, stopping compilation sequence")
                break
        
        end = time.perf_counter()
        ellapsed = end-begin
        
        print()
        print("Results:")
        for config, info in successful_details.items():
            if info[0]:
                text = "OK"
            else:
                text = "FAILED"
            print("- " + config + ": " + text + " ("+format_time(info[1])+")")
        print()
        
        print(str(successful)+"/"+str(total)+" successful builds for a total time of "+format_time(ellapsed) + " (" +str(ellapsed)+" seconds)")
        
    except Exception as exc:
        print(exc)
        return