[Lldb-commits] [lldb] b90c490 - [lldb/cmake] Reduce duplication in generation lldb-dotest

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Fri Feb 5 00:01:50 PST 2021


Author: Pavel Labath
Date: 2021-02-05T08:44:10+01:00
New Revision: b90c4907ae81e13ff3ce8a56b698e92b36a62d61

URL: https://github.com/llvm/llvm-project/commit/b90c4907ae81e13ff3ce8a56b698e92b36a62d61
DIFF: https://github.com/llvm/llvm-project/commit/b90c4907ae81e13ff3ce8a56b698e92b36a62d61.diff

LOG: [lldb/cmake] Reduce duplication in generation lldb-dotest

Use indirection to avoid duplicated long lists of variables.

Depends on D95261.

Differential Revision: https://reviews.llvm.org/D96034

Added: 
    

Modified: 
    lldb/utils/lldb-dotest/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/lldb/utils/lldb-dotest/CMakeLists.txt b/lldb/utils/lldb-dotest/CMakeLists.txt
index 6a5b3993d780..979722efd298 100644
--- a/lldb/utils/lldb-dotest/CMakeLists.txt
+++ b/lldb/utils/lldb-dotest/CMakeLists.txt
@@ -10,6 +10,20 @@ llvm_canonicalize_cmake_booleans(
   LLDB_BUILD_INTEL_PT
 )
 
+set(LLVM_TOOLS_DIR "${LLVM_TOOLS_BINARY_DIR}")
+set(vars
+  LLDB_DOTEST_ARGS
+  LLDB_SOURCE_DIR
+  LLDB_FRAMEWORK_DIR
+  LLDB_TEST_BUILD_DIRECTORY
+  LLDB_TEST_EXECUTABLE
+  LLDB_TEST_COMPILER
+  LLDB_TEST_DSYMUTIL
+  LLDB_TEST_SERVER
+  LLDB_LIBS_DIR
+  LLVM_TOOLS_DIR
+  )
+
 # Generate lldb-dotest Python driver script for each build mode.
 if(LLDB_BUILT_STANDALONE)
   set(config_types ".")
@@ -19,40 +33,21 @@ if(LLDB_BUILT_STANDALONE)
   foreach(config_type ${config_types})
     # In paths to our build-tree, replace CMAKE_CFG_INTDIR with our actual configuration names.
     string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} config_runtime_output_dir ${LLVM_RUNTIME_OUTPUT_INTDIR})
-    string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_DOTEST_ARGS_CONFIGURED "${LLDB_DOTEST_ARGS}")
-    string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_SOURCE_DIR_CONFIGURED "${LLDB_SOURCE_DIR}")
-    string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_FRAMEWORK_DIR_CONFIGURED "${LLDB_FRAMEWORK_DIR}")
-    string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_BUILD_DIRECTORY_CONFIGURED "${LLDB_TEST_BUILD_DIRECTORY}")
-    string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_EXECUTABLE_CONFIGURED "${LLDB_TEST_EXECUTABLE}")
-    string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_COMPILER_CONFIGURED "${LLDB_TEST_COMPILER}")
-    string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_DSYMUTIL_CONFIGURED "${LLDB_TEST_DSYMUTIL}")
-    string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_SERVER_CONFIGURED "${LLDB_TEST_SERVER}")
+    foreach(var ${vars})
+      string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} "${var}_CONFIGURED" "${${var}}")
+    endforeach()
 
     # Remaining ones must be paths to the provided LLVM build-tree.
     if(${config_type} IN_LIST LLVM_CONFIGURATION_TYPES)
       # Multi-configuration generator like Xcode (with a matching config).
-      string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} LLDB_DOTEST_ARGS_CONFIGURED "${LLDB_DOTEST_ARGS}")
-      string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} LLDB_SOURCE_DIR_CONFIGURED "${LLDB_SOURCE_DIR}")
-      string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} LLDB_FRAMEWORK_DIR_CONFIGURED "${LLDB_FRAMEWORK_DIR}")
-      string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} LLDB_TEST_BUILD_DIRECTORY_CONFIGURED "${LLDB_TEST_BUILD_DIRECTORY}")
-      string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} LLDB_TEST_EXECUTABLE_CONFIGURED "${LLDB_TEST_EXECUTABLE}")
-      string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} LLDB_TEST_COMPILER_CONFIGURED "${LLDB_TEST_COMPILER}")
-      string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} LLDB_TEST_DSYMUTIL_CONFIGURED "${LLDB_TEST_DSYMUTIL}")
-      string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} LLDB_TEST_SERVER_CONFIGURED "${LLDB_TEST_SERVER}")
-      string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} LLDB_LIBS_DIR_CONFIGURED "${LLDB_LIBS_DIR}")
-      string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} LLVM_TOOLS_DIR_CONFIGURED "${LLVM_TOOLS_BINARY_DIR}")
+      foreach(var ${vars})
+        string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} "${var}_CONFIGURED" "${${var}}")
+      endforeach()
     else()
       # Single-configuration generator like Ninja.
