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

[Cleanup] CRTP header only#219

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 7 commits intomainfromcrtp_header_only
Oct 21, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
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
7 changes: 0 additions & 7 deletionsbuildcc/lib/target/cmake/common_target_src.cmake
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,12 +13,7 @@ set(COMMON_TARGET_SRCS
include/target/common/util.h

# API
src/api/source_api.cpp
src/api/include_api.cpp
src/api/lib_api.cpp
src/api/pch_api.cpp
src/api/flag_api.cpp
src/api/deps_api.cpp
include/target/api/source_api.h
include/target/api/include_api.h
include/target/api/lib_api.h
Expand All@@ -28,9 +23,7 @@ set(COMMON_TARGET_SRCS
src/api/sync_api.cpp
include/target/api/sync_api.h

src/api/target_info_getter.cpp
src/api/target_getter.cpp
include/target/api/target_info_getter.h
include/target/api/target_getter.h

# Generator
Expand Down
43 changes: 37 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@@ -19,42 +19,73 @@

#include <filesystem>

#include "schema/path.h"

namespace fs = std::filesystem;

namespace buildcc::internal {

// Requires
// - TargetStorer
// - TargetEnv
// User::CompileDependencies
// User::LinkDependencies
// TargetEnv
template <typename T> class DepsApi {
public:
// TODO, AddPchDependency
// TODO, Rename AddObjectDependency
// TODO, Rename AddTargetDependency

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

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

/**
* @brief Recompile sources to object if compile dependency is removed, added
* or newer from the previous build
*/
void AddCompileDependency(const fs::path &relative_path);
void AddCompileDependencyAbsolute(const fs::path &absolute_path) {
auto &t = static_cast<T &>(*this);

t.user_.compile_dependencies.insert(absolute_path);
}

/**
* @brief Recompile sources to object if compile dependency is removed, added
* or newer from the previous build
*/
void AddCompileDependencyAbsolute(const fs::path &absolute_path);
void AddCompileDependency(const fs::path &relative_path) {
auto &t = static_cast<T &>(*this);

fs::path absolute_path = t.env_.GetTargetRootDir() / relative_path;
AddCompileDependencyAbsolute(absolute_path);
}

/**
* @brief Relink target if link dependency is removed, added or newer from
* previous build
*/
void AddLinkDependency(const fs::path &relative_path);
void AddLinkDependencyAbsolute(const fs::path &absolute_path) {
auto &t = static_cast<T &>(*this);

t.user_.link_dependencies.insert(absolute_path);
}

/**
* @brief Relink target if link dependency is removed, added or newer from
* previous build
*/
void AddLinkDependencyAbsolute(const fs::path &absolute_path);
void AddLinkDependency(const fs::path &relative_path) {
auto &t = static_cast<T &>(*this);

fs::path absolute_path = t.env_.GetTargetRootDir() / relative_path;
AddLinkDependencyAbsolute(absolute_path);
}
};

} // namespace buildcc::internal
Expand Down
76 changes: 66 additions & 10 deletionsbuildcc/lib/target/include/target/api/include_api.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,27 +19,83 @@

#include <filesystem>

#include "schema/path.h"

namespace fs = std::filesystem;

namespace buildcc::internal {

// Requires
// - TargetStorer
// - TargetConfig
// - TargetEnv
// Toolchain
// User::Headers
// User::IncludeDirs
// TargetEnv
template <typename T> class IncludeApi {
public:
const fs_unordered_set &GetHeaderFiles() const {
const auto &t = static_cast<const T &>(*this);
return t.user_.headers;
}

const fs_unordered_set &GetIncludeDirs() const {
const auto &t = static_cast<const T &>(*this);
return t.user_.include_dirs;
}

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);
}

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

for (const auto &p : fs::directory_iterator(absolute_path)) {
if (t.toolchain_.GetConfig().IsValidHeader(p.path())) {
AddHeaderAbsolute(p.path());
}
}
}

void AddIncludeDirAbsolute(const fs::path &absolute_include_dir,
bool glob_headers = false) {
auto &t = static_cast<T &>(*this);

t.user_.include_dirs.insert(absolute_include_dir);

if (glob_headers) {
GlobHeadersAbsolute(absolute_include_dir);
}
}

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

// Check Source
fs::path absolute_filepath =
t.env_.GetTargetRootDir() / relative_to_target_path / relative_filename;
AddHeaderAbsolute(absolute_filepath);
}

void GlobHeaders(const fs::path &relative_to_target_path = "");
void GlobHeadersAbsolute(const fs::path &absolute_path);
void GlobHeaders(const fs::path &relative_to_target_path = "") {
auto &t = static_cast<T &>(*this);

fs::path absolute_path =
t.env_.GetTargetRootDir() / relative_to_target_path;
GlobHeadersAbsolute(absolute_path);
}

void AddIncludeDir(const fs::path &relative_include_dir,
bool glob_headers = false);
void AddIncludeDirAbsolute(const fs::path &absolute_include_dir,
bool glob_headers = false);
bool glob_headers = false) {
auto &t = static_cast<T &>(*this);

const fs::path absolute_include_dir =
t.env_.GetTargetRootDir() / relative_include_dir;
AddIncludeDirAbsolute(absolute_include_dir, glob_headers);
}
};

} // namespace buildcc::internal
Expand Down
48 changes: 41 additions & 7 deletionsbuildcc/lib/target/include/target/api/lib_api.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,6 +19,9 @@

#include <filesystem>
#include <string>
#include <vector>

#include "schema/path.h"

namespace fs = std::filesystem;

Expand All@@ -31,16 +34,47 @@ class Target;
namespace buildcc::internal {

// Requires
// - TargetStorer
// - TargetEnv
// T::GetTargetPath
// User::LibDirs
// User::Libs
// User::ExternalLibs
// TargetEnv
// Target::GetTargetPath
template <typename T> class LibApi {
public:
void AddLibDep(const Target &lib_dep);
void AddLibDep(const std::string &lib_dep);
const std::vector<fs::path> &GetLibDeps() const {
const auto &t = static_cast<const T &>(*this);
return t.user_.libs;
}

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

const fs_unordered_set &GetLibDirs() const {
const auto &t = static_cast<const T &>(*this);
return t.user_.lib_dirs;
}

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

void AddLibDir(const fs::path &relative_lib_dir) {
auto &t = static_cast<T &>(*this);
fs::path final_lib_dir = t.env_.GetTargetRootDir() / relative_lib_dir;
AddLibDirAbsolute(final_lib_dir);
}

void AddLibDep(const std::string &lib_dep) {
auto &t = static_cast<T &>(*this);
t.user_.external_libs.push_back(lib_dep);
}

// Target class has been forward declared
// This is because this file is meant to be used by `TargetInfo` and `Target`
void AddLibDep(const Target &lib_dep);
};

} // namespace buildcc::internal
Expand Down
33 changes: 28 additions & 5 deletionsbuildcc/lib/target/include/target/api/pch_api.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,19 +19,42 @@

#include <filesystem>

#include "schema/path.h"

namespace fs = std::filesystem;

namespace buildcc::internal {

// Requires
//- TargetStorer
//- TargetConfig
//-TargetEnv
//Toolchain
//User::Pchs
// TargetEnv
template <typename T> class PchApi {
public:
const fs_unordered_set &GetPchFiles() const {
const auto &t = static_cast<const T &>(*this);
return t.user_.pchs;
}

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

t.toolchain_.GetConfig().ExpectsValidHeader(absolute_filepath);

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

void AddPch(const fs::path &relative_filename,
const fs::path &relative_to_target_path = "");
void AddPchAbsolute(const fs::path &absolute_filepath);
const fs::path &relative_to_target_path = "") {
auto &t = static_cast<T &>(*this);

// Compute the absolute source path
fs::path absolute_pch =
t.env_.GetTargetRootDir() / relative_to_target_path / relative_filename;

AddPchAbsolute(absolute_pch);
}
};

} // namespace buildcc::internal
Expand Down
53 changes: 46 additions & 7 deletionsbuildcc/lib/target/include/target/api/source_api.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,22 +19,61 @@

#include <filesystem>

#include "schema/path.h"

namespace fs = std::filesystem;

namespace buildcc::internal {

// Requires
//- TargetStorer
//- TargetConfig
//-TargetEnv
//Toolchain
//User::Sources
// TargetEnv
template <typename T> class SourceApi {
public:
void AddSourceAbsolute(const fs::path &absolute_source);
void GlobSourcesAbsolute(const fs::path &absolute_source_dir);
const fs_unordered_set &GetSourceFiles() const {
const auto &t = static_cast<const T &>(*this);
return t.user_.sources;
}

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());
}

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

for (const auto &p : fs::directory_iterator(absolute_source_dir)) {
if (t.toolchain_.GetConfig().IsValidSource(p.path())) {
AddSourceAbsolute(p.path());
}
}
}

void AddSource(const fs::path &relative_source,
const fs::path &relative_to_target_path = "");
void GlobSources(const fs::path &relative_to_target_path = "");
const fs::path &relative_to_target_path = "") {
auto &t = static_cast<T &>(*this);

// Compute the absolute source path
fs::path absolute_source =
t.env_.GetTargetRootDir() / relative_to_target_path / relative_source;
AddSourceAbsolute(absolute_source);
}

void GlobSources(const fs::path &relative_to_target_path = "") {
auto &t = static_cast<T &>(*this);

fs::path absolute_input_path =
t.env_.GetTargetRootDir() / relative_to_target_path;
for (const auto &p : fs::directory_iterator(absolute_input_path)) {
if (t.toolchain_.GetConfig().IsValidSource(p.path())) {
AddSourceAbsolute(p.path());
}
}
}
};

} // namespace buildcc::internal
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp