1#ifndef BACKENDS_P4TOOLS_COMMON_P4CTOOL_H_
2#define BACKENDS_P4TOOLS_COMMON_P4CTOOL_H_
8#include "backends/p4tools/common/compiler/compiler_target.h"
9#include "backends/p4tools/common/compiler/context.h"
10#include "backends/p4tools/common/lib/logging.h"
11#include "backends/p4tools/common/options.h"
12#include "frontends/common/options.h"
20template <
class Options,
21 typename = std::enable_if_t<std::is_base_of_v<AbstractP4cToolOptions, Options>>>
29 virtual void registerTarget() = 0;
35 int main(std::string_view toolName,
const std::vector<const char *> &args) {
40 auto context = Target::initializeTarget(toolName, args);
41 if (!context.has_value()) {
48 auto result = toolOptions.process(args);
49 if (result != EXIT_SUCCESS) {
55 if (!toolOptions.disableInformationLogging) {
60 if (toolOptions.seed) {
61 printInfo(
"============ Program seed %1% =============\n", *toolOptions.seed);
66 if (!compilerResult.has_value()) {
69 return mainImpl(compilerResult.value());
A compilation context for P4Tools that provides a custom compiler configuration.
Definition context.h:11
OptionsType & options() override
Definition context.h:24
Definition compile_context.h:77