blob: bd115994420d0ba1effa036f9c631204ffe9e5b5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
#pragma once
#include <filesystem>
#include <functional>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <boost/property_tree/ptree.hpp>
#include "LanguageSettings.h"
#include "ProcessRunner.h"
class Builder
{
public:
Builder(const boost::property_tree::ptree& ptree, const std::string& target);
void build();
void run_tests();
void clean();
private:
std::unordered_map<std::filesystem::path, std::vector<std::filesystem::path>> get_dependencies(const boost::property_tree::ptree& ptree, bool include_sources = true) const;
std::vector<std::filesystem::path> dependencies_of(const std::filesystem::path& p) const;
std::vector<std::filesystem::path> include_paths_of_object(const std::filesystem::path& p) const;
std::filesystem::path target_from_object(const std::filesystem::path& object) const;
std::vector<std::string> link_libs_of(const std::filesystem::path& p) const;
bool is_outdated(const std::filesystem::path& p) const;
bool is_outdated(const std::filesystem::path& p, const std::vector<std::filesystem::path> &dependencies) const;
std::vector<std::filesystem::path> make_depfile_from(const std::filesystem::path& p) const;
std::filesystem::path get_compile_unit_source_from_object(const std::filesystem::path& path);
std::unordered_set<std::filesystem::path> get_buildlist(std::function<bool(const std::filesystem::path&)> outdated_pred);
void build_file(const std::filesystem::path& p);
void build_filelist();
void cleanup_buildlist();
const boost::property_tree::ptree _ptree;
std::string _target;
std::vector<std::filesystem::path> _all_targets;
std::vector<std::filesystem::path> _all_objects;
std::unordered_map<std::filesystem::path, std::vector<std::filesystem::path>> _dependencies;
std::unordered_map<std::filesystem::path, std::vector<std::filesystem::path>> _include_paths;
std::unordered_map<std::filesystem::path, std::vector<std::string>> _link_libs;
LanguageSettings _lang;
ProcessRunner _runner;
std::unordered_set<std::filesystem::path> _buildlist; // build done
std::unordered_set<std::filesystem::path> _activelist; // currently building
std::unordered_set<std::filesystem::path> _donelist; // build done
};
|