Files
RedBear-OS/local/recipes/dev/libclc/source/offload/tools/offload-tblgen/offload-tblgen.cpp
T
vasilito cb424d7448 build: static patch-sanity linter (shift-left the malformed-patch class)
verify-patch-sanity.py validates every active recipe .patch has internally-
consistent hunk line counts — catching the 'malformed patch at line N' failure
at commit/CI/preflight time instead of hours into a cook. This cycle hit that
class three times (qtwaylandscanner, sddm, xwayland), each only discovered when
cookbook tried to apply the patch.

Running it across the repo found 29 latent malformed patches (validated against
GNU patch: e.g. relibc/P3-sysv-ipc reproduces 'malformed patch at line 22').
They were harmless only because they sit in vendored recipes (baked, not re-
applied) — but would fail on any version-bump re-derivation. --fix recounts the
hunk headers (body untouched) and repaired all 29.

Wired into build-preflight.sh (Phase 1.0D) and redbear-ci.yml, with a unit test
(test-patch-sanity.sh). Skips archived/legacy trees and unvalidatable formats
(empty placeholders, bare-@@ git hunks).
2026-08-01 05:13:02 +03:00

119 lines
3.4 KiB
C++

//===- offload-tblgen/offload-tblgen.cpp ----------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This is a Tablegen tool that produces source files for the Offload project.
// See offload/API/README.md for more information.
//
//===----------------------------------------------------------------------===//
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/InitLLVM.h"
#include "llvm/TableGen/Main.h"
#include "llvm/TableGen/Record.h"
#include "Generators.hpp"
namespace llvm {
namespace offload {
namespace tblgen {
enum ActionType {
PrintRecords,
DumpJSON,
GenAPI,
GenDoc,
GenFuncNames,
GenImplFuncDecls,
GenEntryPoints,
GenPrintHeader,
GenExports,
GenErrcodes,
GenInfo,
};
namespace {
cl::opt<ActionType> Action(
cl::desc("Action to perform:"),
cl::values(
clEnumValN(PrintRecords, "print-records",
"Print all records to stdout (default)"),
clEnumValN(DumpJSON, "dump-json",
"Dump all records as machine-readable JSON"),
clEnumValN(GenAPI, "gen-api", "Generate Offload API header contents"),
clEnumValN(GenDoc, "gen-doc",
"Generate Offload API documentation contents"),
clEnumValN(GenFuncNames, "gen-func-names",
"Generate a list of all Offload API function names"),
clEnumValN(
GenImplFuncDecls, "gen-impl-func-decls",
"Generate declarations for Offload API implementation functions"),
clEnumValN(GenEntryPoints, "gen-entry-points",
"Generate Offload API wrapper function definitions"),
clEnumValN(GenPrintHeader, "gen-print-header",
"Generate Offload API print header"),
clEnumValN(GenExports, "gen-exports",
"Generate export file for the Offload library"),
clEnumValN(GenErrcodes, "gen-errcodes",
"Generate Offload Error Code enum"),
clEnumValN(GenInfo, "gen-info", "Generate Offload Info enum")));
}
static bool OffloadTableGenMain(raw_ostream &OS, const RecordKeeper &Records) {
switch (Action) {
case PrintRecords:
OS << Records;
break;
case DumpJSON:
EmitJSON(Records, OS);
break;
case GenAPI:
EmitOffloadAPI(Records, OS);
break;
case GenDoc:
EmitOffloadDoc(Records, OS);
break;
case GenFuncNames:
EmitOffloadFuncNames(Records, OS);
break;
case GenImplFuncDecls:
EmitOffloadImplFuncDecls(Records, OS);
break;
case GenEntryPoints:
EmitOffloadEntryPoints(Records, OS);
break;
case GenPrintHeader:
EmitOffloadPrintHeader(Records, OS);
break;
case GenExports:
EmitOffloadExports(Records, OS);
break;
case GenErrcodes:
EmitOffloadErrcodes(Records, OS);
break;
case GenInfo:
EmitOffloadInfo(Records, OS);
break;
}
return false;
}
int OffloadTblgenMain(int argc, char **argv) {
InitLLVM y(argc, argv);
cl::ParseCommandLineOptions(argc, argv);
return TableGenMain(argv[0], &OffloadTableGenMain);
}
} // namespace tblgen
} // namespace offload
} // namespace llvm
using namespace llvm;
using namespace offload::tblgen;
int main(int argc, char **argv) { return OffloadTblgenMain(argc, argv); }