cb424d7448
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).
78 lines
1.8 KiB
Python
Executable File
78 lines
1.8 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import argparse
|
|
import re
|
|
import os
|
|
|
|
HEADER = """\
|
|
//===-- SBLanguages.h -----------------------------------------*- C++ -*-===//
|
|
//
|
|
// 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLDB_API_SBLANGUAGE_H
|
|
#define LLDB_API_SBLANGUAGE_H
|
|
|
|
#include <cstdint>
|
|
|
|
namespace lldb {
|
|
/// Used by \\ref SBExpressionOptions.
|
|
/// These enumerations use the same language enumerations as the DWARF
|
|
/// specification for ease of use and consistency.
|
|
enum SBSourceLanguageName : uint16_t {
|
|
"""
|
|
|
|
FOOTER = """\
|
|
};
|
|
|
|
} // namespace lldb
|
|
|
|
#endif
|
|
"""
|
|
|
|
REGEX = re.compile(
|
|
r'^ *HANDLE_DW_LNAME *\( *(?P<value>[^,]+), (?P<name>.*), "(?P<comment>[^"]+)",.*\)'
|
|
)
|
|
|
|
|
|
def emit_enum(input, output):
|
|
# Read the input and break it up by lines.
|
|
lines = []
|
|
with open(input, "r") as f:
|
|
lines = f.readlines()
|
|
|
|
# Create output folder if it does not exist
|
|
os.makedirs(os.path.dirname(output), exist_ok=True)
|
|
|
|
# Write the output.
|
|
with open(output, "w") as f:
|
|
# Emit the header.
|
|
f.write(HEADER)
|
|
|
|
# Emit the enum values.
|
|
for line in lines:
|
|
match = REGEX.match(line)
|
|
if not match:
|
|
continue
|
|
f.write(f" /// {match.group('comment')}.\n")
|
|
f.write(f" eLanguageName{match.group('name')} = {match.group('value')},\n")
|
|
|
|
# Emit the footer
|
|
f.write(FOOTER)
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("--output", "-o")
|
|
parser.add_argument("input")
|
|
args = parser.parse_args()
|
|
|
|
emit_enum(args.input, args.output)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|