diff options
| author | Bent Bisballe Nyeng <deva@aasimon.org> | 2021-09-20 17:31:54 +0200 | 
|---|---|---|
| committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2021-09-20 17:31:54 +0200 | 
| commit | cb5f269b13429f0e1ffbc41426227983e5ccaeba (patch) | |
| tree | 14e4bd292e1a16ff3d844e73a466ab051f7345d7 /src | |
| parent | 41ce3a4dcf5a03588b7c350445e73975c6b12ff7 (diff) | |
Simplify/fix task dependency calculation. And tasks unit-tests.
Diffstat (limited to 'src')
| -rw-r--r-- | src/task.cc | 8 | ||||
| -rw-r--r-- | src/task.h | 3 | ||||
| -rw-r--r-- | src/task_ar.cc | 15 | ||||
| -rw-r--r-- | src/task_ld.cc | 15 | ||||
| -rw-r--r-- | src/task_so.cc | 15 | ||||
| -rw-r--r-- | src/tasks.h | 8 | 
6 files changed, 15 insertions, 49 deletions
diff --git a/src/task.cc b/src/task.cc index 962a02b..4cdfa5e 100644 --- a/src/task.cc +++ b/src/task.cc @@ -3,17 +3,15 @@  #include <unistd.h>  #include <iostream> -Task::Task(const BuildConfiguration& config, -           const std::vector<std::string>& depends) -	: dependsStr(depends) -	, config(config) +Task::Task(const BuildConfiguration& config) +	: config(config)  	, output_system(config.system)  {  }  int Task::registerDepTasks(const std::list<std::shared_ptr<Task>>& tasks)  { -	for(auto const& depStr : dependsStr) +	for(const auto& depStr : depends())  	{  		bool found{false};  		for(const auto& task : tasks) @@ -21,8 +21,7 @@ enum class State  class Task  {  public: -	Task(const BuildConfiguration& config, -	     const std::vector<std::string>& depends = {}); +	Task(const BuildConfiguration& config);  	int registerDepTasks(const std::list<std::shared_ptr<Task>>& tasks); diff --git a/src/task_ar.cc b/src/task_ar.cc index 980d8b4..51d609e 100644 --- a/src/task_ar.cc +++ b/src/task_ar.cc @@ -22,26 +22,13 @@ std::string readFile(const std::string &fileName)  	return std::string(bytes.data(), fileSize);  } - -std::vector<std::string> addPrefix(const std::vector<std::string>& lst, -                                   const Settings& settings) -{ -	std::vector<std::string> out; -	for(const auto& item : lst) -	{ -		std::filesystem::path file = settings.builddir; -		file /= item; -		out.push_back(file.string()); -	} -	return out; -}  } // namespace ::  TaskAR::TaskAR(const BuildConfiguration& config,                 const Settings& settings,                 const std::string& target,                 const std::vector<std::string>& objects) -	: Task(config, addPrefix(config.depends, settings)) +	: Task(config)  	, config(config)  	, settings(settings)  { diff --git a/src/task_ld.cc b/src/task_ld.cc index ec68190..4eb64f4 100644 --- a/src/task_ld.cc +++ b/src/task_ld.cc @@ -21,26 +21,13 @@ std::string readFile(const std::string &fileName)  	return std::string(bytes.data(), fileSize);  } - -std::vector<std::string> addPrefix(const std::vector<std::string>& lst, -                                   const Settings& settings) -{ -	std::vector<std::string> out; -	for(const auto& item : lst) -	{ -		std::filesystem::path file = settings.builddir; -		file /= item; -		out.push_back(file.string()); -	} -	return out; -}  } // namespace ::  TaskLD::TaskLD(const BuildConfiguration& config,                 const Settings& settings,                 const std::string& target,                 const std::vector<std::string>& objects) -	: Task(config, addPrefix(config.depends, settings)) +	: Task(config)  	, config(config)  	, settings(settings)  { diff --git a/src/task_so.cc b/src/task_so.cc index ca7883f..519085a 100644 --- a/src/task_so.cc +++ b/src/task_so.cc @@ -21,26 +21,13 @@ std::string readFile(const std::string &fileName)  	return std::string(bytes.data(), fileSize);  } - -std::vector<std::string> addPrefix(const std::vector<std::string>& lst, -                                   const Settings& settings) -{ -	std::vector<std::string> out; -	for(const auto& item : lst) -	{ -		std::filesystem::path file = settings.builddir; -		file /= item; -		out.push_back(file.string()); -	} -	return out; -}  } // namespace ::  TaskSO::TaskSO(const BuildConfiguration& config,                 const Settings& settings,                 const std::string& target,                 const std::vector<std::string>& objects) -	: Task(config, addPrefix(config.depends, settings)) +	: Task(config)  	, config(config)  	, settings(settings)  { diff --git a/src/tasks.h b/src/tasks.h index e5d1daf..c5b326e 100644 --- a/src/tasks.h +++ b/src/tasks.h @@ -17,9 +17,17 @@ struct Target  	std::string path;  }; +//! Get list of all registered targets  const std::deque<Target>& getTargets(const Settings& settings); +//! Returns next dirty task from the dirtyTasks list that has all its dependencies +//! fulfilled. +//! The returned task is removed from the dirty list. +//! Return nullptr if no dirty task is ready.  std::shared_ptr<Task> getNextTask(const std::list<std::shared_ptr<Task>>& allTasks,                                    std::list<std::shared_ptr<Task>>& dirtyTasks); + +//! Get list of tasks filtered by name including each of their direct +//! dependency tasks (ie. objects tasks from their sources).  std::list<std::shared_ptr<Task>> getTasks(const Settings& settings,                                            const std::vector<std::string> names = {});  | 
