MayaFlux
1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
Scan.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include "
Collector.hpp
"
4
5
namespace
MayaFlux::Reflect::Tool
{
6
7
/**
8
* @struct ScanInput
9
* @brief What one scan needs: the compile database, the headers, and flag overrides.
10
*/
11
struct
ScanInput
{
12
std::filesystem::path
build_path
;
13
std::filesystem::path
translation_unit
;
14
std::vector<std::filesystem::path>
roots
;
15
std::vector<std::filesystem::path>
headers
;
16
std::string
resource_dir
;
17
std::vector<std::string>
extra_args
;
18
std::vector<std::string>
stubs
;
19
};
20
21
/** @brief Registers the matchers of one tool on the MatchFinder a scan runs. */
22
using
AttachMatchers
= std::function<void(clang::ast_matchers::MatchFinder&)>;
23
24
/**
25
* @brief Parses every header of @p input in one translation unit and runs the matchers @p attach registers.
26
*
27
* The translation unit and the arguments are chosen as scan() below describes.
28
*
29
* @return false with @p error set when the database, the command or Clang fails.
30
*/
31
[[nodiscard]]
bool
scan
(
const
ScanInput
& input,
const
AttachMatchers
& attach, std::string& error);
32
33
/**
34
* @struct BuildScanInput
35
* @brief What a build scan needs: a ScanInput, plus optional explicit compile arguments.
36
*
37
* With compile_args empty the command is borrowed from the compile database as
38
* scan() does. Otherwise compile_args are the whole command line, and neither
39
* a database nor a translation unit is read.
40
*/
41
struct
BuildScanInput
{
42
ScanInput
scan
;
43
std::vector<std::string>
compile_args
;
44
};
45
46
/**
47
* @brief scan() for a build step: also reports the files the scan read.
48
*
49
* @p dependencies receives every non-system file the preprocessor opened, as
50
* absolute paths, without the scan's own temporary files.
51
*
52
* @return false with @p error set when the database, the command or Clang fails.
53
*/
54
[[nodiscard]]
bool
scan_for_build
(
const
BuildScanInput
& input,
const
AttachMatchers
& attach,
55
std::vector<std::filesystem::path>& dependencies, std::string& error);
56
57
/**
58
* @brief Parses every header of @p input in one translation unit and fills @p collector.
59
*
60
* The translation unit borrows the compile command of input.translation_unit,
61
* or of the first database entry under a root, then the first entry overall.
62
* Its source is replaced in memory by the marker definitions and an include of
63
* each header. Precompiled-header inputs are dropped from the command.
64
*
65
* Each name in input.stubs is written as an empty header into the scan's
66
* temporary directory, which is added as an include path. A header whose
67
* sidecar does not exist yet still parses, and the source tree is not touched.
68
*
69
* @return false with @p error set when the database, the command or Clang fails.
70
*/
71
[[nodiscard]]
bool
scan
(
const
ScanInput
& input,
RequestCollector
& collector, std::string& error);
72
73
}
Collector.hpp
MayaFlux::Reflect::Tool::RequestCollector
Turns each MF_DESCRIBE alias in the scanned translation unit into a RecordRequest.
Definition
Collector.hpp:14
MayaFlux::Reflect::Tool::scan_for_build
bool scan_for_build(const BuildScanInput &input, const AttachMatchers &attach, std::vector< std::filesystem::path > &dependencies, std::string &error)
scan() for a build step: also reports the files the scan read.
Definition
Scan.cpp:330
MayaFlux::Reflect::Tool::scan
bool scan(const ScanInput &input, RequestCollector &collector, std::string &error)
Parses every header of input in one translation unit and fills collector.
Definition
Scan.cpp:176
MayaFlux::Reflect::Tool::AttachMatchers
std::function< void(clang::ast_matchers::MatchFinder &)> AttachMatchers
Registers the matchers of one tool on the MatchFinder a scan runs.
Definition
Scan.hpp:22
MayaFlux::Reflect::Tool
Definition
Build.cpp:19
MayaFlux::Reflect::Tool::BuildScanInput::compile_args
std::vector< std::string > compile_args
Definition
Scan.hpp:43
MayaFlux::Reflect::Tool::BuildScanInput::scan
ScanInput scan
Definition
Scan.hpp:42
MayaFlux::Reflect::Tool::BuildScanInput
What a build scan needs: a ScanInput, plus optional explicit compile arguments.
Definition
Scan.hpp:41
MayaFlux::Reflect::Tool::ScanInput::build_path
std::filesystem::path build_path
Definition
Scan.hpp:12
MayaFlux::Reflect::Tool::ScanInput::extra_args
std::vector< std::string > extra_args
Definition
Scan.hpp:17
MayaFlux::Reflect::Tool::ScanInput::resource_dir
std::string resource_dir
Definition
Scan.hpp:16
MayaFlux::Reflect::Tool::ScanInput::stubs
std::vector< std::string > stubs
Definition
Scan.hpp:18
MayaFlux::Reflect::Tool::ScanInput::roots
std::vector< std::filesystem::path > roots
Definition
Scan.hpp:14
MayaFlux::Reflect::Tool::ScanInput::headers
std::vector< std::filesystem::path > headers
Definition
Scan.hpp:15
MayaFlux::Reflect::Tool::ScanInput::translation_unit
std::filesystem::path translation_unit
Definition
Scan.hpp:13
MayaFlux::Reflect::Tool::ScanInput
What one scan needs: the compile database, the headers, and flag overrides.
Definition
Scan.hpp:11
src
Tools
Reflect
Scan.hpp
Generated by
1.15.0