Skip to content

Commit 27f44d5

Browse files
authored
Target schema updates (#231)
1 parent 3f37a04 commit 27f44d5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+940
-1062
lines changed

buildcc/lib/target/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ include(cmake/common_target_src.cmake)
44
if (${TESTING})
55
set(TARGET_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
66
include(cmake/mock_target.cmake)
7-
add_subdirectory(test/path)
87
add_subdirectory(test/target)
98
endif()
109

buildcc/lib/target/cmake/common_target_src.cmake

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ set(COMMON_TARGET_SRCS
88
include/target/common/target_config.h
99
include/target/common/target_state.h
1010
include/target/common/target_env.h
11-
12-
src/common/util.cpp
1311
include/target/common/util.h
1412

1513
# API

buildcc/lib/target/include/target/api/deps_api.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ template <typename T> class DepsApi {
3535
// TODO, Rename AddObjectDependency
3636
// TODO, Rename AddTargetDependency
3737

38-
const fs_unordered_set &GetCompileDependencies() const {
38+
std::vector<std::string> GetCompileDependencies() const {
3939
const auto &t = static_cast<const T &>(*this);
40-
return t.user_.compile_dependencies;
40+
return t.user_.compile_dependencies.GetPaths();
4141
}
4242

43-
const fs_unordered_set &GetLinkDependencies() const {
43+
std::vector<std::string> GetLinkDependencies() const {
4444
const auto &t = static_cast<const T &>(*this);
45-
return t.user_.link_dependencies;
45+
return t.user_.link_dependencies.GetPaths();
4646
}
4747

4848
/**
@@ -52,7 +52,7 @@ template <typename T> class DepsApi {
5252
void AddCompileDependencyAbsolute(const fs::path &absolute_path) {
5353
auto &t = static_cast<T &>(*this);
5454

55-
t.user_.compile_dependencies.insert(absolute_path);
55+
t.user_.compile_dependencies.Emplace(absolute_path, "");
5656
}
5757

5858
/**
@@ -73,7 +73,7 @@ template <typename T> class DepsApi {
7373
void AddLinkDependencyAbsolute(const fs::path &absolute_path) {
7474
auto &t = static_cast<T &>(*this);
7575

76-
t.user_.link_dependencies.insert(absolute_path);
76+
t.user_.link_dependencies.Emplace(absolute_path, "");
7777
}
7878

7979
/**

buildcc/lib/target/include/target/api/include_api.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,21 @@ namespace buildcc::internal {
3232
// TargetEnv
3333
template <typename T> class IncludeApi {
3434
public:
35-
const fs_unordered_set &GetHeaderFiles() const {
35+
std::vector<std::string> GetHeaderFiles() const {
3636
const auto &t = static_cast<const T &>(*this);
37-
return t.user_.headers;
37+
return t.user_.headers.GetPaths();
3838
}
3939

40-
const fs_unordered_set &GetIncludeDirs() const {
40+
const std::vector<std::string> &GetIncludeDirs() const {
4141
const auto &t = static_cast<const T &>(*this);
42-
return t.user_.include_dirs;
42+
return t.user_.include_dirs.GetPaths();
4343
}
4444

4545
void AddHeaderAbsolute(const fs::path &absolute_filepath) {
4646
auto &t = static_cast<T &>(*this);
4747

4848
t.toolchain_.GetConfig().ExpectsValidHeader(absolute_filepath);
49-
t.user_.headers.insert(absolute_filepath);
49+
t.user_.headers.Emplace(absolute_filepath, "");
5050
}
5151

5252
void GlobHeadersAbsolute(const fs::path &absolute_path) {
@@ -63,7 +63,7 @@ template <typename T> class IncludeApi {
6363
bool glob_headers = false) {
6464
auto &t = static_cast<T &>(*this);
6565

66-
t.user_.include_dirs.insert(absolute_include_dir);
66+
t.user_.include_dirs.Emplace(absolute_include_dir);
6767

6868
if (glob_headers) {
6969
GlobHeadersAbsolute(absolute_include_dir);

buildcc/lib/target/include/target/api/lib_api.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,24 +41,24 @@ namespace buildcc::internal {
4141
// Target::GetTargetPath
4242
template <typename T> class LibApi {
4343
public:
44-
const std::vector<fs::path> &GetLibDeps() const {
44+
std::vector<std::string> GetLibDeps() const {
4545
const auto &t = static_cast<const T &>(*this);
46-
return t.user_.libs;
46+
return t.user_.libs.GetPaths();
4747
}
4848

4949
const std::vector<std::string> &GetExternalLibDeps() const {
5050
const auto &t = static_cast<const T &>(*this);
5151
return t.user_.external_libs;
5252
}
5353

54-
const fs_unordered_set &GetLibDirs() const {
54+
const std::vector<std::string> &GetLibDirs() const {
5555
const auto &t = static_cast<const T &>(*this);
56-
return t.user_.lib_dirs;
56+
return t.user_.lib_dirs.GetPaths();
5757
}
5858

5959
void AddLibDirAbsolute(const fs::path &absolute_lib_dir) {
6060
auto &t = static_cast<T &>(*this);
61-
t.user_.lib_dirs.insert(absolute_lib_dir);
61+
t.user_.lib_dirs.Emplace(absolute_lib_dir);
6262
}
6363

6464
void AddLibDir(const fs::path &relative_lib_dir) {

buildcc/lib/target/include/target/api/pch_api.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ namespace buildcc::internal {
3131
// TargetEnv
3232
template <typename T> class PchApi {
3333
public:
34-
const fs_unordered_set &GetPchFiles() const {
34+
std::vector<std::string> GetPchFiles() const {
3535
const auto &t = static_cast<const T &>(*this);
36-
return t.user_.pchs;
36+
return t.user_.pchs.GetPaths();
3737
}
3838

3939
void AddPchAbsolute(const fs::path &absolute_filepath) {
@@ -42,7 +42,7 @@ template <typename T> class PchApi {
4242
t.toolchain_.GetConfig().ExpectsValidHeader(absolute_filepath);
4343

4444
const fs::path absolute_pch = fs::path(absolute_filepath).make_preferred();
45-
t.user_.pchs.insert(absolute_pch);
45+
t.user_.pchs.Emplace(absolute_pch, "");
4646
}
4747

4848
void AddPch(const fs::path &relative_filename,

buildcc/lib/target/include/target/api/source_api.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ namespace buildcc::internal {
3131
// TargetEnv
3232
template <typename T> class SourceApi {
3333
public:
34-
const fs_unordered_set &GetSourceFiles() const {
34+
std::vector<std::string> GetSourceFiles() const {
3535
const auto &t = static_cast<const T &>(*this);
36-
return t.user_.sources;
36+
return t.user_.sources.GetPaths();
3737
}
3838

3939
void AddSourceAbsolute(const fs::path &absolute_source) {
4040
auto &t = static_cast<T &>(*this);
4141

4242
t.toolchain_.GetConfig().ExpectsValidSource(absolute_source);
43-
t.user_.sources.emplace(fs::path(absolute_source).make_preferred());
43+
t.user_.sources.Emplace(absolute_source, "");
4444
}
4545

4646
void GlobSourcesAbsolute(const fs::path &absolute_source_dir) {

buildcc/lib/target/include/target/common/util.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,15 @@ template <typename T> std::string aggregate(const T &list) {
2929
return fmt::format("{}", fmt::join(list, " "));
3030
}
3131

32-
std::string aggregate(const buildcc::fs_unordered_set &paths);
33-
34-
std::string aggregate_with_prefix(const std::string &prefix,
35-
const fs_unordered_set &dirs);
32+
template <typename T>
33+
std::string aggregate_with_prefix(const std::string &prefix, const T &list) {
34+
std::vector<std::string> agg_list;
35+
for (const auto &l : list) {
36+
auto formatted_output = fmt::format("{}{}", prefix, l);
37+
agg_list.emplace_back(std::move(formatted_output));
38+
}
39+
return aggregate(agg_list);
40+
}
3641

3742
} // namespace buildcc::internal
3843

buildcc/lib/target/include/target/custom_generator/custom_generator_context.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ namespace buildcc {
2626
class CustomGeneratorContext {
2727
public:
2828
CustomGeneratorContext(const env::Command &c,
29-
const std::unordered_set<std::string> &i,
30-
const std::unordered_set<std::string> &o,
29+
const std::vector<std::string> &i,
30+
const std::vector<std::string> &o,
3131
const std::vector<uint8_t> &ub)
3232
: command(c), inputs(i), outputs(o), userblob(ub) {}
3333

3434
const env::Command &command;
35-
const std::unordered_set<std::string> &inputs;
36-
const std::unordered_set<std::string> &outputs;
35+
const std::vector<std::string> &inputs;
36+
const std::vector<std::string> &outputs;
3737
const std::vector<uint8_t> &userblob;
3838
};
3939

buildcc/lib/target/include/target/friend/compile_object.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,29 +54,28 @@ class CompileObject {
5454
void Task();
5555

5656
const ObjectData &GetObjectData(const fs::path &absolute_source) const;
57-
const std::unordered_map<fs::path, ObjectData, internal::PathHash> &
58-
GetObjectDataMap() const {
57+
const std::unordered_map<std::string, ObjectData> &GetObjectDataMap() const {
5958
return object_files_;
6059
}
61-
fs_unordered_set GetCompiledSources() const;
60+
std::vector<fs::path> GetCompiledSources() const;
6261
tf::Task &GetTask() { return compile_task_; }
6362

6463
private:
6564
fs::path ConstructObjectPath(const fs::path &absolute_source_file) const;
6665

67-
void BuildObjectCompile(std::vector<internal::Path> &source_files,
68-
std::vector<internal::Path> &dummy_source_files);
66+
void BuildObjectCompile(std::vector<internal::PathInfo> &source_files,
67+
std::vector<internal::PathInfo> &dummy_source_files);
6968

7069
void PreObjectCompile();
7170

72-
void CompileSources(std::vector<internal::Path> &source_files);
73-
void RecompileSources(std::vector<internal::Path> &source_files,
74-
std::vector<internal::Path> &dummy_source_files);
71+
void CompileSources(std::vector<internal::PathInfo> &source_files);
72+
void RecompileSources(std::vector<internal::PathInfo> &source_files,
73+
std::vector<internal::PathInfo> &dummy_source_files);
7574

7675
private:
7776
Target &target_;
7877

79-
std::unordered_map<fs::path, ObjectData, internal::PathHash> object_files_;
78+
std::unordered_map<std::string, ObjectData> object_files_;
8079
tf::Task compile_task_;
8180
};
8281

0 commit comments

Comments
 (0)