MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
Dependencies.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "Session.hpp"
4
5namespace MayaFlux::Host {
6
7/**
8 * @brief Add a directory to the JIT include search path.
9 *
10 * The directory is checked at call time and only that directory is looked at.
11 * Include paths cannot change a session that has started, so after
12 * start_session this is refused.
13 *
14 * @param directory Directory to add, absolute or relative to the working directory.
15 * @param marker_file Plain file name that must exist inside directory, or empty for none.
16 * @return The absolute directory, or the reason it was refused.
17 */
19 const std::filesystem::path& directory,
20 std::string_view marker_file = {});
21
22/**
23 * @brief Include a header in the session.
24 *
25 * Each root is tried in the order given, without descending into
26 * subdirectories. The first root holding file_name wins, and the header is
27 * included by its absolute path. The include search path is not changed.
28 * Before start_session the include is staged and evaluated at start.
29 *
30 * @param file_name Plain header file name, e.g. "Dust.hpp".
31 * @param roots Directories to look in, in order.
32 * @return The absolute header path, or every path that was tried.
33 */
35 std::string_view file_name,
36 std::span<const std::filesystem::path> roots);
37
38/**
39 * @brief Load a shared library from an explicit file path.
40 *
41 * Loading the same file twice is a no-op. Before start_session the load is
42 * staged and performed at start.
43 *
44 * @param path Path to the library, absolute or relative to the working directory.
45 * @return The canonical path, or the reason it was refused or failed to load.
46 */
47MAYAFLUX_HOST_API Result<std::filesystem::path> load_library(const std::filesystem::path& path);
48
49/**
50 * @brief Load a shared library by name from one prefix.
51 *
52 * Candidates are tried under lib, lib64 and bin of the prefix, using the
53 * platform's file name for base_name first and base_name as written last.
54 *
55 * @param prefix Install prefix to search.
56 * @param base_name Plain library name, e.g. "Dust" or "libDust".
57 * @return The canonical path, or every path that was tried.
58 */
60 const std::filesystem::path& prefix,
61 std::string_view base_name);
62
63/**
64 * @brief Add a compile flag to the JIT.
65 *
66 * Flags cannot change a session that has started, so after start_session
67 * this is refused.
68 *
69 * @param flag Compiler flag, e.g. "-DMY_DEFINE".
70 * @return Success, or the reason it was refused.
71 */
72MAYAFLUX_HOST_API Result<void> add_compile_flag(const std::string& flag);
73
74} // namespace MayaFlux::Host
Result< std::filesystem::path > load_library_from_prefix(const std::filesystem::path &prefix, std::string_view base_name)
Load a shared library by name from one prefix.
std::expected< T, Failure > Result
Result of a Host call.
Definition Session.hpp:26
Result< void > add_compile_flag(const std::string &flag)
Add a compile flag to the JIT.
Result< std::filesystem::path > add_include_root(const std::filesystem::path &directory, std::string_view marker_file)
Add a directory to the JIT include search path.
Result< std::filesystem::path > add_header(std::string_view file_name, std::span< const std::filesystem::path > roots)
Include a header in the session.
Result< std::filesystem::path > load_library(const std::filesystem::path &path)
Load a shared library from an explicit file path.