7#ifndef BACKENDS_P4TOOLS_COMMON_P4CTOOL_H_
8#define BACKENDS_P4TOOLS_COMMON_P4CTOOL_H_
14#include "backends/p4tools/common/compiler/compiler_target.h"
15#include "backends/p4tools/common/compiler/context.h"
16#include "backends/p4tools/common/lib/logging.h"
17#include "backends/p4tools/common/options.h"
18#include "frontends/common/options.h"
26template <
class Options,
27 typename = std::enable_if_t<std::is_base_of_v<AbstractP4cToolOptions, Options>>>
35 virtual void registerTarget() = 0;
41 int main(std::string_view toolName,
const std::vector<const char *> &args) {
46 auto context = Target::initializeTarget(toolName, args);
47 if (!context.has_value()) {
54 auto result = toolOptions.process(args);
55 if (result != EXIT_SUCCESS) {
61 if (!toolOptions.disableInformationLogging) {
66 if (toolOptions.seed) {
67 printInfo(
"============ Program seed %1% =============\n", *toolOptions.seed);
72 if (!compilerResult.has_value()) {
75 return mainImpl(compilerResult.value());
A compilation context for P4Tools that provides a custom compiler configuration.
Definition context.h:17
OptionsType & options() override
Definition context.h:30
Definition compile_context.h:68