Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Target schema updates#231

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
coder137 merged 25 commits intomainfromtarget_schema_updates
Dec 25, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
25 commits
Select commitHold shift + click to select a range
3d67220
Path Schema Ordered updates (#230)
coder137Dec 5, 2022
989c530
Updated link_dependencies to PathInfoList
coder137Dec 6, 2022
3222acc
Updated target_schema flags from std::unordered_set to std::vector
coder137Dec 6, 2022
86a6c22
Migrated target_schema lib_dirs to PathList
coder137Dec 6, 2022
a2de7d8
Converted libs to PathInfoList
coder137Dec 6, 2022
bac571a
Updated target_schema with compile_dependencies
coder137Dec 6, 2022
0e2870c
Converted include_dirs to PathList
coder137Dec 6, 2022
4808e51
Converted path_schema headers to PathInfoList
coder137Dec 6, 2022
f0d9d9f
Updated path_schema for pchs
coder137Dec 6, 2022
1a63d15
Migrated target_schema sources to PathInfoList
coder137Dec 7, 2022
b1a8dac
Removed util.cpp
coder137Dec 7, 2022
6f228ac
Updated path.h
coder137Dec 23, 2022
0871390
Removed fs_unordered_set
coder137Dec 24, 2022
215ca56
Removed Path struct from path.h
coder137Dec 24, 2022
5cddf10
Converted some APIs to fs::path
coder137Dec 24, 2022
0688346
Updated unit tests for path schema
coder137Dec 24, 2022
12f0865
Added test case for pch include dirs rebuild
coder137Dec 25, 2022
ad8c7fe
Updated pch rebuild for headers
coder137Dec 25, 2022
f35ad14
Removed duplicated block in compile_pch.cpp
coder137Dec 25, 2022
8abbc63
Added flags example
coder137Dec 25, 2022
28fd823
Updated target_pch flags unit test
coder137Dec 25, 2022
5b42bf4
Removed target dirty check from compile_pch since it is the first tas…
coder137Dec 25, 2022
a21ea17
Updated compile object flags
coder137Dec 25, 2022
3b0fc10
Updated link target
coder137Dec 25, 2022
102b5ab
Combined else if statements for link target
coder137Dec 25, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletionbuildcc/lib/target/CMakeLists.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,6 @@ include(cmake/common_target_src.cmake)
if (${TESTING})
set(TARGET_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
include(cmake/mock_target.cmake)
add_subdirectory(test/path)
add_subdirectory(test/target)
endif()

Expand Down
2 changes: 0 additions & 2 deletionsbuildcc/lib/target/cmake/common_target_src.cmake
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,8 +8,6 @@ set(COMMON_TARGET_SRCS
include/target/common/target_config.h
include/target/common/target_state.h
include/target/common/target_env.h

src/common/util.cpp
include/target/common/util.h

# API
Expand Down
12 changes: 6 additions & 6 deletionsbuildcc/lib/target/include/target/api/deps_api.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,14 +35,14 @@ template <typename T> class DepsApi {
// TODO, Rename AddObjectDependency
// TODO, Rename AddTargetDependency

const fs_unordered_set &GetCompileDependencies() const {
std::vector<std::string>GetCompileDependencies() const {
const auto &t = static_cast<const T &>(*this);
return t.user_.compile_dependencies;
return t.user_.compile_dependencies.GetPaths();
}

const fs_unordered_set &GetLinkDependencies() const {
std::vector<std::string>GetLinkDependencies() const {
const auto &t = static_cast<const T &>(*this);
return t.user_.link_dependencies;
return t.user_.link_dependencies.GetPaths();
}

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

t.user_.compile_dependencies.insert(absolute_path);
t.user_.compile_dependencies.Emplace(absolute_path, "");
}

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

t.user_.link_dependencies.insert(absolute_path);
t.user_.link_dependencies.Emplace(absolute_path, "");
}

/**
Expand Down
12 changes: 6 additions & 6 deletionsbuildcc/lib/target/include/target/api/include_api.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,21 +32,21 @@ namespace buildcc::internal {
// TargetEnv
template <typename T> class IncludeApi {
public:
const fs_unordered_set &GetHeaderFiles() const {
std::vector<std::string>GetHeaderFiles() const {
const auto &t = static_cast<const T &>(*this);
return t.user_.headers;
return t.user_.headers.GetPaths();
}

constfs_unordered_set &GetIncludeDirs() const {
conststd::vector<std::string> &GetIncludeDirs() const {
const auto &t = static_cast<const T &>(*this);
return t.user_.include_dirs;
return t.user_.include_dirs.GetPaths();
}

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

t.toolchain_.GetConfig().ExpectsValidHeader(absolute_filepath);
t.user_.headers.insert(absolute_filepath);
t.user_.headers.Emplace(absolute_filepath, "");
}

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

t.user_.include_dirs.insert(absolute_include_dir);
t.user_.include_dirs.Emplace(absolute_include_dir);

if (glob_headers) {
GlobHeadersAbsolute(absolute_include_dir);
Expand Down
10 changes: 5 additions & 5 deletionsbuildcc/lib/target/include/target/api/lib_api.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -41,24 +41,24 @@ namespace buildcc::internal {
// Target::GetTargetPath
template <typename T> class LibApi {
public:
conststd::vector<fs::path> &GetLibDeps() const {
std::vector<std::string>GetLibDeps() const {
const auto &t = static_cast<const T &>(*this);
return t.user_.libs;
return t.user_.libs.GetPaths();
}

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

constfs_unordered_set &GetLibDirs() const {
conststd::vector<std::string> &GetLibDirs() const {
const auto &t = static_cast<const T &>(*this);
return t.user_.lib_dirs;
return t.user_.lib_dirs.GetPaths();
}

void AddLibDirAbsolute(const fs::path &absolute_lib_dir) {
auto &t = static_cast<T &>(*this);
t.user_.lib_dirs.insert(absolute_lib_dir);
t.user_.lib_dirs.Emplace(absolute_lib_dir);
}

void AddLibDir(const fs::path &relative_lib_dir) {
Expand Down
6 changes: 3 additions & 3 deletionsbuildcc/lib/target/include/target/api/pch_api.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -31,9 +31,9 @@ namespace buildcc::internal {
// TargetEnv
template <typename T> class PchApi {
public:
const fs_unordered_set &GetPchFiles() const {
std::vector<std::string>GetPchFiles() const {
const auto &t = static_cast<const T &>(*this);
return t.user_.pchs;
return t.user_.pchs.GetPaths();
}

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

const fs::path absolute_pch = fs::path(absolute_filepath).make_preferred();
t.user_.pchs.insert(absolute_pch);
t.user_.pchs.Emplace(absolute_pch, "");
}

void AddPch(const fs::path &relative_filename,
Expand Down
6 changes: 3 additions & 3 deletionsbuildcc/lib/target/include/target/api/source_api.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -31,16 +31,16 @@ namespace buildcc::internal {
// TargetEnv
template <typename T> class SourceApi {
public:
const fs_unordered_set &GetSourceFiles() const {
std::vector<std::string>GetSourceFiles() const {
const auto &t = static_cast<const T &>(*this);
return t.user_.sources;
return t.user_.sources.GetPaths();
}

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

t.toolchain_.GetConfig().ExpectsValidSource(absolute_source);
t.user_.sources.emplace(fs::path(absolute_source).make_preferred());
t.user_.sources.Emplace(absolute_source, "");
}

void GlobSourcesAbsolute(const fs::path &absolute_source_dir) {
Expand Down
13 changes: 9 additions & 4 deletionsbuildcc/lib/target/include/target/common/util.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,10 +29,15 @@ template <typename T> std::string aggregate(const T &list) {
returnfmt::format("{}",fmt::join(list,""));
}

std::stringaggregate(const buildcc::fs_unordered_set &paths);

std::stringaggregate_with_prefix(const std::string &prefix,
const fs_unordered_set &dirs);
template<typename T>
std::stringaggregate_with_prefix(const std::string &prefix,const T &list) {
std::vector<std::string> agg_list;
for (constauto &l : list) {
auto formatted_output =fmt::format("{}{}", prefix, l);
agg_list.emplace_back(std::move(formatted_output));
}
returnaggregate(agg_list);
}

}// namespace buildcc::internal

Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,14 +26,14 @@ namespace buildcc {
class CustomGeneratorContext {
public:
CustomGeneratorContext(const env::Command &c,
const std::unordered_set<std::string> &i,
const std::unordered_set<std::string> &o,
const std::vector<std::string> &i,
const std::vector<std::string> &o,
const std::vector<uint8_t> &ub)
: command(c), inputs(i), outputs(o), userblob(ub) {}

const env::Command &command;
const std::unordered_set<std::string> &inputs;
const std::unordered_set<std::string> &outputs;
const std::vector<std::string> &inputs;
const std::vector<std::string> &outputs;
const std::vector<uint8_t> &userblob;
};

Expand Down
17 changes: 8 additions & 9 deletionsbuildcc/lib/target/include/target/friend/compile_object.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -54,29 +54,28 @@ class CompileObject {
void Task();

const ObjectData &GetObjectData(const fs::path &absolute_source) const;
const std::unordered_map<fs::path, ObjectData, internal::PathHash> &
GetObjectDataMap() const {
const std::unordered_map<std::string, ObjectData> &GetObjectDataMap() const {
return object_files_;
}
fs_unordered_set GetCompiledSources() const;
std::vector<fs::path> GetCompiledSources() const;
tf::Task &GetTask() { return compile_task_; }

private:
fs::path ConstructObjectPath(const fs::path &absolute_source_file) const;

void BuildObjectCompile(std::vector<internal::Path> &source_files,
std::vector<internal::Path> &dummy_source_files);
void BuildObjectCompile(std::vector<internal::PathInfo> &source_files,
std::vector<internal::PathInfo> &dummy_source_files);

void PreObjectCompile();

void CompileSources(std::vector<internal::Path> &source_files);
void RecompileSources(std::vector<internal::Path> &source_files,
std::vector<internal::Path> &dummy_source_files);
void CompileSources(std::vector<internal::PathInfo> &source_files);
void RecompileSources(std::vector<internal::PathInfo> &source_files,
std::vector<internal::PathInfo> &dummy_source_files);

private:
Target &target_;

std::unordered_map<fs::path, ObjectData, internal::PathHash> object_files_;
std::unordered_map<std::string, ObjectData> object_files_;
tf::Task compile_task_;
};

Expand Down
117 changes: 0 additions & 117 deletionsbuildcc/lib/target/include/target/interface/builder_interface.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,71 +29,6 @@

namespace buildcc::internal {

enum class PathState {
kNoChange,
kRemoved,
kAdded,
kUpdated,
};

template <typename T>
inline bool CheckChanged(const T &previous, const T &current) {
bool changed = false;
if (previous != current) {
changed = true;
}
return changed;
}

/**
* @brief
*
* @return PathState Returns first state found if `Removed`, `Added` or
* `Updated`
* If none of the above states are true then it returns `NoChange`
*/
inline PathState CheckPaths(const internal::path_unordered_set &previous_path,
const internal::path_unordered_set &current_path) {
PathState state{PathState::kNoChange};

// * Old path is removed
const bool removed = std::any_of(
previous_path.begin(), previous_path.end(), [&](const internal::Path &p) {
return current_path.find(p) == current_path.end();
});
if (removed) {
state = PathState::kRemoved;
} else {
(void)std::any_of(current_path.cbegin(), current_path.cend(),
[&](const internal::Path &p) -> bool {
bool dirty = false;
const auto find = previous_path.find(p);
const bool added_cond = (find == previous_path.end());
if (added_cond) {
dirty = true;
state = PathState::kAdded;
} else {
const bool updated_cond =
(p.last_write_timestamp >
find->last_write_timestamp);
if (updated_cond) {
dirty = true;
state = PathState::kUpdated;
} else {
dirty = false;
}
}
return dirty;
});
}
return state;
}

// TODO, 1. Consider updating Recheck* APIs - do not modify internal `dirty_`
// flag
// TODO, 2. Consider removing dependency on target/common/util.h
// TODO, 3. Consider making Recheck* APIs free namespaced functions instead of
// only within the scope of BuilderInterfaces (See TODO 1. and 2. first)
class BuilderInterface {

public:
Expand All@@ -102,58 +37,6 @@ class BuilderInterface {
const std::string &GetUniqueId() const { return unique_id_; }
tf::Taskflow &GetTaskflow() { return tf_; }

protected:
template <typename T>
void RecheckChanged(
const T &previous, const T &current,
const std::function<void(void)> &callback = []() {}) {
ASSERT_FATAL(callback, "Bad function: callback");

if (dirty_) {
return;
}

if (CheckChanged(previous, current)) {
callback();
dirty_ = true;
}
}

void RecheckPaths(
const internal::path_unordered_set &previous_path,
const internal::path_unordered_set &current_path,
const std::function<void(void)> &path_removed_cb = []() {},
const std::function<void(void)> &path_added_cb = []() {},
const std::function<void(void)> &path_updated_cb = []() {}) {
ASSERT_FATAL(path_removed_cb, "Bad function: path_removed_cb");
ASSERT_FATAL(path_added_cb, "Bad function: path_added_cb");
ASSERT_FATAL(path_updated_cb, "Bad function: path_updated_cb");

if (dirty_) {
return;
}

auto path_state = CheckPaths(previous_path, current_path);
switch (path_state) {
case PathState::kRemoved:
path_removed_cb();
dirty_ = true;
break;
case PathState::kAdded:
path_added_cb();
dirty_ = true;
break;
case PathState::kUpdated:
path_updated_cb();
dirty_ = true;
break;
case PathState::kNoChange:
default:
dirty_ = false;
break;
}
}

protected:
bool dirty_{false};
std::string unique_id_;
Expand Down
12 changes: 1 addition & 11 deletionsbuildcc/lib/target/include/target/target.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -96,17 +96,6 @@ class Target : public internal::BuilderInterface,
env::optional<std::string> SelectCompileFlags(FileExt ext) const;
env::optional<std::string> SelectCompiler(FileExt ext) const;

// Recompilation checks
void RecheckPaths(const internal::path_unordered_set &previous_path,
const internal::path_unordered_set &current_path);
void RecheckDirs(const fs_unordered_set &previous_dirs,
const fs_unordered_set &current_dirs);
void RecheckFlags(const std::unordered_set<std::string> &previous_flags,
const std::unordered_set<std::string> &current_flags);
void
RecheckExternalLib(const std::vector<std::string> &previous_external_libs,
const std::vector<std::string> &current_external_libs);

// Tasks
void EndTask();
void TaskDeps();
Expand All@@ -119,6 +108,7 @@ class Target : public internal::BuilderInterface,
void PathAdded();
void PathUpdated();

void PathChanged();
void DirChanged();
void FlagChanged();
void ExternalLibChanged();
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp