Exemple #1
0
def _main(blade_path, argv):
    """The main entry of blade."""
    command, options, targets = command_line.parse(argv)
    setup_console(options)

    root_dir, working_dir = get_source_dirs()
    if root_dir != working_dir:
        # This message is required by vim quickfix mode if pwd is changed during
        # the building, DO NOT change the pattern of this message.
        if options.verbosity != 'quiet':
            print("Blade: Entering directory `%s'" % root_dir)
        os.chdir(root_dir)

    load_config(options, root_dir)
    adjust_config_by_options(config, options)
    if _check_error_log('config'):
        return 1

    if not targets:
        targets = ['.']
    targets = target_pattern.normalize_list(targets, working_dir)

    build_dir = setup_build_dir(options)
    setup_log(build_dir, options)

    generate_scm(build_dir)

    lock_file_fd = lock_workspace(build_dir)
    try:
        run_fn = run_subcommand_profile if options.profiling else run_subcommand
        return run_fn(command, options, targets, blade_path, root_dir,
                      build_dir, working_dir)
    finally:
        unlock_workspace(lock_file_fd)
Exemple #2
0
def _main(blade_path, argv):
    """The main entry of blade."""
    command, options, targets = command_line.parse(argv)
    setup_console(options)

    ws = workspace.initialize(options)
    ws.switch_to_root_dir()
    load_config(options, ws.root_dir())

    adjust_config_by_options(config, options)
    if _check_error_log('config'):
        return 1

    if not targets:
        targets = ['.']
    targets = target_pattern.normalize_list(targets, ws.working_dir())

    ws.setup_build_dir()

    lock_id = ws.lock()
    try:
        run_fn = run_subcommand_profile if options.profiling else run_subcommand
        return run_fn(blade_path, command, options, ws, targets)
    finally:
        ws.unlock(lock_id)
Exemple #3
0
 def _test(self):
     """Run tests."""
     exclude_tests = []
     if self.__options.exclude_tests:
         exclude_tests = target_pattern.normalize_list(
             self.__options.exclude_tests.split(','), self.__working_dir)
     test_runner = TestRunner(self.__options, self.__target_database,
                              self.__direct_targets,
                              self.__expanded_command_targets,
                              self.__build_targets, exclude_tests,
                              self.test_jobs_num())
     return test_runner.run()
Exemple #4
0
 def _parse_qyery_path_to(self):
     """Parse the `--path-to` command line argument"""
     if not self.__options.query_path_to:
         return set()
     result = set()
     for id in target_pattern.normalize_list(
             self.__options.query_path_to.split(','), self.__working_dir):
         if id not in self.__target_database:
             console.fatal(
                 'Invalid argument: "--path-to=%s", target "%s" does not exist'
                 % (self.__options.query_path_to, id))
             result.add(id)
     return result
 def testNormalizeList(self):
     self.assertEqual(['foo:...', 'foo:*'],
                      target_pattern.normalize_list(['foo...', 'foo'], '.'))