================ @@ -0,0 +1,53 @@ +#!/usr/bin/env python3 +""" +Usage: <path/to/input-header.h> <path/to/output-header.h> LLDB_MAJOR_VERSION LLDB_MINOR_VERSION LLDB_PATCH_VERSION + +This script uncomments and populates the versioning information in lldb-defines.h +""" + +import argparse +import os +import re + +LLDB_VERSION_REGEX = re.compile(r'^//#define LLDB_VERSION$') +LLDB_REVISION_REGEX = re.compile(r'^//#define LLDB_REVISION$') +LLDB_VERSION_STRING_REGEX = re.compile(r'^//#define LLDB_VERSION_STRING$') + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("input_path") + parser.add_argument("output_path") + parser.add_argument("lldb_version_major") + parser.add_argument("lldb_version_minor") + parser.add_argument("lldb_version_patch") + args = parser.parse_args() + input_path = str(args.input_path) + output_path = str(args.output_path) + lldb_version_major = args.lldb_version_major + lldb_version_minor = args.lldb_version_minor + lldb_version_patch = args.lldb_version_patch + + with open(input_path, "r") as input_file: + lines = input_file.readlines() + + with open(output_path, "w") as output_file: + for line in lines: + version_match = LLDB_VERSION_REGEX.match(line) + revision_match = LLDB_REVISION_REGEX.match(line) + version_string_match = LLDB_VERSION_STRING_REGEX.match(line) + + # For the defines in lldb-defines.h that define the major, minor and version string + # uncomment each define and populate its value using the arguments passed in. + # e.g. //#define LLDB_VERSION -> #define LLDB_VERSION <LLDB_MAJOR_VERSION> + if version_match: + output_file.write(re.sub(LLDB_VERSION_REGEX, r'#define LLDB_VERSION ' + lldb_version_major, line)) + elif revision_match: + output_file.write(re.sub(LLDB_REVISION_REGEX, r'#define LLDB_REVISION ' + lldb_version_patch, line)) + elif version_string_match: + output_file.write(re.sub(LLDB_VERSION_STRING_REGEX, r'#define LLDB_VERSION_STRING "{0}.{1}.{2}"'.format(lldb_version_major, lldb_version_minor, lldb_version_patch), line)) + else: + output_file.write(line) ---------------- chelcassanova wrote:
> Unless that's intentional? Not really, this is more of a holdover from how I set up the regex matching for other Python scripts that do this kind of thing. I can try passing in the buffer here instead of going line by line. https://github.com/llvm/llvm-project/pull/141116 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits