Skip to content

Revert "[lldb][headers] Create script to fix up versioning" #142864

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 4, 2025

Conversation

chelcassanova
Copy link
Contributor

Reverts #141116. It's breaking the Xcode build as well as the build on AIX.

@chelcassanova chelcassanova merged commit e5cfa0a into main Jun 4, 2025
6 of 10 checks passed
@llvmbot llvmbot added the lldb label Jun 4, 2025
@chelcassanova chelcassanova deleted the revert-141116-create-python-version-fix-script branch June 4, 2025 22:04
@llvmbot
Copy link
Member

llvmbot commented Jun 4, 2025

@llvm/pr-subscribers-lldb

Author: Chelsea Cassanova (chelcassanova)

Changes

Reverts llvm/llvm-project#141116. It's breaking the Xcode build as well as the build on AIX.


Full diff: https://github.com/llvm/llvm-project/pull/142864.diff

5 Files Affected:

  • (modified) lldb/scripts/framework-header-fix.sh (+6)
  • (removed) lldb/scripts/version-header-fix.py (-61)
  • (modified) lldb/source/API/CMakeLists.txt (-39)
  • (removed) lldb/test/Shell/Scripts/Inputs/lldb-defines.h (-7)
  • (removed) lldb/test/Shell/Scripts/TestVersionFixScript.test (-11)
diff --git a/lldb/scripts/framework-header-fix.sh b/lldb/scripts/framework-header-fix.sh
index 345579c80cdf5..3459dd91c9ec1 100755
--- a/lldb/scripts/framework-header-fix.sh
+++ b/lldb/scripts/framework-header-fix.sh
@@ -7,5 +7,11 @@ for file in `find $1 -name "*.h"`
 do
   /usr/bin/sed -i.bak 's/\(#include\)[ ]*"lldb\/\(API\/\)\{0,1\}\(.*\)"/\1 <LLDB\/\3>/1' "$file"
   /usr/bin/sed -i.bak 's|<LLDB/Utility|<LLDB|' "$file"
+  LLDB_VERSION=`echo $2 | /usr/bin/sed -E 's/^([0-9]+).([0-9]+).([0-9]+)(.[0-9]+)?$/\\1/g'`
+  LLDB_REVISION=`echo $2 | /usr/bin/sed -E 's/^([0-9]+).([0-9]+).([0-9]+)(.[0-9]+)?$/\\3/g'`
+  LLDB_VERSION_STRING=`echo $2`
+  /usr/bin/sed -i.bak "s|//#define LLDB_VERSION$|#define LLDB_VERSION $LLDB_VERSION |" "$file"
+  /usr/bin/sed -i.bak "s|//#define LLDB_REVISION|#define LLDB_REVISION $LLDB_REVISION |" "$file"
+  /usr/bin/sed -i.bak "s|//#define LLDB_VERSION_STRING|#define LLDB_VERSION_STRING \"$LLDB_VERSION_STRING\" |" "$file"
   rm -f "$file.bak"
 done
diff --git a/lldb/scripts/version-header-fix.py b/lldb/scripts/version-header-fix.py
deleted file mode 100755
index fb26ee1579e66..0000000000000
--- a/lldb/scripts/version-header-fix.py
+++ /dev/null
@@ -1,61 +0,0 @@
-#!/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"//\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():
-    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()
-        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,
-            r"#define LLDB_VERSION " + lldb_version_major,
-            file_buffer,
-        )
-
-        file_buffer = re.sub(
-            LLDB_REVISION_REGEX,
-            r"#define LLDB_REVISION " + lldb_version_patch,
-            file_buffer,
-        )
-        file_buffer = re.sub(
-            LLDB_VERSION_STRING_REGEX,
-            r'#define LLDB_VERSION_STRING "{0}.{1}.{2}"'.format(
-                lldb_version_major, lldb_version_minor, lldb_version_patch
-            ),
-            file_buffer,
-        )
-        output_file.write(file_buffer)
-
-
-if __name__ == "__main__":
-    main()
diff --git a/lldb/source/API/CMakeLists.txt b/lldb/source/API/CMakeLists.txt
index fbf4e5c1494b9..cb5f1f831dac0 100644
--- a/lldb/source/API/CMakeLists.txt
+++ b/lldb/source/API/CMakeLists.txt
@@ -290,45 +290,6 @@ else()
   endif()
 endif()
 
