def setup_manifest(ctx: Context, write: bool = True, write_perf_info: bool = False):
    """Load the manifest and add it to the context."""
    req_strs = ["profile", "project", "runtime_config"]
    reqs = [ctx.obj.get(dep) for dep in req_strs]

    if None in reqs:
        raise DbtProjectError("profile, project, and runtime_config required for manifest")

    runtime_config = ctx.obj["runtime_config"]

    catalogs = ctx.obj["catalogs"] if "catalogs" in ctx.obj else []
    active_integrations = [get_active_write_integration(catalog) for catalog in catalogs]

    # if a manifest has already been set on the context, don't overwrite it
    if ctx.obj.get("manifest") is None:
        ctx.obj["manifest"] = parse_manifest(
            runtime_config, write_perf_info, write, ctx.obj["flags"].write_json
        )
        adapter = get_adapter(runtime_config)
    else:
        register_adapter(runtime_config, get_mp_context())
        adapter = get_adapter(runtime_config)
        adapter.set_macro_context_generator(generate_runtime_macro_context)  # type: ignore[arg-type]
        adapter.set_macro_resolver(ctx.obj["manifest"])
        query_header_context = generate_query_header_context(adapter.config, ctx.obj["manifest"])  # type: ignore[attr-defined]
        adapter.connections.set_query_header(query_header_context)

    for integration in active_integrations:
        adapter.add_catalog_integration(integration)
Load the manifest and add it to the context.
core/dbt/cli/requires.py