-      string(REPLACE ${CMAKE_CFG_INTDIR} "." LLDB_DOTEST_ARGS_CONFIGURED "${LLDB_DOTEST_ARGS}")
-      string(REPLACE ${CMAKE_CFG_INTDIR} "." LLDB_SOURCE_DIR_CONFIGURED "${LLDB_SOURCE_DIR}")
-      string(REPLACE ${CMAKE_CFG_INTDIR} "." LLDB_FRAMEWORK_DIR_CONFIGURED "${LLDB_FRAMEWORK_DIR}")
-      string(REPLACE ${CMAKE_CFG_INTDIR} "." LLDB_TEST_BUILD_DIRECTORY_CONFIGURED "${LLDB_TEST_BUILD_DIRECTORY}")
-      string(REPLACE ${CMAKE_CFG_INTDIR} "." LLDB_TEST_EXECUTABLE_CONFIGURED "${LLDB_TEST_EXECUTABLE}")
-      string(REPLACE ${CMAKE_CFG_INTDIR} "." LLDB_TEST_COMPILER_CONFIGURED "${LLDB_TEST_COMPILER}")
-      string(REPLACE ${CMAKE_CFG_INTDIR} "." LLDB_TEST_DSYMUTIL_CONFIGURED "${LLDB_TEST_DSYMUTIL}")
-      string(REPLACE ${CMAKE_CFG_INTDIR} "." LLDB_TEST_SERVER_CONFIGURED "${LLDB_TEST_SERVER}")
-      string(REPLACE ${CMAKE_CFG_INTDIR} "." LLDB_LIBS_DIR_CONFIGURED "${LLDB_LIBS_DIR}")
-      string(REPLACE ${CMAKE_CFG_INTDIR} "." LLVM_TOOLS_DIR_CONFIGURED "${LLVM_TOOLS_BINARY_DIR}")
+      foreach(var ${vars})
+        string(REPLACE ${CMAKE_CFG_INTDIR} "." "${var}_CONFIGURED" "${${var}}")
+      endforeach()
     endif()
 
     configure_file(
@@ -63,16 +58,9 @@ if(LLDB_BUILT_STANDALONE)
 elseif(NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".")
   foreach(LLVM_BUILD_MODE ${CMAKE_CONFIGURATION_TYPES})
     string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_DOTEST_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
-    string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_DOTEST_ARGS_CONFIGURED "${LLDB_DOTEST_ARGS}")
-    string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_SOURCE_DIR_CONFIGURED "${LLDB_SOURCE_DIR}")
-    string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_FRAMEWORK_DIR_CONFIGURED "${LLDB_FRAMEWORK_DIR}")
-    string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_TEST_BUILD_DIRECTORY_CONFIGURED "${LLDB_TEST_BUILD_DIRECTORY}")
-    string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_TEST_EXECUTABLE_CONFIGURED "${LLDB_TEST_EXECUTABLE}")
-    string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_TEST_COMPILER_CONFIGURED "${LLDB_TEST_COMPILER}")
-    string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_TEST_DSYMUTIL_CONFIGURED "${LLDB_TEST_DSYMUTIL}")
-    string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_TEST_SERVER_CONFIGURED "${LLDB_TEST_SERVER}")
-    string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_LIBS_DIR_CONFIGURED "${LLDB_LIBS_DIR}")
-    string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLVM_TOOLS_DIR_CONFIGURED "${LLVM_TOOLS_BINARY_DIR}")
+    foreach(var ${vars})
+      string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} "${var}_CONFIGURED" "${${var}}")
+    endforeach()
 
     configure_file(
       lldb-dotest.in
@@ -80,16 +68,9 @@ elseif(NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".")
       )
   endforeach()
 else()
-  set(LLDB_DOTEST_ARGS_CONFIGURED "${LLDB_DOTEST_ARGS}")
-  set(LLDB_SOURCE_DIR_CONFIGURED "${LLDB_SOURCE_DIR}")
-  set(LLDB_FRAMEWORK_DIR_CONFIGURED "${LLDB_FRAMEWORK_DIR}")
-  set(LLDB_TEST_BUILD_DIRECTORY_CONFIGURED "${LLDB_TEST_BUILD_DIRECTORY}")
-  set(LLDB_TEST_EXECUTABLE_CONFIGURED "${LLDB_TEST_EXECUTABLE}")
-  set(LLDB_TEST_COMPILER_CONFIGURED "${LLDB_TEST_COMPILER}")
-  set(LLDB_TEST_DSYMUTIL_CONFIGURED "${LLDB_TEST_DSYMUTIL}")
-  set(LLDB_TEST_SERVER_CONFIGURED "${LLDB_TEST_SERVER}")
-  set(LLDB_LIBS_DIR_CONFIGURED "${LLDB_LIBS_DIR}")
-  set(LLVM_TOOLS_DIR_CONFIGURED "${LLVM_TOOLS_BINARY_DIR}")
+  foreach(var ${vars})
+    set("${var}_CONFIGURED" "${${var}}")
+  endforeach()
 
   configure_file(
     lldb-dotest.in


        


More information about the lldb-commits mailing list