[tools] Make vscode and lldb-instr optional.

Summary:
Saves some build times, and they're not part of the usual
developer workflow.

Reviewers: JDevlieghere, friss

Subscribers: mgorny, lldb-commits

Tags: #lldb

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

git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@358528 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/cmake/modules/AddLLDB.cmake b/cmake/modules/AddLLDB.cmake
index c0a89e4..9505034 100644
--- a/cmake/modules/AddLLDB.cmake
+++ b/cmake/modules/AddLLDB.cmake
@@ -141,6 +141,11 @@
   endif()
 endfunction(add_lldb_executable)
 
+
+macro(add_lldb_tool_subdirectory name)
+  add_llvm_subdirectory(LLDB TOOL ${name})
+endmacro()
+
 function(add_lldb_tool name)
   add_lldb_executable(${name} GENERATE_INSTALL ${ARGN})
 endfunction()
diff --git a/lit/CMakeLists.txt b/lit/CMakeLists.txt
index 0430867..ea7f897 100644
--- a/lit/CMakeLists.txt
+++ b/lit/CMakeLists.txt
@@ -36,6 +36,8 @@
 # the value is not canonicalized within LLVM
 llvm_canonicalize_cmake_booleans(
   LLDB_DISABLE_PYTHON
+  LLDB_TOOL_LLDB_INSTR_BUILD
+  LLDB_TOOL_LLDB_VSCODE_BUILD
   LLVM_ENABLE_ZLIB
   LLDB_IS_64_BITS)
 
diff --git a/lit/lit.site.cfg.py.in b/lit/lit.site.cfg.py.in
index c3da838..dfe41ab 100644
--- a/lit/lit.site.cfg.py.in
+++ b/lit/lit.site.cfg.py.in
@@ -18,6 +18,8 @@
 config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.lldb_bitness = 64 if @LLDB_IS_64_BITS@ else 32
 config.lldb_disable_python = @LLDB_DISABLE_PYTHON@
+config.have_lldb_instr = @LLDB_TOOL_LLDB_INSTR_BUILD@
+config.have_lldb_vscode = @LLDB_TOOL_LLDB_VSCODE_BUILD@
 config.maxIndividualTestTime = 600
 
 # Support substitution of the tools and libs dirs with user parameters. This is
diff --git a/lit/tools/lldb-instr/lit.local.cfg b/lit/tools/lldb-instr/lit.local.cfg
new file mode 100644
index 0000000..fa6502c
--- /dev/null
+++ b/lit/tools/lldb-instr/lit.local.cfg
@@ -0,0 +1,4 @@
+import sys
+  
+if not config.have_lldb_instr:
+    config.unsupported = True
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index 8e3c7ec..df78037 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -1,10 +1,11 @@
 add_subdirectory(argdumper)
 add_subdirectory(driver)
 add_subdirectory(intel-features)
-add_subdirectory(lldb-instr)
 add_subdirectory(lldb-mi)
 add_subdirectory(lldb-test)
-add_subdirectory(lldb-vscode)
+
+add_lldb_tool_subdirectory(lldb-instr)
+add_lldb_tool_subdirectory(lldb-vscode)
 
 if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
   add_subdirectory(darwin-debug)