Esempio n. 1
0
    def setup_legacy_graph(pants_ignore_patterns,
                           workdir,
                           build_root=None,
                           native=None,
                           symbol_table_cls=None,
                           build_ignore_patterns=None,
                           exclude_target_regexps=None,
                           subproject_roots=None):
        """Construct and return the components necessary for LegacyBuildGraph construction.

    :param list pants_ignore_patterns: A list of path ignore patterns for FileSystemProjectTree,
                                       usually taken from the '--pants-ignore' global option.
    :param str workdir: The pants workdir.
    :param str build_root: A path to be used as the build root. If None, then default is used.
    :param Native native: An instance of the native-engine subsystem.
    :param SymbolTable symbol_table_cls: A SymbolTable class to use for build file parsing, or
                                         None to use the default.
    :param list build_ignore_patterns: A list of paths ignore patterns used when searching for BUILD
                                       files, usually taken from the '--build-ignore' global option.
    :param list exclude_target_regexps: A list of regular expressions for excluding targets.
    :param list subproject_roots: Paths that correspond with embedded build roots
                                  under the current build root.
    :returns: A tuple of (scheduler, engine, symbol_table_cls, build_graph_cls).
    """

        build_root = build_root or get_buildroot()
        scm = get_scm()
        symbol_table_cls = symbol_table_cls or LegacySymbolTable

        project_tree = FileSystemProjectTree(build_root, pants_ignore_patterns)

        # Register "literal" subjects required for these tasks.
        # TODO: Replace with `Subsystems`.
        address_mapper = AddressMapper(
            symbol_table_cls=symbol_table_cls,
            parser_cls=LegacyPythonCallbacksParser,
            build_ignore_patterns=build_ignore_patterns,
            exclude_target_regexps=exclude_target_regexps,
            subproject_roots=subproject_roots)

        # Load the native backend.
        native = native or Native.Factory.global_instance().create()

        # Create a Scheduler containing graph and filesystem tasks, with no installed goals. The
        # LegacyBuildGraph will explicitly request the products it needs.
        tasks = (create_legacy_graph_tasks(symbol_table_cls) +
                 create_fs_rules() +
                 create_graph_rules(address_mapper, symbol_table_cls))

        # TODO: Do not use the cache yet, as it incurs a high overhead.
        scheduler = LocalScheduler(workdir, dict(), tasks, project_tree,
                                   native)
        engine = LocalSerialEngine(scheduler, use_cache=False)
        change_calculator = EngineChangeCalculator(
            scheduler, engine, symbol_table_cls, scm) if scm else None

        return LegacyGraphHelper(scheduler, engine, symbol_table_cls,
                                 change_calculator)
Esempio n. 2
0
    def setup_legacy_graph(pants_ignore_patterns,
                           symbol_table_cls=None,
                           build_ignore_patterns=None,
                           exclude_target_regexps=None):
        """Construct and return the components necessary for LegacyBuildGraph construction.

    :param list pants_ignore_patterns: A list of path ignore patterns for FileSystemProjectTree,
                                       usually taken from the '--pants-ignore' global option.
    :param SymbolTable symbol_table_cls: A SymbolTable class to use for build file parsing, or
                                         None to use the default.
    :param list build_ignore_patterns: A list of paths ignore patterns used when searching for BUILD
                                       files, usually taken from the '--build-ignore' global option.
    :param list exclude_target_regexps: A list of regular expressions for excluding targets.
    :returns: A tuple of (scheduler, engine, symbol_table_cls, build_graph_cls).
    """

        build_root = get_buildroot()
        scm = get_scm()
        project_tree = FileSystemProjectTree(build_root, pants_ignore_patterns)
        symbol_table_cls = symbol_table_cls or LegacySymbolTable

        # Register "literal" subjects required for these tasks.
        # TODO: Replace with `Subsystems`.
        address_mapper = AddressMapper(
            symbol_table_cls=symbol_table_cls,
            parser_cls=LegacyPythonCallbacksParser,
            build_ignore_patterns=build_ignore_patterns,
            exclude_target_regexps=exclude_target_regexps)

        # Create a Scheduler containing graph and filesystem tasks, with no installed goals. The
        # LegacyBuildGraph will explicitly request the products it needs.
        tasks = (create_legacy_graph_tasks(symbol_table_cls) +
                 create_fs_tasks() +
                 create_graph_tasks(address_mapper, symbol_table_cls))

        scheduler = LocalScheduler(dict(), tasks, project_tree)
        # TODO: Do not use the cache yet, as it incurs a high overhead.
        engine = LocalSerialEngine(scheduler,
                                   Storage.create(),
                                   use_cache=False)
        change_calculator = EngineChangeCalculator(engine,
                                                   scm) if scm else None

        return LegacyGraphHelper(scheduler, engine, symbol_table_cls,
                                 change_calculator)
    def setup_legacy_graph(pants_ignore_patterns,
                           workdir,
                           build_root=None,
                           native=None,
                           build_file_aliases=None,
                           build_ignore_patterns=None,
                           exclude_target_regexps=None,
                           subproject_roots=None,
                           include_trace_on_error=True):
        """Construct and return the components necessary for LegacyBuildGraph construction.

    :param list pants_ignore_patterns: A list of path ignore patterns for FileSystemProjectTree,
                                       usually taken from the '--pants-ignore' global option.
    :param str workdir: The pants workdir.
    :param str build_root: A path to be used as the build root. If None, then default is used.
    :param Native native: An instance of the native-engine subsystem.
    :param build_file_aliases: BuildFileAliases to register.
    :type build_file_aliases: :class:`pants.build_graph.build_file_aliases.BuildFileAliases`
    :param list build_ignore_patterns: A list of paths ignore patterns used when searching for BUILD
                                       files, usually taken from the '--build-ignore' global option.
    :param list exclude_target_regexps: A list of regular expressions for excluding targets.
    :param list subproject_roots: Paths that correspond with embedded build roots
                                  under the current build root.
    :param bool include_trace_on_error: If True, when an error occurs, the error message will
                include the graph trace.
    :returns: A tuple of (scheduler, engine, symbol_table, build_graph_cls).
    """

        build_root = build_root or get_buildroot()
        scm = get_scm()

        if not build_file_aliases:
            _, build_config = OptionsInitializer(
                OptionsBootstrapper()).setup(init_logging=False)
            build_file_aliases = build_config.registered_aliases()
        symbol_table = LegacySymbolTable(build_file_aliases)

        project_tree = FileSystemProjectTree(build_root, pants_ignore_patterns)

        # Register "literal" subjects required for these tasks.
        parser = LegacyPythonCallbacksParser(symbol_table, build_file_aliases)
        address_mapper = AddressMapper(
            parser=parser,
            build_ignore_patterns=build_ignore_patterns,
            exclude_target_regexps=exclude_target_regexps,
            subproject_roots=subproject_roots)

        # Load the native backend.
        native = native or Native.create()

        # Create a Scheduler containing graph and filesystem tasks, with no installed goals. The
        # LegacyBuildGraph will explicitly request the products it needs.
        tasks = (create_legacy_graph_tasks(symbol_table) + create_fs_rules() +
                 create_graph_rules(address_mapper, symbol_table))

        scheduler = LocalScheduler(
            workdir,
            dict(),
            tasks,
            project_tree,
            native,
            include_trace_on_error=include_trace_on_error)
        change_calculator = EngineChangeCalculator(scheduler, symbol_table,
                                                   scm) if scm else None

        return LegacyGraphHelper(scheduler, symbol_table, change_calculator)