-# Stage all headers in the include directory in the build dir.
-file(GLOB public_headers ${LLDB_SOURCE_DIR}/include/lldb/API/*.h)
-set(lldb_header_staging_dir ${CMAKE_BINARY_DIR}/include/lldb)
-file(GLOB root_public_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-*.h)
-file(GLOB root_private_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-private*.h)
-list(REMOVE_ITEM root_public_headers ${root_private_headers})
-
-find_program(unifdef_EXECUTABLE unifdef)
-
-foreach(header
-    ${public_headers}
-    ${generated_public_headers}
-    ${root_public_headers})
-  get_filename_component(basename ${header} NAME)
-  set(staged_header ${lldb_header_staging_dir}/${basename})
-
-  if(unifdef_EXECUTABLE)
-    # unifdef returns 0 when the file is unchanged and 1 if something was changed.
-    # That means if we successfully remove SWIG code, the build system believes
-    # that the command has failed and stops. This is undesirable.
-    set(copy_command ${unifdef_EXECUTABLE} -USWIG -o ${staged_header} ${header} || (exit 0))
-  else()
-    set(copy_command ${CMAKE_COMMAND} -E copy ${header} ${staged_header})
-  endif()
-
-  add_custom_command(
-    DEPENDS ${header} OUTPUT ${staged_header}
-    COMMAND ${copy_command}
-    COMMENT "LLDB headers: stage LLDB headers in include directory")
-
-  list(APPEND lldb_staged_headers ${staged_header})
-endforeach()
-
-add_custom_command(TARGET liblldb POST_BUILD
-  COMMAND ${LLDB_SOURCE_DIR}/scripts/version-header-fix.py ${LLDB_SOURCE_DIR}/include/lldb/lldb-defines.h ${lldb_header_staging_dir}/lldb-defines.h ${LLDB_VERSION_MAJOR} ${LLDB_VERSION_MINOR} ${LLDB_VERSION_PATCH}
-)
-add_custom_target(liblldb-header-staging DEPENDS ${lldb_staged_headers})
-add_dependencies(liblldb liblldb-header-staging)
-
 if(LLDB_BUILD_FRAMEWORK)
   include(LLDBFramework)
 
diff --git a/lldb/test/Shell/Scripts/Inputs/lldb-defines.h b/lldb/test/Shell/Scripts/Inputs/lldb-defines.h
deleted file mode 100644
index 8d3090e26d26f..0000000000000
--- a/lldb/test/Shell/Scripts/Inputs/lldb-defines.h
+++ /dev/null
@@ -1,7 +0,0 @@
-// This is a truncated version of lldb-defines.h used to test the script
-// that fixes up its versioning info.
-
-// The script needs to uncomment these lines and populate the info for versioning.
-// #define LLDB_VERSION
-// #define LLDB_REVISION
-// #define LLDB_VERSION_STRING
diff --git a/lldb/test/Shell/Scripts/TestVersionFixScript.test b/lldb/test/Shell/Scripts/TestVersionFixScript.test
deleted file mode 100644
index 78cc987263075..0000000000000
--- a/lldb/test/Shell/Scripts/TestVersionFixScript.test
+++ /dev/null
@@ -1,11 +0,0 @@
-# Create a temp dir for output and run the version fix script on the truncated version of lldb-defines.h in the inputs dir.
-RUN: mkdir -p %t/Outputs
-RUN: %python %p/../../../scripts/version-header-fix.py %p/Inputs/lldb-defines.h %t/Outputs/lldb-defines.h 21 0 12
-
-# Check the output
-RUN: cat %t/Outputs/lldb-defines.h | FileCheck %s
-
-# The LLDB version defines must be uncommented and filled in with the values passed into the script.
-CHECK: {{^}}#define LLDB_VERSION 21
-CHECK: {{^}}#define LLDB_REVISION 12
-CHECK: {{^}}#define LLDB_VERSION_STRING "21.0.12"

chelcassanova added a commit to chelcassanova/llvm-project that referenced this pull request Jun 4, 2025
)"

This relands the original commit for the versioning script in LLDB. This
commit uses '>' for output from `unifdef` for platforms that have that
executable but do not have the `-o` option. It also fixes the Xcode
build by adding a dependency between the liblldb-header-staging target in the
source/API/CMakeLists.txt the `liblldb-resource-headers` target in
LLDBFramework.cmake
chelcassanova added a commit that referenced this pull request Jun 10, 2025
#142871)

This relands the original commit for the versioning script in LLDB. This
commit uses '>' for output from `unifdef` for platforms that have that
executable but do not have the `-o` option. It also fixes the Xcode
build by adding a dependency between the liblldb-header-staging target
in the source/API/CMakeLists.txt the `liblldb-resource-headers` target
in LLDBFramework.cmake.

Original patch: #141116
rorth pushed a commit to rorth/llvm-project that referenced this pull request Jun 11, 2025
)

Reverts llvm#141116. It's breaking the Xcode build as well
as the build on AIX.
rorth pushed a commit to rorth/llvm-project that referenced this pull request Jun 11, 2025
)" (llvm#142871)

This relands the original commit for the versioning script in LLDB. This
commit uses '>' for output from `unifdef` for platforms that have that
executable but do not have the `-o` option. It also fixes the Xcode
build by adding a dependency between the liblldb-header-staging target
in the source/API/CMakeLists.txt the `liblldb-resource-headers` target
in LLDBFramework.cmake.

Original patch: llvm#141116
DhruvSrivastavaX pushed a commit to DhruvSrivastavaX/lldb-for-aix that referenced this pull request Jun 12, 2025
)

Reverts llvm#141116. It's breaking the Xcode build as well
as the build on AIX.
tomtor pushed a commit to tomtor/llvm-project that referenced this pull request Jun 14, 2025
)" (llvm#142871)

This relands the original commit for the versioning script in LLDB. This
commit uses '>' for output from `unifdef` for platforms that have that
executable but do not have the `-o` option. It also fixes the Xcode
build by adding a dependency between the liblldb-header-staging target
in the source/API/CMakeLists.txt the `liblldb-resource-headers` target
in LLDBFramework.cmake.

Original patch: llvm#141116
chelcassanova added a commit to chelcassanova/llvm-project that referenced this pull request Jun 17, 2025
)" (llvm#142871)

This relands the original commit for the versioning script in LLDB. This
commit uses '>' for output from `unifdef` for platforms that have that
executable but do not have the `-o` option. It also fixes the Xcode
build by adding a dependency between the liblldb-header-staging target
in the source/API/CMakeLists.txt the `liblldb-resource-headers` target
in LLDBFramework.cmake.

Original patch: llvm#141116

(cherry picked from commit eb76d83)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants