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 find and verify#199

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 46 commits intomainfromtoolchain_find_and_verify
Mar 24, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
46 commits
Select commitHold shift + click to select a range
ea827b1
Added Toolchain find CRTP
coder137Mar 18, 2022
413c8f8
Added test_toolchain_find
coder137Mar 18, 2022
c4897a2
Update toolchain_find.cpp
coder137Mar 19, 2022
b6ee925
Update test_toolchain_find.cpp
coder137Mar 19, 2022
b4a2ff6
Updated toolchain_find API
coder137Mar 19, 2022
b127cf6
Update toolchain_find.h
coder137Mar 20, 2022
920933e
Updated toolchain_verify API
coder137Mar 20, 2022
486b5c3
Update test_toolchain_verify.cpp
coder137Mar 20, 2022
36572e3
Updated toolchain find
coder137Mar 20, 2022
bcd1bcb
Update toolchain_find.h
coder137Mar 20, 2022
17c6317
Update toolchain.h
coder137Mar 20, 2022
d9bfeda
Updated toolchain_verify API
coder137Mar 20, 2022
7a5b3dc
Update toolchain_setup.cpp
coder137Mar 20, 2022
5c69b31
Update build.cpp
coder137Mar 20, 2022
0c71f62
Update test_toolchain_verify.cpp
coder137Mar 20, 2022
cadd0d1
Updated function prototype for VerifySelectedToolchainPath
coder137Mar 21, 2022
58fc928
Updated VerifySelectedToolchainPath
coder137Mar 21, 2022
b0a6c54
Update toolchain_verify.cpp
coder137Mar 22, 2022
f550747
Updated specialized toolchains
coder137Mar 22, 2022
b4098bb
Renamed ToolchainBinaries to ToolchainExecutables
coder137Mar 22, 2022
cf4326f
Updated specialized toolchains
coder137Mar 22, 2022
c5b2f9e
Updated toolchains for virtual functions
coder137Mar 22, 2022
dc68087
Update args.h
coder137Mar 22, 2022
d2dce4f
Renamed binaries to executables
coder137Mar 22, 2022
15db5ea
Update args.cpp
coder137Mar 22, 2022
1a7962d
Update test_args.cpp
coder137Mar 22, 2022
72234c5
Update toolchain_find.cpp
coder137Mar 22, 2022
92ab70e
Added toolchain_executables and toolchain_id header files
coder137Mar 23, 2022
ac079bb
Updated toolchain.h
coder137Mar 23, 2022
aa606f8
Updated toolchain.cpp
coder137Mar 23, 2022
f7cfb77
Updated toolchain_verify
coder137Mar 23, 2022
455b54e
Updated tests
coder137Mar 23, 2022
79c07f8
Updated specialized_toolchains
coder137Mar 23, 2022
490d12c
Update toolchain_verify.cpp
coder137Mar 24, 2022
da33d91
Updated buildexe with toolchain.Verify
coder137Mar 24, 2022
1030886
Update toolchain_id.h
coder137Mar 24, 2022
75e7813
Added test_toolchain_id
coder137Mar 24, 2022
5e972cb
Update test_toolchain_verify.cpp
coder137Mar 24, 2022
74e8060
Update toolchain_verify.cpp
coder137Mar 24, 2022
f05e415
Update test_toolchain_verify.cpp
coder137Mar 24, 2022
6fb51b2
Update test_toolchain_verify.cpp
coder137Mar 24, 2022
eaa57fd
Updated test_toolchain_verify for custom toolchains
coder137Mar 24, 2022
c566b8e
Update test_toolchain_verify.cpp
coder137Mar 24, 2022
b0eff94
Update toolchain_verify.h
coder137Mar 24, 2022
3db102a
Update test_toolchain_verify.cpp
coder137Mar 24, 2022
2eaaec9
Updated GetStatic function
coder137Mar 24, 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
14 changes: 7 additions & 7 deletionsbuildcc/lib/args/include/args/args.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -48,32 +48,32 @@ struct ArgToolchainState {
struct ArgToolchain {
ArgToolchain(){};
ArgToolchain(ToolchainId initial_id, const std::string &initial_name,
constToolchainBinaries &initial_binaries)
: id(initial_id), name(initial_name),binaries(initial_binaries) {}
constToolchainExecutables &initial_executables)
: id(initial_id), name(initial_name),executables(initial_executables) {}
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)
: ArgToolchain(initial_id, initial_name,
ToolchainBinaries(initial_assembler, initial_c_compiler,
initial_cpp_compiler, initial_archiver,
initial_linker)) {}
ToolchainExecutables(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 {
return BaseToolchain(id, name,binaries);
return BaseToolchain(id, name,executables);
}

ArgToolchainState state;
ToolchainId id{ToolchainId::Undefined};
std::string name{""};
ToolchainBinaries binaries;
ToolchainExecutables executables;
};

// NOTE, Incomplete without pch_compile_command
Expand Down
20 changes: 10 additions & 10 deletionsbuildcc/lib/args/src/args.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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.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);
t_user->add_option(kToolchainAsmCompilerParam, out.executables.assembler)
->default_val(initial.executables.assembler);
t_user->add_option(kToolchainCCompilerParam, out.executables.c_compiler)
->default_val(initial.executables.c_compiler);
t_user->add_option(kToolchainCppCompilerParam, out.executables.cpp_compiler)
->default_val(initial.executables.cpp_compiler);
t_user->add_option(kToolchainArchiverParam, out.executables.archiver)
->default_val(initial.executables.archiver);
t_user->add_option(kToolchainLinkerParam, out.executables.linker)
->default_val(initial.executables.linker);
}

void Args::AddTarget(const std::string &name, const std::string &description,
Expand Down
60 changes: 30 additions & 30 deletionsbuildcc/lib/args/test/test_args.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -68,11 +68,11 @@ TEST(ArgsTestGroup, Args_CustomToolchain) {
CHECK_FALSE(gcc_toolchain.state.test);
CHECK(gcc_toolchain.id == buildcc::ToolchainId::Gcc);
STRCMP_EQUAL(gcc_toolchain.name.c_str(), "gcc");
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");
STRCMP_EQUAL(gcc_toolchain.executables.assembler.c_str(), "as");
STRCMP_EQUAL(gcc_toolchain.executables.c_compiler.c_str(), "gcc");
STRCMP_EQUAL(gcc_toolchain.executables.cpp_compiler.c_str(), "g++");
STRCMP_EQUAL(gcc_toolchain.executables.archiver.c_str(), "ar");
STRCMP_EQUAL(gcc_toolchain.executables.linker.c_str(), "ld");
}

TEST(ArgsTestGroup, Args_MultipleCustomToolchain) {
Expand DownExpand Up@@ -106,22 +106,22 @@ TEST(ArgsTestGroup, Args_MultipleCustomToolchain) {
CHECK_FALSE(gcc_toolchain.state.test);
CHECK(gcc_toolchain.id == buildcc::ToolchainId::Gcc);
STRCMP_EQUAL(gcc_toolchain.name.c_str(), "gcc");
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");
STRCMP_EQUAL(gcc_toolchain.executables.assembler.c_str(), "as");
STRCMP_EQUAL(gcc_toolchain.executables.c_compiler.c_str(), "gcc");
STRCMP_EQUAL(gcc_toolchain.executables.cpp_compiler.c_str(), "g++");
STRCMP_EQUAL(gcc_toolchain.executables.archiver.c_str(), "ar");
STRCMP_EQUAL(gcc_toolchain.executables.linker.c_str(), "ld");

// MSVC
CHECK_TRUE(msvc_toolchain.state.build);
CHECK_TRUE(msvc_toolchain.state.test);
CHECK(msvc_toolchain.id == buildcc::ToolchainId::Msvc);
STRCMP_EQUAL(msvc_toolchain.name.c_str(), "msvc");
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");
STRCMP_EQUAL(msvc_toolchain.executables.assembler.c_str(), "cl");
STRCMP_EQUAL(msvc_toolchain.executables.c_compiler.c_str(), "cl");
STRCMP_EQUAL(msvc_toolchain.executables.cpp_compiler.c_str(), "cl");
STRCMP_EQUAL(msvc_toolchain.executables.archiver.c_str(), "lib");
STRCMP_EQUAL(msvc_toolchain.executables.linker.c_str(), "link");
}

TEST(ArgsTestGroup, Args_DuplicateCustomToolchain) {
Expand DownExpand Up@@ -167,11 +167,11 @@ TEST(ArgsTestGroup, Args_CustomTarget) {
CHECK_FALSE(gcc_toolchain.state.test);
CHECK(gcc_toolchain.id == buildcc::ToolchainId::Gcc);
STRCMP_EQUAL(gcc_toolchain.name.c_str(), "gcc");
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");
STRCMP_EQUAL(gcc_toolchain.executables.assembler.c_str(), "as");
STRCMP_EQUAL(gcc_toolchain.executables.c_compiler.c_str(), "gcc");
STRCMP_EQUAL(gcc_toolchain.executables.cpp_compiler.c_str(), "g++");
STRCMP_EQUAL(gcc_toolchain.executables.archiver.c_str(), "ar");
STRCMP_EQUAL(gcc_toolchain.executables.linker.c_str(), "ld");

// Target
STRCMP_EQUAL(gcc_target.compile_command.c_str(),
Expand DownExpand Up@@ -221,11 +221,11 @@ TEST(ArgsTestGroup, Args_MultipleCustomTarget) {
CHECK_FALSE(gcc_toolchain.state.test);
CHECK(gcc_toolchain.id == buildcc::ToolchainId::Gcc);
STRCMP_EQUAL(gcc_toolchain.name.c_str(), "gcc");
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");
STRCMP_EQUAL(gcc_toolchain.executables.assembler.c_str(), "as");
STRCMP_EQUAL(gcc_toolchain.executables.c_compiler.c_str(), "gcc");
STRCMP_EQUAL(gcc_toolchain.executables.cpp_compiler.c_str(), "g++");
STRCMP_EQUAL(gcc_toolchain.executables.archiver.c_str(), "ar");
STRCMP_EQUAL(gcc_toolchain.executables.linker.c_str(), "ld");

// Target
STRCMP_EQUAL(gcc_target.compile_command.c_str(),
Expand All@@ -242,11 +242,11 @@ TEST(ArgsTestGroup, Args_MultipleCustomTarget) {
CHECK_TRUE(msvc_toolchain.state.test);
CHECK(msvc_toolchain.id == buildcc::ToolchainId::Msvc);
STRCMP_EQUAL(msvc_toolchain.name.c_str(), "msvc");
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");
STRCMP_EQUAL(msvc_toolchain.executables.assembler.c_str(), "cl");
STRCMP_EQUAL(msvc_toolchain.executables.c_compiler.c_str(), "cl");
STRCMP_EQUAL(msvc_toolchain.executables.cpp_compiler.c_str(), "cl");
STRCMP_EQUAL(msvc_toolchain.executables.archiver.c_str(), "lib");
STRCMP_EQUAL(msvc_toolchain.executables.linker.c_str(), "link");

// Target
STRCMP_EQUAL(msvc_target.compile_command.c_str(),
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -85,5 +85,6 @@ TEST(ToolchainFlagApiTestGroup, BasicTargetTest) {
}

int main(int ac, char **av) {
MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
return CommandLineTestRunner::RunAllTests(ac, av);
}
34 changes: 26 additions & 8 deletionsbuildcc/lib/toolchain/CMakeLists.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,14 +6,14 @@ set(TOOLCHAIN_SRCS
include/toolchain/common/function_lock.h

# API
src/api/toolchain_find.cpp
src/api/toolchain_verify.cpp
include/toolchain/api/toolchain_find.h
include/toolchain/api/toolchain_verify.h
include/toolchain/api/flag_api.h

src/toolchain/toolchain.cpp
include/toolchain/toolchain.h

# Features
src/api/toolchain_verify.cpp
include/toolchain/api/toolchain_verify.h
)
if (${TESTING})
add_library(mock_toolchain
Expand All@@ -32,10 +32,10 @@ if (${TESTING})
${TEST_LINK_LIBS}
)

add_executable(test_toolchain_verify
test/test_toolchain_verify.cpp
add_executable(test_toolchain_id
test/test_toolchain_id.cpp
)
target_link_libraries(test_toolchain_verify PRIVATE
target_link_libraries(test_toolchain_id PRIVATE
mock_toolchain
)

Expand All@@ -46,10 +46,28 @@ if (${TESTING})
mock_toolchain
)

add_executable(test_toolchain_find
test/test_toolchain_find.cpp
)
target_link_libraries(test_toolchain_find PRIVATE
mock_toolchain
)

add_executable(test_toolchain_verify
test/test_toolchain_verify.cpp
)
target_link_libraries(test_toolchain_verify PRIVATE
mock_toolchain
)

add_test(NAME test_toolchain_id COMMAND test_toolchain_id)
add_test(NAME test_toolchain_config COMMAND test_toolchain_config)
add_test(NAME test_toolchain_find COMMAND test_toolchain_find
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/test
)
add_test(NAME test_toolchain_verify COMMAND test_toolchain_verify
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/test
)
add_test(NAME test_toolchain_config COMMAND test_toolchain_config)
endif()

if(${BUILDCC_BUILD_AS_SINGLE_LIB})
Expand Down
62 changes: 62 additions & 0 deletionsbuildcc/lib/toolchain/include/toolchain/api/toolchain_find.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
/*
* Copyright 2021-2022 Niket Naidu. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef TOOLCHAIN_TOOLCHAIN_FIND_H_
#define TOOLCHAIN_TOOLCHAIN_FIND_H_

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

#include "schema/path.h"

namespace fs = std::filesystem;

namespace buildcc {

/**
* @brief Configure the behaviour of Toolchain::Find API. By default searches
* the directories mentioned in the ENV{PATH} variable to find the toolchain.
* @param absolute_search_paths absolute_search_paths expect directories that
* are iterated for exact toolchain matches
* @param env_vars env_vars contain paths that are seperated by OS delimiter.
* These are converted to paths and searched similarly to absolute_search_paths
* <br>
* NOTE: env_vars must contain single absolute paths or multiple absolute
* paths seperated by OS delimiter <br>
* Example: [Windows] "absolute_path_1;absolute_path_2;..." <br>
* Example: [Linux] "absolute_path_1:absolute_path_2:..." <br>
*/
struct ToolchainFindConfig {
ToolchainFindConfig(
const std::unordered_set<std::string> &env_vars = {"PATH"},
const fs_unordered_set &absolute_search_paths = {})
: env_vars(env_vars), absolute_search_paths(absolute_search_paths) {}

std::unordered_set<std::string> env_vars;
fs_unordered_set absolute_search_paths;
};

template <typename T> class ToolchainFind {
public:
std::vector<fs::path>
Find(const ToolchainFindConfig &config = ToolchainFindConfig()) const;
};

} // namespace buildcc

#endif
Loading

[8]ページ先頭

©2009-2025 Movatter.jp