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

Toolchain config#194

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 23 commits intomainfromtoolchain_config
Feb 21, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
23 commits
Select commitHold shift + click to select a range
c8b570f
Update schema.cmake
coder137Feb 20, 2022
8099670
Added toolchain_config.h
coder137Feb 20, 2022
38f196f
Create file_ext.h
coder137Feb 20, 2022
7a22863
Update CMakeLists.txt
coder137Feb 20, 2022
c10605f
Update toolchain.h
coder137Feb 20, 2022
4f6de50
Add toolchain_ to target_info
coder137Feb 21, 2022
a1c939f
Update build_buildcc.cpp
coder137Feb 21, 2022
a1c5b32
Update build.cpp
coder137Feb 21, 2022
ae26cd0
Updated TargetConfig
coder137Feb 21, 2022
c64f63c
Delete target_file_ext.h
coder137Feb 21, 2022
bcf9672
Rename TargetFileExt to FileExt
coder137Feb 21, 2022
72d1ddf
Removed target_file_ext from targets
coder137Feb 21, 2022
a3c9fc8
Use toolchain_.config instead of target_.config for toolchain specifi…
coder137Feb 21, 2022
d94f224
Removed test_target_config test
coder137Feb 21, 2022
059c3eb
Added test_toolchain_config to toolchain
coder137Feb 21, 2022
3f93c95
Updated toolchain.h with UpdateConfig virtual function
coder137Feb 21, 2022
531320f
Update build_env_setup.cpp
coder137Feb 21, 2022
e476913
Update build_buildcc.cpp
coder137Feb 21, 2022
e85e082
Update msvc-analysis.yml
coder137Feb 21, 2022
ef6989e
Updated documentation with toolchain_utils
coder137Feb 21, 2022
1b99baa
Updated target and mock_target
coder137Feb 21, 2022
7e9ec32
Update buildcc_interface_lib.PNG
coder137Feb 21, 2022
da5b9b5
Update software_heirarchy.rst
coder137Feb 21, 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
2 changes: 1 addition & 1 deletion.github/workflows/msvc-analysis.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,7 +25,7 @@ env:
jobs:
analyze:
name: Analyze
runs-on: windows-latest
runs-on: windows-2019

steps:
- name: Checkout repository
Expand Down
18 changes: 11 additions & 7 deletionsbootstrap/src/build_buildcc.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -62,9 +62,11 @@ void buildcc_cb(BaseTarget &target, const BaseGenerator &schema_gen,

// TOOLCHAIN
target.GlobSources("lib/toolchain/src/api");
target.GlobSources("lib/toolchain/src/common");
target.AddIncludeDir("lib/toolchain/include");
target.GlobHeaders("lib/toolchain/include/toolchain");
target.GlobHeaders("lib/toolchain/include/toolchain/api");
target.GlobHeaders("lib/toolchain/include/toolchain/common");

// TARGET
target.GlobSources("lib/target/src/common");
Expand DownExpand Up@@ -205,33 +207,35 @@ void BuildBuildCC::Setup(const ArgToolchainState &state) {

// Flatbuffers HO lib
auto &flatbuffers_ho_lib = storage_.Add<TargetInfo>(
kFlatbuffersHoName,
kFlatbuffersHoName, toolchain_,
TargetEnv(env_.GetTargetRootDir() / "third_party" / "flatbuffers",
env_.GetTargetBuildDir()));
reg_.CallbackIf(state, flatbuffers_ho_cb, flatbuffers_ho_lib);

// CLI11 HO lib
auto &cli11_ho_lib = storage_.Add<TargetInfo>(
kCli11HoName, TargetEnv(env_.GetTargetRootDir() / "third_party" / "CLI11",
env_.GetTargetBuildDir()));
kCli11HoName, toolchain_,
TargetEnv(env_.GetTargetRootDir() / "third_party" / "CLI11",
env_.GetTargetBuildDir()));
reg_.CallbackIf(state, cli11_ho_cb, cli11_ho_lib);

// fmt HO lib
auto &fmt_ho_lib = storage_.Add<TargetInfo>(
kFmtHoName, TargetEnv(env_.GetTargetRootDir() / "third_party" / "fmt",
env_.GetTargetBuildDir()));
kFmtHoName, toolchain_,
TargetEnv(env_.GetTargetRootDir() / "third_party" / "fmt",
env_.GetTargetBuildDir()));
reg_.CallbackIf(state, fmt_ho_cb, fmt_ho_lib);

// spdlog HO lib
auto &spdlog_ho_lib = storage_.Add<TargetInfo>(
kSpdlogHoName,
kSpdlogHoName, toolchain_,
TargetEnv(env_.GetTargetRootDir() / "third_party" / "spdlog",
env_.GetTargetBuildDir()));
reg_.CallbackIf(state, spdlog_ho_cb, spdlog_ho_lib);

// taskflow HO lib
auto &taskflow_ho_lib = storage_.Add<TargetInfo>(
kTaskflowHoName,
kTaskflowHoName, toolchain_,
TargetEnv(env_.GetTargetRootDir() / "third_party" / "taskflow",
env_.GetTargetBuildDir()));
reg_.CallbackIf(state, taskflow_ho_cb, taskflow_ho_lib);
Expand Down
1 change: 0 additions & 1 deletionbuildcc/lib/target/cmake/common_target_src.cmake
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,6 @@ set(COMMON_TARGET_SRCS
src/common/target_state.cpp
include/target/common/target_config.h
include/target/common/target_state.h
include/target/common/target_file_ext.h
include/target/common/target_env.h

src/common/util.cpp
Expand Down
1 change: 0 additions & 1 deletionbuildcc/lib/target/cmake/mock_target.cmake
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,7 +21,6 @@ target_link_options(mock_target PUBLIC ${TEST_LINK_FLAGS} ${BUILD_LINK_FLAGS})
target_link_libraries(mock_target PUBLIC
Taskflow

mock_schema
mock_toolchain

CppUTest
Expand Down
1 change: 0 additions & 1 deletionbuildcc/lib/target/cmake/target.cmake
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,7 +28,6 @@ if(${BUILDCC_BUILD_AS_INTERFACE})
$<INSTALL_INTERFACE:${BUILDCC_INSTALL_HEADER_PREFIX}>
)
target_link_libraries(target PUBLIC
schema
toolchain
Taskflow
)
Expand Down
66 changes: 0 additions & 66 deletionsbuildcc/lib/target/include/target/common/target_config.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,86 +21,20 @@
#include <string>
#include <unordered_set>

#include "target/common/target_file_ext.h"

namespace fs = std::filesystem;

namespace buildcc {

struct TargetConfig {
TargetConfig() = default;

/**
* @brief Get the valid file extension from a path
*
* See TargetConfig::valid_c_ext, TargetConfig::valid_cpp_ext,
* TargetConfig::valid_asm_ext, TargetConfig::valid_header_ext
*
* @param filepath Absolute / Relative path of the file
* @return TargetFileExt File path detected as per TargetConfig::valid_*
* variables
*/
TargetFileExt GetFileExt(const fs::path &filepath) const;

/**
* @brief Checks for C/C++ source file validity.
*
* See TargetConfig::valid_c_ext, TargetConfig::valid_cpp_ext,
* TargetConfig::valid_asm_ext
*
* @param filepath Absolute / Relative path of file
* @return true If file extension belongs to the above valid_* list
* @return false If file extension does not belong to the above valid_* list
*/
bool IsValidSource(const fs::path &filepath) const;

/**
* @brief Checks for Header file validity
*
* See TargetConfig::valid_header_ext
*
* @param filepath Absolute / Relative path of file
* @return true If file extension belongs to above valid_* list
* @return false If file extension does not belong to above valid_* list
*/
bool IsValidHeader(const fs::path &filepath) const;

/**
* @brief Expects Source file validity
*
* env::assert_fatal if not a valid source
*
* @param filepath Absolute / Relative path of file
*/
void ExpectsValidSource(const fs::path &filepath) const;

/**
* @brief Expects header file validity
*
* env::assert_fatal if not a valid header
*
* @param filepath Absolute / Relative path of file
*/
void ExpectsValidHeader(const fs::path &filepath) const;

std::string target_ext{""};
std::string obj_ext{".o"};
std::string pch_header_ext{".h"};
std::string pch_compile_ext{".gch"};

std::string prefix_include_dir{"-I"};
std::string prefix_lib_dir{"-L"};

// clang-format off
std::string pch_command{"{compiler} {preprocessor_flags} {include_dirs} {common_compile_flags} {pch_compile_flags} {compile_flags} -o {output} -c {input}"};
std::string compile_command{"{compiler} {preprocessor_flags} {include_dirs} {common_compile_flags} {pch_object_flags} {compile_flags} -o {output} -c {input}"};
std::string link_command{"{cpp_compiler} {link_flags} {compiled_sources} -o {output} {lib_dirs} {lib_deps}"};
// clang-format on

std::unordered_set<std::string> valid_c_ext{".c"};
std::unordered_set<std::string> valid_cpp_ext{".cpp", ".cxx", ".cc"};
std::unordered_set<std::string> valid_asm_ext{".s", ".S", ".asm"};
std::unordered_set<std::string> valid_header_ext{".h", ".hpp"};
};

} // namespace buildcc
Expand Down
4 changes: 2 additions & 2 deletionsbuildcc/lib/target/include/target/common/target_state.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,7 +17,7 @@
#ifndef TARGET_COMMON_TARGET_STATE_H_
#define TARGET_COMMON_TARGET_STATE_H_

#include "target/common/target_file_ext.h"
#include "toolchain/common/file_ext.h"

namespace buildcc {

Expand All@@ -27,7 +27,7 @@ namespace buildcc {
// TargetInfo does not have a `Build` method, it is only meant to hold
// information
struct TargetState {
void SetSourceState(TargetFileExt file_extension);
void SetSourceState(FileExt file_extension);
void SetPch();
void SetLock();

Expand Down
10 changes: 6 additions & 4 deletionsbuildcc/lib/target/include/target/target.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -70,10 +70,12 @@ class Target : public internal::BuilderInterface,
const Toolchain &toolchain, const TargetEnv &env,
const TargetConfig &config = TargetConfig())
: TargetInfo(
toolchain,
TargetEnv(env.GetTargetRootDir(),
env.GetTargetBuildDir() / toolchain.GetName() / name),
config),
name_(name), type_(type), toolchain_(toolchain),
name_(name), type_(type),
// toolchain_(toolchain),
// loader_(name, env_.GetTargetBuildDir()),
serialization_(env_.GetTargetBuildDir() / fmt::format("{}.bin", name)),
compile_pch_(*this), compile_object_(*this), link_target_(*this) {
Expand All@@ -99,8 +101,8 @@ class Target : public internal::BuilderInterface,
void Initialize();

//
std::optional<std::string> SelectCompileFlags(TargetFileExt ext) const;
std::optional<std::string> SelectCompiler(TargetFileExt ext) const;
std::optional<std::string> SelectCompileFlags(FileExt ext) const;
std::optional<std::string> SelectCompiler(FileExt ext) const;

// Recompilation checks
void RecheckPaths(const internal::path_unordered_set &previous_path,
Expand DownExpand Up@@ -139,7 +141,7 @@ class Target : public internal::BuilderInterface,
private:
std::string name_;
TargetType type_;
const Toolchain &toolchain_;
//const Toolchain &toolchain_;
internal::TargetSerialization serialization_;

// Friend classes
Expand Down
8 changes: 6 additions & 2 deletionsbuildcc/lib/target/include/target/target_info.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,6 +19,8 @@

#include <string>

#include "toolchain/toolchain.h"

#include "target/common/target_config.h"
#include "target/common/target_env.h"
#include "target/common/target_state.h"
Expand DownExpand Up@@ -60,8 +62,9 @@ class TargetInfo : public internal::SourceApi<TargetInfo>,
public internal::SyncApi<TargetInfo>,
public internal::TargetInfoGetter<TargetInfo> {
public:
TargetInfo(const TargetEnv &env, const TargetConfig &config = TargetConfig())
: env_(env), config_(config) {}
TargetInfo(const BaseToolchain &toolchain, const TargetEnv &env,
const TargetConfig &config = TargetConfig())
: toolchain_(toolchain), env_(env), config_(config) {}

private:
// Inputs
Expand All@@ -79,6 +82,7 @@ class TargetInfo : public internal::SourceApi<TargetInfo>,
friend class internal::TargetInfoGetter<TargetInfo>;

protected:
const BaseToolchain &toolchain_;
TargetEnv env_;
TargetConfig config_;

Expand Down
4 changes: 2 additions & 2 deletionsbuildcc/lib/target/src/api/include_api.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,7 +25,7 @@ void IncludeApi<T>::AddHeaderAbsolute(const fs::path &absolute_filepath) {
T &t = static_cast<T &>(*this);

t.state_.ExpectsUnlock();
t.config_.ExpectsValidHeader(absolute_filepath);
t.toolchain_.GetConfig().ExpectsValidHeader(absolute_filepath);
t.user_.headers.insert(absolute_filepath);
}

Expand DownExpand Up@@ -53,7 +53,7 @@ void IncludeApi<T>::GlobHeadersAbsolute(const fs::path &absolute_path) {
T &t = static_cast<T &>(*this);

for (const auto &p : fs::directory_iterator(absolute_path)) {
if (t.config_.IsValidHeader(p.path())) {
if (t.toolchain_.GetConfig().IsValidHeader(p.path())) {
AddHeaderAbsolute(p.path());
}
}
Expand Down
2 changes: 1 addition & 1 deletionbuildcc/lib/target/src/api/pch_api.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,7 +25,7 @@ void PchApi<T>::AddPchAbsolute(const fs::path &absolute_filepath) {
T &t = static_cast<T &>(*this);

t.state_.ExpectsUnlock();
t.config_.ExpectsValidHeader(absolute_filepath);
t.toolchain_.GetConfig().ExpectsValidHeader(absolute_filepath);

const fs::path absolute_pch = fs::path(absolute_filepath).make_preferred();
t.user_.pchs.insert(absolute_pch);
Expand Down
6 changes: 3 additions & 3 deletionsbuildcc/lib/target/src/api/source_api.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,7 +25,7 @@ void SourceApi<T>::AddSourceAbsolute(const fs::path &absolute_source) {
T &t = static_cast<T &>(*this);

t.state_.ExpectsUnlock();
t.config_.ExpectsValidSource(absolute_source);
t.toolchain_.GetConfig().ExpectsValidSource(absolute_source);
t.user_.sources.emplace(fs::path(absolute_source).make_preferred());
}

Expand All@@ -34,7 +34,7 @@ void SourceApi<T>::GlobSourcesAbsolute(const fs::path &absolute_source_dir) {
T &t = static_cast<T &>(*this);

for (const auto &p : fs::directory_iterator(absolute_source_dir)) {
if (t.config_.IsValidSource(p.path())) {
if (t.toolchain_.GetConfig().IsValidSource(p.path())) {
AddSourceAbsolute(p.path());
}
}
Expand All@@ -59,7 +59,7 @@ void SourceApi<T>::GlobSources(const fs::path &relative_to_target_path) {
fs::path absolute_input_path =
t.env_.GetTargetRootDir() / relative_to_target_path;
for (const auto &p : fs::directory_iterator(absolute_input_path)) {
if (t.config_.IsValidSource(p.path())) {
if (t.toolchain_.GetConfig().IsValidSource(p.path())) {
AddSourceAbsolute(p.path());
}
}
Expand Down
65 changes: 1 addition & 64 deletionsbuildcc/lib/target/src/common/target_config.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,67 +22,4 @@

#include "fmt/format.h"

namespace buildcc {

TargetFileExt TargetConfig::GetFileExt(const fs::path &filepath) const {
if (!filepath.has_extension()) {
return TargetFileExt::Invalid;
}

TargetFileExt type = TargetFileExt::Invalid;
const std::string ext = filepath.extension().string();

if (valid_c_ext.count(ext) == 1) {
type = TargetFileExt::C;
} else if (valid_cpp_ext.count(ext) == 1) {
type = TargetFileExt::Cpp;
} else if (valid_asm_ext.count(ext) == 1) {
type = TargetFileExt::Asm;
} else if (valid_header_ext.count(ext) == 1) {
type = TargetFileExt::Header;
}

return type;
}

bool TargetConfig::IsValidSource(const fs::path &filepath) const {
if (!filepath.has_extension()) {
return false;
}

const std::string ext = filepath.extension().string();
bool valid = false;
if ((valid_c_ext.find(ext) != valid_c_ext.end()) ||
(valid_cpp_ext.find(ext) != valid_cpp_ext.end()) ||
(valid_asm_ext.find(ext) != valid_asm_ext.end())) {
valid = true;
}
return valid;
}

void TargetConfig::ExpectsValidSource(const fs::path &filepath) const {
env::assert_fatal(
IsValidSource(filepath),
fmt::format("{} does not have a valid source extension", filepath));
}

bool TargetConfig::IsValidHeader(const fs::path &filepath) const {
if (!filepath.has_extension()) {
return {};
}

const std::string ext = filepath.extension().string();
bool valid = false;
if ((valid_header_ext.find(ext) != valid_header_ext.end())) {
valid = true;
}
return valid;
}

void TargetConfig::ExpectsValidHeader(const fs::path &filepath) const {
env::assert_fatal(
IsValidHeader(filepath),
fmt::format("{} does not have a valid header extension", filepath));
}

} // namespace buildcc
namespace buildcc {} // namespace buildcc
Loading

[8]ページ先頭

©2009-2025 Movatter.jp