10 #include <string_view> 11 #include <unordered_map> 15 #include <hilti/rt/filesystem.h> 17 #include <hilti/base/logger.h> 18 #include <hilti/base/result.h> 19 #include <hilti/base/timing.h> 20 #include <hilti/compiler/context.h> 21 #include <hilti/compiler/unit.h> 31 enum class Dependencies {
43 bool include_linker =
false;
44 bool output_hilti =
false;
45 bool output_prototypes =
false;
46 bool output_cxx =
false;
48 bool output_linker =
false;
49 Dependencies output_dependencies = Dependencies::None;
50 bool execute_code =
false;
51 bool show_backtraces =
false;
52 bool abort_on_exceptions =
false;
53 bool keep_tmps =
false;
54 bool skip_dependencies =
false;
55 bool report_resource_usage =
false;
56 bool report_times =
false;
57 bool dump_code =
false;
58 bool global_optimizations =
true;
59 std::vector<hilti::rt::filesystem::path>
62 std::unique_ptr<Logger>
65 Options() { logger = std::make_unique<Logger>(); }
88 explicit Driver(std::string name);
97 Driver(std::string name,
const hilti::rt::filesystem::path& argv0);
149 return ! (_pending_units.empty() && _processed_units.empty() && _processed_paths.empty() &&
150 _libraries.empty() && _external_cxxs.empty());
290 result::Error error(std::string_view msg,
const hilti::rt::filesystem::path& p =
"");
310 Result<std::ofstream> openOutput(
const hilti::rt::filesystem::path& p,
bool binary =
false,
bool append =
false);
319 Result<Nothing> openInput(std::ifstream& in,
const hilti::rt::filesystem::path& p);
328 Result<Nothing> writeOutput(std::ifstream& in,
const hilti::rt::filesystem::path& p);
347 const std::string& extension =
"tmp");
350 void dumpUnit(
const Unit& unit);
427 enum Stage { UNINITIALIZED, INITIALIZED, COMPILED, CODEGENED, LINKED, JITTED } _stage = UNINITIALIZED;
429 void _addUnit(
Unit unit);
444 std::vector<Unit> _pending_units;
446 std::set<hilti::ID> _processed_units;
447 std::set<hilti::rt::filesystem::path> _processed_paths;
449 std::shared_ptr<Context> _ctx;
450 std::unique_ptr<hilti::JIT> _jit;
451 std::shared_ptr<const hilti::rt::Library> _library;
453 std::vector<CxxCode> _generated_cxxs;
454 std::unordered_map<std::string, Library> _libraries;
455 std::vector<hilti::rt::filesystem::path> _external_cxxs;
456 std::vector<linker::MetaData> _mds;
457 std::vector<Unit> _hlts;
459 bool _runtime_initialized =
false;
460 std::set<std::string> _tmp_files;
virtual void hookAddInput(const hilti::rt::filesystem::path &path)
Definition: driver.h:378
std::unique_ptr< Logger > logger
Definition: driver.h:63
const auto & driverOptions() const
Definition: driver.h:154
virtual std::string hookAugmentUsage()
Definition: driver.h:372
virtual void hookNewASTPreCompilation(const ID &name, const std::optional< hilti::rt::filesystem::path > &path, const Node &root)
Definition: driver.h:391
virtual Result< Nothing > hookCompilationFinished()
Definition: driver.h:410
virtual void hookInitRuntime()
Definition: driver.h:416
virtual bool hookProcessCommandLineOption(char opt, const char *optarg)
Definition: driver.h:366
bool hasInputs() const
Definition: driver.h:148
auto context() const
Definition: driver.h:199
virtual void hookAddInput(const hilti::Module &m, const hilti::rt::filesystem::path &path)
Definition: driver.h:384
virtual void hookFinishRuntime()
Definition: driver.h:422
hilti::rt::filesystem::path output_path
Definition: driver.h:61
virtual std::string hookAddCommandLineOptions()
Definition: driver.h:363
const auto & hiltiOptions() const
Definition: driver.h:157
Definition: exception.h:21
std::string output_cxx_prefix
Definition: driver.h:47
virtual void hookNewASTPostCompilation(const ID &name, const std::optional< hilti::rt::filesystem::path > &path, const Node &root)
Definition: driver.h:399
std::vector< hilti::rt::filesystem::path > inputs
Definition: driver.h:60