2025-06-10 09:47:11 -07:00
#!/usr/bin/env python3
"""
2025-06-26 17:02:22 -07:00
Usage : - i < path / to / input - header . h > - o < path / to / output - header . h > - m LLDB_MAJOR_VERSION - n LLDB_MINOR_VERSION - p LLDB_PATCH_VERSION
2025-06-10 09:47:11 -07:00
2025-06-26 17:02:22 -07:00
This script uncomments and populates the versioning information in lldb - defines . h . Note that the LLDB version numbering looks like MAJOR . MINOR . PATCH
2025-06-10 09:47:11 -07:00
"""
import argparse
import os
import re
LLDB_VERSION_REGEX = re . compile ( r " // \ s*#define LLDB_VERSION \ s*$ " , re . M )
LLDB_REVISION_REGEX = re . compile ( r " // \ s*#define LLDB_REVISION \ s*$ " , re . M )
LLDB_VERSION_STRING_REGEX = re . compile ( r " // \ s*#define LLDB_VERSION_STRING \ s*$ " , re . M )
def main ( ) :
2025-06-26 17:02:22 -07:00
parser = argparse . ArgumentParser (
description = " This script uncomments and populates the versioning information in lldb-defines.h. Note that the LLDB version numbering looks like MAJOR.MINOR.PATCH "
)
parser . add_argument ( " -i " , " --input_path " , help = " The filepath for the input header. " )
parser . add_argument (
" -o " , " --output_path " , help = " The filepath for the output header. "
)
parser . add_argument ( " -m " , " --major " , help = " The LLDB version major. " )
parser . add_argument ( " -n " , " --minor " , help = " The LLDB version minor. " )
parser . add_argument ( " -p " , " --patch " , help = " The LLDB version patch number. " )
2025-06-10 09:47:11 -07:00
args = parser . parse_args ( )
input_path = str ( args . input_path )
output_path = str ( args . output_path )
2025-07-18 15:26:09 -05:00
# Create the output dir if it doesn't already exist
if not os . path . exists ( os . path . dirname ( output_path ) ) :
os . makedirs ( os . path . dirname ( output_path ) )
2025-06-10 09:47:11 -07:00
with open ( input_path , " r " ) as input_file :
lines = input_file . readlines ( )
file_buffer = " " . join ( lines )
with open ( output_path , " w " ) as output_file :
# 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>
file_buffer = re . sub (
LLDB_VERSION_REGEX ,
2025-06-26 17:02:22 -07:00
r " #define LLDB_VERSION " + args . major ,
2025-06-10 09:47:11 -07:00
file_buffer ,
)
file_buffer = re . sub (
LLDB_REVISION_REGEX ,
2025-06-26 17:02:22 -07:00
r " #define LLDB_REVISION " + args . patch ,
2025-06-10 09:47:11 -07:00
file_buffer ,
)
file_buffer = re . sub (
LLDB_VERSION_STRING_REGEX ,
r ' #define LLDB_VERSION_STRING " {0} . {1} . {2} " ' . format (
2025-06-26 17:02:22 -07:00
args . major , args . minor , args . patch
2025-06-10 09:47:11 -07:00
) ,
file_buffer ,
)
output_file . write ( file_buffer )
if __name__ == " __main__ " :
main ( )