docc 0.8.3 (0d44999b)
C++ API Reference
Loading...
Searching...
No Matches
src_file_compiler_builder.h
Go to the documentation of this file.
1#pragma once
3
4namespace docc::compile {
5
7
8template<typename T>
10protected:
11 std::shared_ptr<util::DefaultDoccPaths> docc_paths_;
12
13public:
14 virtual ~CodegenCompilerBuilderBase() = default;
15
16 virtual T& set_from_paths(std::shared_ptr<util::DefaultDoccPaths> paths) {
17 docc_paths_ = paths;
18 return *dynamic_cast<T*>(this);
19 }
20
21 const util::DefaultDoccPaths& docc_paths() const { return *docc_paths_; }
22};
23
24struct LibPath {
25 std::filesystem::path path;
27
28 LibPath(std::filesystem::path path, bool is_rpath) : path(std::move(path)), is_rpath(is_rpath) {}
29};
30
31class SrcFileCompilerBuilder : public CodegenCompilerBuilderBase<SrcFileCompilerBuilder> {
32 std::optional<std::filesystem::path> output_dir_;
33 std::optional<std::filesystem::path> compiler_;
34 std::optional<std::filesystem::path> linker_;
35 std::optional<std::string> main_src_ext_;
36 std::string bin_ext_ = "elf";
37 int codegen_order_ = 0;
38 int compile_min_order_ = 0;
39 std::vector<std::string> common_options_;
40 std::vector<std::string> compile_options_;
41 std::vector<std::string> link_options_;
42 std::vector<std::filesystem::path> include_paths_;
43 std::vector<LibPath> library_paths_;
44 bool link_immediately_ = false;
45 std::unordered_map<std::string, std::unique_ptr<SrcFileCompiler>> redirects_;
46 std::vector<std::string> parent_link_options_;
47
48public:
51
54
55 SrcFileCompilerBuilder& set_src_extension(const std::string& ext);
56 SrcFileCompilerBuilder& set_output_dir(const std::filesystem::path& output_dir);
58 SrcFileCompilerBuilder& add_link_option(const std::string& opt);
59 SrcFileCompilerBuilder& add_common_option(const std::string& opt);
60 SrcFileCompilerBuilder& add_include_path(const std::filesystem::path& path);
61
65 SrcFileCompilerBuilder& add_library_path(const std::filesystem::path& path);
66
73 SrcFileCompilerBuilder& add_library_path(const std::filesystem::path& path, bool is_rpath);
74 SrcFileCompilerBuilder& set_compiler(const std::filesystem::path& compiler);
75 SrcFileCompilerBuilder& set_linker(const std::filesystem::path& linker);
76 SrcFileCompilerBuilder& set_from_paths(std::shared_ptr<util::DefaultDoccPaths> paths) override;
77 SrcFileCompilerBuilder& set_bin_extension(const std::string& ext);
78
79 SrcFileCompilerBuilder& set_compile_order(int codegen_order = 0, int compile_min_order = 0);
80
81 SrcFileCompilerBuilder& inherit(const SrcFileCompilerBuilder& builder, bool compile_options = false);
89 SrcFileCompilerBuilder& contribute_parent_link_options(const std::vector<std::string>& opts);
90 SrcFileCompilerBuilder& redirect_snippet(const std::string& ext, SrcFileCompilerBuilder sub_builder);
91
92 std::unique_ptr<SrcFileCompiler> build();
93
94 bool remove_compile_option(const std::string& opt);
95};
96
97} // namespace docc::compile
Definition src_file_compiler_builder.h:9
const util::DefaultDoccPaths & docc_paths() const
Definition src_file_compiler_builder.h:21
virtual T & set_from_paths(std::shared_ptr< util::DefaultDoccPaths > paths)
Definition src_file_compiler_builder.h:16
std::shared_ptr< util::DefaultDoccPaths > docc_paths_
Definition src_file_compiler_builder.h:11
SrcFileCompilerBuilder & set_output_dir(const std::filesystem::path &output_dir)
bool remove_compile_option(const std::string &opt)
SrcFileCompilerBuilder & set_src_extension(const std::string &ext)
SrcFileCompilerBuilder & set_compile_order(int codegen_order=0, int compile_min_order=0)
SrcFileCompilerBuilder & set_link_immediately(bool link_imm)
There is only 1 source and no need to compile an object file and then link all object files.
SrcFileCompilerBuilder & redirect_snippet(const std::string &ext, SrcFileCompilerBuilder sub_builder)
SrcFileCompilerBuilder & add_compile_option(const std::string &opt)
SrcFileCompilerBuilder & set_bin_extension(const std::string &ext)
SrcFileCompilerBuilder & contribute_parent_link_options(const std::vector< std::string > &opts)
SrcFileCompilerBuilder & set_compiler(const std::filesystem::path &compiler)
SrcFileCompilerBuilder & inherit(const SrcFileCompilerBuilder &builder, bool compile_options=false)
SrcFileCompilerBuilder & set_from_paths(std::shared_ptr< util::DefaultDoccPaths > paths) override
SrcFileCompilerBuilder & add_library_path(const std::filesystem::path &path)
calls [add_library_path(path, false)]
std::unique_ptr< SrcFileCompiler > build()
SrcFileCompilerBuilder & set_linker(const std::filesystem::path &linker)
SrcFileCompilerBuilder & add_common_option(const std::string &opt)
SrcFileCompilerBuilder & add_link_option(const std::string &opt)
SrcFileCompilerBuilder & codegen_only()
SrcFileCompilerBuilder & add_include_path(const std::filesystem::path &path)
SrcFileCompilerBuilder(SrcFileCompilerBuilder &&) noexcept
Definition src_file_compiler.h:66
Definition docc_paths.h:21
Definition targets.h:8
Definition cuda_query_compute_capability.h:8
Definition function_builder.h:10
LibPath(std::filesystem::path path, bool is_rpath)
Definition src_file_compiler_builder.h:28
std::filesystem::path path
Definition src_file_compiler_builder.h:25
bool is_rpath
Definition src_file_compiler_builder.h:26