sammccall created this revision.
sammccall added reviewers: thakis, ilya-biryukov.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay, 
mgorny.
Herald added a project: clang.

Introduce a new CLANGD_BUILD option, only default to true if threads are on.

(the name doesn't seem ideal, I'm trying to follow precedent of 
CLANGD_BUILD_XPC)

This is a bit of a mess because of the parallel unittest/ and test/ trees in
clang-tools-extra (clangd has three root directories).

I'd like to move clang-tools-extra/test/clangd -> clang-tools-extra/clangd/test 
etc,
but will do that afterwards.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D61122

Files:
  CMakeLists.txt
  test/CMakeLists.txt
  test/clangd/lit.local.cfg
  unittests/CMakeLists.txt

Index: unittests/CMakeLists.txt
===================================================================
--- unittests/CMakeLists.txt
+++ unittests/CMakeLists.txt
@@ -21,4 +21,6 @@
 add_subdirectory(clang-move)
 add_subdirectory(clang-query)
 add_subdirectory(clang-tidy)
-add_subdirectory(clangd)
+if (CLANGD_BUILD)
+  add_subdirectory(clangd)
+endif()
Index: test/clangd/lit.local.cfg
===================================================================
--- test/clangd/lit.local.cfg
+++ test/clangd/lit.local.cfg
@@ -4,3 +4,5 @@
 # FIXME: make our tests less brittle instead.
 if re.match(r'.*-scei-ps4', config.target_triple):
   config.unsupported = True
+if 'CLANGD_BUILD' not in lit_config.params:
+  config.unsupported = True
Index: test/CMakeLists.txt
===================================================================
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -70,33 +70,36 @@
   clang
 )
 
-if(CLANGD_BUILD_XPC)
-  list(APPEND CLANG_TOOLS_TEST_DEPS clangd-xpc-test-client)
-endif()
-
-set(CLANGD_TEST_DEPS
-  clangd
-  ClangdTests
-  # clangd-related tools which don't have tests, add them to the test to make
-  # sure we don't introduce new changes that break their compilations.
-  clangd-indexer
-  dexp
-  )
-
-# Add lit test dependencies.
 set(LLVM_UTILS_DEPS
   FileCheck count not
 )
 foreach(dep ${LLVM_UTILS_DEPS})
   if(TARGET ${dep})
-    list(APPEND CLANGD_TEST_DEPS ${dep})
+    list(APPEND CLANG_TOOLS_TEST_DEPS ${dep})
   endif()
 endforeach()
 
-foreach(clangd_dep ${CLANGD_TEST_DEPS})
-  list(APPEND CLANG_TOOLS_TEST_DEPS
-       ${clangd_dep})
-endforeach()
+if ( CLANGD_BUILD )
+  if(CLANGD_BUILD_XPC)
+    list(APPEND CLANG_TOOLS_TEST_DEPS clangd-xpc-test-client)
+  endif()
+
+  set(CLANGD_TEST_DEPS
+    clangd
+    ClangdTests
+    # clangd-related tools which don't have tests, add them to the test to make
+    # sure we don't introduce new changes that break their compilations.
+    clangd-indexer
+    dexp
+    )
+
+  foreach(clangd_dep ${CLANGD_TEST_DEPS})
+    list(APPEND CLANG_TOOLS_TEST_DEPS
+         ${clangd_dep})
+  endforeach()
+
+  set(CLANG_TOOLS_TEST_EXTRA_ARGS ${CLANG_TEST_EXTRA_ARGS} "-DCLANGD_BUILD=1")
+endif()
 
 add_lit_testsuite(check-clang-tools "Running the Clang extra tools' regression tests"
   ${CMAKE_CURRENT_BINARY_DIR}
@@ -106,14 +109,17 @@
 
 set_target_properties(check-clang-tools PROPERTIES FOLDER "Clang extra tools' tests")
 
-# Setup an individual test for building and testing clangd-only stuff.
-# Note: all clangd tests have been covered in check-clang-tools, this is a
-# convenient target for clangd developers.
-# Exclude check-clangd from check-all.
-set(EXCLUDE_FROM_ALL ON)
-add_lit_testsuite(check-clangd "Running the Clangd regression tests"
-  ${CMAKE_CURRENT_BINARY_DIR}/Unit/clangd;${CMAKE_CURRENT_BINARY_DIR}/clangd
-  DEPENDS ${CLANGD_TEST_DEPS}
-)
-set_target_properties(check-clangd PROPERTIES FOLDER "Clangd tests")
-set(EXCLUDE_FROM_ALL OFF)
+if ( CLANGD_BUILD )
+  # Setup an individual test for building and testing clangd-only stuff.
+  # Note: all clangd tests have been covered in check-clang-tools, this is a
+  # convenient target for clangd developers.
+  # Exclude check-clangd from check-all.
+  set(EXCLUDE_FROM_ALL ON)
+  add_lit_testsuite(check-clangd "Running the Clangd regression tests"
+    ${CMAKE_CURRENT_BINARY_DIR}/Unit/clangd;${CMAKE_CURRENT_BINARY_DIR}/clangd
+    DEPENDS ${CLANGD_TEST_DEPS}
+    ARGS -DCLANGD_BUILD=1
+  )
+  set_target_properties(check-clangd PROPERTIES FOLDER "Clangd tests")
+  set(EXCLUDE_FROM_ALL OFF)
+endif()
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -9,6 +9,8 @@
 
   unset(CLANGD_BUILD_XPC_DEFAULT)
 endif ()
+# FIXME: move clangd to its own self-contained subtree and clean this up.
+option(CLANGD_BUILD "Build clangd" ${LLVM_ENABLE_THREADS})
 
 add_subdirectory(clang-apply-replacements)
 add_subdirectory(clang-reorder-fields)
@@ -21,7 +23,9 @@
 add_subdirectory(clang-include-fixer)
 add_subdirectory(clang-move)
 add_subdirectory(clang-query)
-add_subdirectory(clangd)
+if ( CLANGD_BUILD )
+  add_subdirectory(clangd)
+endif()
 add_subdirectory(pp-trace)
 add_subdirectory(tool-template)
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to