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 cleanup#198

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 12 commits intomainfromtoolchain_updates
Mar 18, 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
23 changes: 11 additions & 12 deletionsbuildcc/lib/args/include/args/args.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -48,33 +48,32 @@ struct ArgToolchainState {
struct ArgToolchain {
ArgToolchain(){};
ArgToolchain(ToolchainId initial_id, const std::string &initial_name,
const std::string &initial_asm_compiler,
const ToolchainBinaries &initial_binaries)
: id(initial_id), name(initial_name), binaries(initial_binaries) {}
ArgToolchain(ToolchainId initial_id, const std::string &initial_name,
const std::string &initial_assembler,
const std::string &initial_c_compiler,
const std::string &initial_cpp_compiler,
const std::string &initial_archiver,
const std::string &initial_linker)
: id(initial_id), name(initial_name), asm_compiler(initial_asm_compiler),
c_compiler(initial_c_compiler), cpp_compiler(initial_cpp_compiler),
archiver(initial_archiver), linker(initial_linker) {}
: ArgToolchain(initial_id, initial_name,
ToolchainBinaries(initial_assembler, initial_c_compiler,
initial_cpp_compiler, initial_archiver,
initial_linker)) {}

/**
* @brief Construct a BaseToolchain from the arguments supplied through the
* command line information
*/
// TODO, Update this for lock and ToolchainConfig
BaseToolchain ConstructToolchain() const {
BaseToolchain toolchain(id, name, asm_compiler, c_compiler, cpp_compiler,
archiver, linker);
return toolchain;
return BaseToolchain(id, name, binaries);
}

ArgToolchainState state;
ToolchainId id{ToolchainId::Undefined};
std::string name{""};
std::string asm_compiler{""};
std::string c_compiler{""};
std::string cpp_compiler{""};
std::string archiver{""};
std::string linker{""};
ToolchainBinaries binaries;
};

// NOTE, Incomplete without pch_compile_command
Expand Down
22 changes: 11 additions & 11 deletionsbuildcc/lib/args/src/args.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -75,7 +75,7 @@ const std::unordered_map<const char *, buildcc::env::LogLevel> kLogLevelMap{
{"critical", buildcc::env::LogLevel::Critical},
};

const std::unordered_map<const char *, buildcc::Toolchain::Id> kToolchainIdMap{
const std::unordered_map<const char *, buildcc::ToolchainId> kToolchainIdMap{
{"gcc", buildcc::ToolchainId::Gcc},
{"msvc", buildcc::ToolchainId::Msvc},
{"mingw", buildcc::ToolchainId::MinGW},
Expand All@@ -99,16 +99,16 @@ void Args::AddToolchain(const std::string &name, const std::string &description,
->transform(CLI::CheckedTransformer(kToolchainIdMap, CLI::ignore_case))
->default_val(initial.id);
t_user->add_option(kToolchainNameParam, out.name)->default_val(initial.name);
t_user->add_option(kToolchainAsmCompilerParam, out.asm_compiler)
->default_val(initial.asm_compiler);
t_user->add_option(kToolchainCCompilerParam, out.c_compiler)
->default_val(initial.c_compiler);
t_user->add_option(kToolchainCppCompilerParam, out.cpp_compiler)
->default_val(initial.cpp_compiler);
t_user->add_option(kToolchainArchiverParam, out.archiver)
->default_val(initial.archiver);
t_user->add_option(kToolchainLinkerParam, out.linker)
->default_val(initial.linker);
t_user->add_option(kToolchainAsmCompilerParam, out.binaries.assembler)
->default_val(initial.binaries.assembler);
t_user->add_option(kToolchainCCompilerParam, out.binaries.c_compiler)
->default_val(initial.binaries.c_compiler);
t_user->add_option(kToolchainCppCompilerParam, out.binaries.cpp_compiler)
->default_val(initial.binaries.cpp_compiler);
t_user->add_option(kToolchainArchiverParam, out.binaries.archiver)
->default_val(initial.binaries.archiver);
t_user->add_option(kToolchainLinkerParam, out.binaries.linker)
->default_val(initial.binaries.linker);
}

void Args::AddTarget(const std::string &name, const std::string &description,
Expand Down
72 changes: 36 additions & 36 deletionsbuildcc/lib/args/test/test_args.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -66,13 +66,13 @@ TEST(ArgsTestGroup, Args_CustomToolchain) {
// Toolchain
CHECK_TRUE(gcc_toolchain.state.build);
CHECK_FALSE(gcc_toolchain.state.test);
CHECK(gcc_toolchain.id == buildcc::Toolchain::Id::Gcc);
CHECK(gcc_toolchain.id == buildcc::ToolchainId::Gcc);
STRCMP_EQUAL(gcc_toolchain.name.c_str(), "gcc");
STRCMP_EQUAL(gcc_toolchain.asm_compiler.c_str(), "as");
STRCMP_EQUAL(gcc_toolchain.c_compiler.c_str(), "gcc");
STRCMP_EQUAL(gcc_toolchain.cpp_compiler.c_str(), "g++");
STRCMP_EQUAL(gcc_toolchain.archiver.c_str(), "ar");
STRCMP_EQUAL(gcc_toolchain.linker.c_str(), "ld");
STRCMP_EQUAL(gcc_toolchain.binaries.assembler.c_str(), "as");
STRCMP_EQUAL(gcc_toolchain.binaries.c_compiler.c_str(), "gcc");
STRCMP_EQUAL(gcc_toolchain.binaries.cpp_compiler.c_str(), "g++");
STRCMP_EQUAL(gcc_toolchain.binaries.archiver.c_str(), "ar");
STRCMP_EQUAL(gcc_toolchain.binaries.linker.c_str(), "ld");
}

TEST(ArgsTestGroup, Args_MultipleCustomToolchain) {
Expand DownExpand Up@@ -104,24 +104,24 @@ TEST(ArgsTestGroup, Args_MultipleCustomToolchain) {
// GCC
CHECK_TRUE(gcc_toolchain.state.build);
CHECK_FALSE(gcc_toolchain.state.test);
CHECK(gcc_toolchain.id == buildcc::Toolchain::Id::Gcc);
CHECK(gcc_toolchain.id == buildcc::ToolchainId::Gcc);
STRCMP_EQUAL(gcc_toolchain.name.c_str(), "gcc");
STRCMP_EQUAL(gcc_toolchain.asm_compiler.c_str(), "as");
STRCMP_EQUAL(gcc_toolchain.c_compiler.c_str(), "gcc");
STRCMP_EQUAL(gcc_toolchain.cpp_compiler.c_str(), "g++");
STRCMP_EQUAL(gcc_toolchain.archiver.c_str(), "ar");
STRCMP_EQUAL(gcc_toolchain.linker.c_str(), "ld");
STRCMP_EQUAL(gcc_toolchain.binaries.assembler.c_str(), "as");
STRCMP_EQUAL(gcc_toolchain.binaries.c_compiler.c_str(), "gcc");
STRCMP_EQUAL(gcc_toolchain.binaries.cpp_compiler.c_str(), "g++");
STRCMP_EQUAL(gcc_toolchain.binaries.archiver.c_str(), "ar");
STRCMP_EQUAL(gcc_toolchain.binaries.linker.c_str(), "ld");

// MSVC
CHECK_TRUE(msvc_toolchain.state.build);
CHECK_TRUE(msvc_toolchain.state.test);
CHECK(msvc_toolchain.id == buildcc::Toolchain::Id::Msvc);
CHECK(msvc_toolchain.id == buildcc::ToolchainId::Msvc);
STRCMP_EQUAL(msvc_toolchain.name.c_str(), "msvc");
STRCMP_EQUAL(msvc_toolchain.asm_compiler.c_str(), "cl");
STRCMP_EQUAL(msvc_toolchain.c_compiler.c_str(), "cl");
STRCMP_EQUAL(msvc_toolchain.cpp_compiler.c_str(), "cl");
STRCMP_EQUAL(msvc_toolchain.archiver.c_str(), "lib");
STRCMP_EQUAL(msvc_toolchain.linker.c_str(), "link");
STRCMP_EQUAL(msvc_toolchain.binaries.assembler.c_str(), "cl");
STRCMP_EQUAL(msvc_toolchain.binaries.c_compiler.c_str(), "cl");
STRCMP_EQUAL(msvc_toolchain.binaries.cpp_compiler.c_str(), "cl");
STRCMP_EQUAL(msvc_toolchain.binaries.archiver.c_str(), "lib");
STRCMP_EQUAL(msvc_toolchain.binaries.linker.c_str(), "link");
}

TEST(ArgsTestGroup, Args_DuplicateCustomToolchain) {
Expand DownExpand Up@@ -165,13 +165,13 @@ TEST(ArgsTestGroup, Args_CustomTarget) {
// Toolchain
CHECK_TRUE(gcc_toolchain.state.build);
CHECK_FALSE(gcc_toolchain.state.test);
CHECK(gcc_toolchain.id == buildcc::Toolchain::Id::Gcc);
CHECK(gcc_toolchain.id == buildcc::ToolchainId::Gcc);
STRCMP_EQUAL(gcc_toolchain.name.c_str(), "gcc");
STRCMP_EQUAL(gcc_toolchain.asm_compiler.c_str(), "as");
STRCMP_EQUAL(gcc_toolchain.c_compiler.c_str(), "gcc");
STRCMP_EQUAL(gcc_toolchain.cpp_compiler.c_str(), "g++");
STRCMP_EQUAL(gcc_toolchain.archiver.c_str(), "ar");
STRCMP_EQUAL(gcc_toolchain.linker.c_str(), "ld");
STRCMP_EQUAL(gcc_toolchain.binaries.assembler.c_str(), "as");
STRCMP_EQUAL(gcc_toolchain.binaries.c_compiler.c_str(), "gcc");
STRCMP_EQUAL(gcc_toolchain.binaries.cpp_compiler.c_str(), "g++");
STRCMP_EQUAL(gcc_toolchain.binaries.archiver.c_str(), "ar");
STRCMP_EQUAL(gcc_toolchain.binaries.linker.c_str(), "ld");

// Target
STRCMP_EQUAL(gcc_target.compile_command.c_str(),
Expand DownExpand Up@@ -219,13 +219,13 @@ TEST(ArgsTestGroup, Args_MultipleCustomTarget) {
// Toolchain
CHECK_TRUE(gcc_toolchain.state.build);
CHECK_FALSE(gcc_toolchain.state.test);
CHECK(gcc_toolchain.id == buildcc::Toolchain::Id::Gcc);
CHECK(gcc_toolchain.id == buildcc::ToolchainId::Gcc);
STRCMP_EQUAL(gcc_toolchain.name.c_str(), "gcc");
STRCMP_EQUAL(gcc_toolchain.asm_compiler.c_str(), "as");
STRCMP_EQUAL(gcc_toolchain.c_compiler.c_str(), "gcc");
STRCMP_EQUAL(gcc_toolchain.cpp_compiler.c_str(), "g++");
STRCMP_EQUAL(gcc_toolchain.archiver.c_str(), "ar");
STRCMP_EQUAL(gcc_toolchain.linker.c_str(), "ld");
STRCMP_EQUAL(gcc_toolchain.binaries.assembler.c_str(), "as");
STRCMP_EQUAL(gcc_toolchain.binaries.c_compiler.c_str(), "gcc");
STRCMP_EQUAL(gcc_toolchain.binaries.cpp_compiler.c_str(), "g++");
STRCMP_EQUAL(gcc_toolchain.binaries.archiver.c_str(), "ar");
STRCMP_EQUAL(gcc_toolchain.binaries.linker.c_str(), "ld");

// Target
STRCMP_EQUAL(gcc_target.compile_command.c_str(),
Expand All@@ -240,13 +240,13 @@ TEST(ArgsTestGroup, Args_MultipleCustomTarget) {
// Toolchain
CHECK_TRUE(msvc_toolchain.state.build);
CHECK_TRUE(msvc_toolchain.state.test);
CHECK(msvc_toolchain.id == buildcc::Toolchain::Id::Msvc);
CHECK(msvc_toolchain.id == buildcc::ToolchainId::Msvc);
STRCMP_EQUAL(msvc_toolchain.name.c_str(), "msvc");
STRCMP_EQUAL(msvc_toolchain.asm_compiler.c_str(), "cl");
STRCMP_EQUAL(msvc_toolchain.c_compiler.c_str(), "cl");
STRCMP_EQUAL(msvc_toolchain.cpp_compiler.c_str(), "cl");
STRCMP_EQUAL(msvc_toolchain.archiver.c_str(), "lib");
STRCMP_EQUAL(msvc_toolchain.linker.c_str(), "link");
STRCMP_EQUAL(msvc_toolchain.binaries.assembler.c_str(), "cl");
STRCMP_EQUAL(msvc_toolchain.binaries.c_compiler.c_str(), "cl");
STRCMP_EQUAL(msvc_toolchain.binaries.cpp_compiler.c_str(), "cl");
STRCMP_EQUAL(msvc_toolchain.binaries.archiver.c_str(), "lib");
STRCMP_EQUAL(msvc_toolchain.binaries.linker.c_str(), "link");

// Target
STRCMP_EQUAL(msvc_target.compile_command.c_str(),
Expand Down
14 changes: 7 additions & 7 deletionsbuildcc/lib/args/test/test_register.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -100,7 +100,7 @@ TEST(RegisterTestGroup, Register_Build) {

// Make dummy toolchain and target
buildcc::env::init(fs::current_path(), fs::current_path());
buildcc::Toolchain toolchain(buildcc::Toolchain::Id::Gcc, "", "", "", "", "",
buildcc::Toolchain toolchain(buildcc::ToolchainId::Gcc, "", "", "", "", "",
"");
buildcc::BaseTarget target("dummyT", buildcc::TargetType::Executable,
toolchain, "");
Expand DownExpand Up@@ -148,7 +148,7 @@ TEST(RegisterTestGroup, Register_NoBuildAndDep) {

// Make dummy toolchain and target
buildcc::env::init(fs::current_path(), fs::current_path());
buildcc::Toolchain toolchain(buildcc::Toolchain::Id::Gcc, "", "", "", "", "",
buildcc::Toolchain toolchain(buildcc::ToolchainId::Gcc, "", "", "", "", "",
"");
buildcc::BaseTarget target("dummyT", buildcc::TargetType::Executable,
toolchain, "");
Expand DownExpand Up@@ -232,7 +232,7 @@ TEST(RegisterTestGroup, Register_BuildAndDep) {

// Make dummy toolchain and target
buildcc::env::init(fs::current_path(), fs::current_path());
buildcc::Toolchain toolchain(buildcc::Toolchain::Id::Gcc, "", "", "", "", "",
buildcc::Toolchain toolchain(buildcc::ToolchainId::Gcc, "", "", "", "", "",
"");
buildcc::BaseTarget target("dummyT", buildcc::TargetType::Executable,
toolchain, "");
Expand DownExpand Up@@ -327,7 +327,7 @@ TEST(RegisterTestGroup, Register_DepDuplicate) {

// Make dummy toolchain and target
buildcc::env::init(fs::current_path(), fs::current_path());
buildcc::Toolchain toolchain(buildcc::Toolchain::Id::Gcc, "", "", "", "", "",
buildcc::Toolchain toolchain(buildcc::ToolchainId::Gcc, "", "", "", "", "",
"");
buildcc::BaseTarget target("dummyT", buildcc::TargetType::Executable,
toolchain, "");
Expand DownExpand Up@@ -403,7 +403,7 @@ TEST(RegisterTestGroup, Register_DepCyclic) {

// Make dummy toolchain and target
buildcc::env::init(fs::current_path(), fs::current_path());
buildcc::Toolchain toolchain(buildcc::Toolchain::Id::Gcc, "", "", "", "", "",
buildcc::Toolchain toolchain(buildcc::ToolchainId::Gcc, "", "", "", "", "",
"");
buildcc::BaseTarget target("dummyT", buildcc::TargetType::Executable,
toolchain, "");
Expand DownExpand Up@@ -479,7 +479,7 @@ TEST(RegisterTestGroup, Register_Test) {

// Make dummy toolchain and target
buildcc::env::init(fs::current_path(), fs::current_path());
buildcc::Toolchain toolchain(buildcc::Toolchain::Id::Gcc, "", "", "", "", "",
buildcc::Toolchain toolchain(buildcc::ToolchainId::Gcc, "", "", "", "", "",
"");
buildcc::BaseTarget target("dummyT", buildcc::TargetType::Executable,
toolchain, "");
Expand DownExpand Up@@ -564,7 +564,7 @@ TEST(RegisterTestGroup, Register_TestWithOutput) {

// Make dummy toolchain and target
buildcc::env::init(fs::current_path(), fs::current_path());
buildcc::Toolchain toolchain(buildcc::Toolchain::Id::Gcc, "", "", "", "", "",
buildcc::Toolchain toolchain(buildcc::ToolchainId::Gcc, "", "", "", "", "",
"");
buildcc::BaseTarget target("dummyT", buildcc::TargetType::Executable,
toolchain, "");
Expand Down
4 changes: 4 additions & 0 deletionsbuildcc/lib/target/include/target/api/target_getter.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,6 +24,7 @@

#include "toolchain/toolchain.h"

#include "target/common/target_config.h"
#include "target/common/target_state.h"

#include "taskflow/taskflow.hpp"
Expand All@@ -39,6 +40,9 @@ template <typename T> class TargetGetter {
bool IsBuilt() const;
bool IsLocked() const;

// Target Config
const TargetConfig &GetConfig() const;

const std::string &GetName() const;
const Toolchain &GetToolchain() const;
TargetType GetType() const;
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,7 +19,6 @@

#include "schema/path.h"

#include "target/common/target_config.h"
#include "target/common/target_state.h"

namespace buildcc::internal {
Expand All@@ -34,9 +33,6 @@ template <typename T> class TargetInfoGetter {
const fs::path &GetTargetRootDir() const;
const fs::path &GetTargetBuildDir() const;

// Target Config
const TargetConfig &GetConfig() const;

// Target Storer
const fs_unordered_set &GetSourceFiles() const;
const fs_unordered_set &GetHeaderFiles() const;
Expand Down
11 changes: 5 additions & 6 deletionsbuildcc/lib/target/include/target/target.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -69,12 +69,10 @@ class Target : public internal::BuilderInterface,
explicit Target(const std::string &name, TargetType type,
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),
: TargetInfo(toolchain, TargetEnv(env.GetTargetRootDir(),
env.GetTargetBuildDir() /
toolchain.GetName() / name)),
name_(name), type_(type), config_(config),
serialization_(env_.GetTargetBuildDir() / fmt::format("{}.bin", name)),
compile_pch_(*this), compile_object_(*this), link_target_(*this) {
Initialize();
Expand DownExpand Up@@ -139,6 +137,7 @@ class Target : public internal::BuilderInterface,
private:
std::string name_;
TargetType type_;
TargetConfig config_;
internal::TargetSerialization serialization_;
internal::CompilePch compile_pch_;
internal::CompileObject compile_object_;
Expand Down
8 changes: 3 additions & 5 deletionsbuildcc/lib/target/include/target/target_info.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -61,9 +61,8 @@ class TargetInfo : public internal::SourceApi<TargetInfo>,
public internal::SyncApi<TargetInfo>,
public internal::TargetInfoGetter<TargetInfo> {
public:
TargetInfo(const BaseToolchain &toolchain, const TargetEnv &env,
const TargetConfig &config = TargetConfig())
: toolchain_(toolchain), env_(env), config_(config) {
TargetInfo(const BaseToolchain &toolchain, const TargetEnv &env)
: toolchain_(toolchain), env_(env) {
Initialize();
}

Expand All@@ -85,11 +84,10 @@ class TargetInfo : public internal::SourceApi<TargetInfo>,
protected:
const BaseToolchain &toolchain_;
TargetEnv env_;
TargetConfig config_;

//
UserTargetSchema user_;
FunctionLock lock_;
UserTargetSchema user_;

private:
void Initialize();
Expand Down
7 changes: 7 additions & 0 deletionsbuildcc/lib/target/src/api/target_getter.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -33,6 +33,13 @@ template <typename T> bool TargetGetter<T>::IsBuilt() const {
return t.state_.IsBuilt();
}

// Target Config
template <typename T> const TargetConfig &TargetGetter<T>::GetConfig() const {
const T &t = static_cast<const T &>(*this);

return t.config_;
}

template <typename T> bool TargetGetter<T>::IsLocked() const {
const T &t = static_cast<const T &>(*this);

Expand Down
8 changes: 0 additions & 8 deletionsbuildcc/lib/target/src/api/target_info_getter.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,14 +35,6 @@ const fs::path &TargetInfoGetter<T>::GetTargetBuildDir() const {
return t.env_.GetTargetBuildDir();
}

// Target Config
template <typename T>
const TargetConfig &TargetInfoGetter<T>::GetConfig() const {
const T &t = static_cast<const T &>(*this);

return t.config_;
}

// Target Storer
template <typename T>
const fs_unordered_set &TargetInfoGetter<T>::GetSourceFiles() const {
Expand Down
4 changes: 2 additions & 2 deletionsbuildcc/lib/target/src/target/build.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -54,7 +54,7 @@ namespace buildcc {
void Target::Build() {
env::log_trace(name_, __FUNCTION__);

lock_.ExpectsUnlock(__FUNCTION__);
lock_.ExpectsUnlock("Target::Build");
lock_.Lock();

// PCH state
Expand DownExpand Up@@ -87,7 +87,7 @@ void Target::Build() {
{kLinkFlags, internal::aggregate(GetLinkFlags())},

// Toolchain executables here
{kAsmCompiler, fmt::format("{}", fs::path(toolchain_.GetAsmCompiler()))},
{kAsmCompiler, fmt::format("{}", fs::path(toolchain_.GetAssembler()))},
{kCCompiler, fmt::format("{}", fs::path(toolchain_.GetCCompiler()))},
{kCppCompiler, fmt::format("{}", fs::path(toolchain_.GetCppCompiler()))},
{kArchiver, fmt::format("{}", fs::path(toolchain_.GetArchiver()))},
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp