MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ add_header()

MAYAFLUX_HOST_API Result< std::filesystem::path > MayaFlux::Host::add_header ( std::string_view file_name,
std::span< const std::filesystem::path > roots )

Include a header in the session.

Each root is tried in the order given, without descending into subdirectories. The first root holding file_name wins, and the header is included by its absolute path. The include search path is not changed. Before start_session the include is staged and evaluated at start.

Parameters
file_namePlain header file name, e.g. "Dust.hpp".
rootsDirectories to look in, in order.
Returns
The absolute header path, or every path that was tried.

Definition at line 46 of file Dependencies.cpp.

49{
50 Failure failure { "header not found: " + std::string(file_name), {} };
51
52 for (const auto& root : roots) {
53 auto found = Platform::acquire_header_root(root, file_name);
54 if (!found) {
55 Failure refused = detail::to_failure(found.error());
56 failure.tried.insert(failure.tried.end(), refused.tried.begin(), refused.tried.end());
57 continue;
58 }
59
60 const std::filesystem::path header = *found / file_name;
61 if (auto included = eval_file(header); !included) {
62 return std::unexpected(std::move(included.error()));
63 }
64 return header;
65 }
66
67 return std::unexpected(std::move(failure));
68}
Failure to_failure(const Platform::AcquireFailure &failure)
Definition Session.cpp:165
Result< void > eval_file(const std::filesystem::path &path)
Evaluate a source file by including it.
Definition Session.cpp:364
Acquired< std::filesystem::path > acquire_header_root(const std::filesystem::path &directory, std::string_view marker_file={})
Validate a header root: an existing directory, optionally containing a marker file.
std::vector< std::filesystem::path > tried
Definition Session.hpp:19
Why a Host call was refused, with every path that was checked.
Definition Session.hpp:17

References MayaFlux::Platform::acquire_header_root(), eval_file(), MayaFlux::Host::detail::to_failure(), and MayaFlux::Host::Failure::tried.

Here is the call graph for this function: