// -*- c++ -*-
// Distributed under the BSD 2-Clause License.
// See accompanying file LICENSE for details.
#pragma once

#include <string>
#include <vector>
#include <memory>

#include "task.h"
#include "tasks.h"

namespace ctor {
struct settings;
} // namespace ctor::

//! Dry-run returns number of dirty tasks but otherwise does nothing.
int build(const ctor::settings& settings,
          const std::string& name,
          const std::vector<std::shared_ptr<Task>>& tasks,
          const std::vector<std::shared_ptr<Task>>& all_tasks,
          bool dryrun = false);

//! Dry-run returns number of dirty tasks but otherwise does nothing.
int build(const ctor::settings& settings,
          const std::string& name,
          const std::vector<std::shared_ptr<Task>>& all_tasks,
          bool dryrun = false);

//! Dry-run returns number of dirty tasks but otherwise does nothing.
int build(const ctor::settings& settings,
          const std::string& name,
          const std::vector<Target>& targets,
          const std::vector<std::shared_ptr<Task>>& all_tasks,
          bool dryrun = false);

// Recursively build vector of dependency tasks from source task.
// Throws if a cycle is detected.
std::vector<std::shared_ptr<Task>> getDepTasks(std::shared_ptr<Task> task,
                                               std::vector<std::shared_ptr<Task>> trace = {});