Hi rnk, klimek,

Here's take two on http://llvm-reviews.chandlerc.com/D2248

This patch makes it possible to build the clang-format vs plugin from the cmake 
build. It is a hack, because it shells out to "devenv" to actually built it, 
but it's hidden away in a corner behind a flag, and it provides a convenient 
way of building the plug-in from the command-line together with the rest of 
clang.

What do you think?

http://llvm-reviews.chandlerc.com/D2310

Files:
  tools/CMakeLists.txt
  tools/clang-format-vs/CMakeLists.txt
  tools/clang-format-vs/README.txt

Index: tools/CMakeLists.txt
===================================================================
--- tools/CMakeLists.txt
+++ tools/CMakeLists.txt
@@ -2,6 +2,7 @@
 add_subdirectory(driver)
 if(CLANG_ENABLE_REWRITER)
   add_subdirectory(clang-format)
+  add_subdirectory(clang-format-vs)
 endif()
 
 if(CLANG_ENABLE_ARCMT)
Index: tools/clang-format-vs/CMakeLists.txt
===================================================================
--- /dev/null
+++ tools/clang-format-vs/CMakeLists.txt
@@ -0,0 +1,16 @@
+option(BUILD_CLANG_FORMAT_VS_PLUGIN "Build clang-format VS plugin" OFF)
+if (BUILD_CLANG_FORMAT_VS_PLUGIN)
+  add_custom_target(clang_format_exe_for_vsix
+      ${CMAKE_COMMAND} -E copy_if_different
+      "${LLVM_TOOLS_BINARY_DIR}/clang-format.exe"
+      "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/clang-format.exe"
+      DEPENDS clang-format)
+
+  add_custom_target(clang_format_vsix ALL
+      devenv "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat.sln" /Build Release
+      DEPENDS clang_format_exe_for_vsix
+      COMMAND ${CMAKE_COMMAND} -E copy_if_different
+      "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/bin/Release/ClangFormat.vsix"
+      "${LLVM_TOOLS_BINARY_DIR}/ClangFormat.vsix"
+      DEPENDS clang_format_exe_for_vsix)
+endif()
Index: tools/clang-format-vs/README.txt
===================================================================
--- tools/clang-format-vs/README.txt
+++ tools/clang-format-vs/README.txt
@@ -8,3 +8,6 @@
 
 clang-format.exe must be copied into the ClangFormat/ directory before 
building.
 It will be bundled into the .vsix file.
+
+The extension can be built manually from ClangFormat.sln (e.g. by opening it in
+Visual Studio), or with cmake by setting the BUILD_CLANG_FORMAT_VS_PLUGIN flag.
Index: tools/CMakeLists.txt
===================================================================
--- tools/CMakeLists.txt
+++ tools/CMakeLists.txt
@@ -2,6 +2,7 @@
 add_subdirectory(driver)
 if(CLANG_ENABLE_REWRITER)
   add_subdirectory(clang-format)
+  add_subdirectory(clang-format-vs)
 endif()
 
 if(CLANG_ENABLE_ARCMT)
Index: tools/clang-format-vs/CMakeLists.txt
===================================================================
--- /dev/null
+++ tools/clang-format-vs/CMakeLists.txt
@@ -0,0 +1,16 @@
+option(BUILD_CLANG_FORMAT_VS_PLUGIN "Build clang-format VS plugin" OFF)
+if (BUILD_CLANG_FORMAT_VS_PLUGIN)
+  add_custom_target(clang_format_exe_for_vsix
+      ${CMAKE_COMMAND} -E copy_if_different
+      "${LLVM_TOOLS_BINARY_DIR}/clang-format.exe"
+      "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/clang-format.exe"
+      DEPENDS clang-format)
+
+  add_custom_target(clang_format_vsix ALL
+      devenv "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat.sln" /Build Release
+      DEPENDS clang_format_exe_for_vsix
+      COMMAND ${CMAKE_COMMAND} -E copy_if_different
+      "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/bin/Release/ClangFormat.vsix"
+      "${LLVM_TOOLS_BINARY_DIR}/ClangFormat.vsix"
+      DEPENDS clang_format_exe_for_vsix)
+endif()
Index: tools/clang-format-vs/README.txt
===================================================================
--- tools/clang-format-vs/README.txt
+++ tools/clang-format-vs/README.txt
@@ -8,3 +8,6 @@
 
 clang-format.exe must be copied into the ClangFormat/ directory before building.
 It will be bundled into the .vsix file.
+
+The extension can be built manually from ClangFormat.sln (e.g. by opening it in
+Visual Studio), or with cmake by setting the BUILD_CLANG_FORMAT_VS_PLUGIN flag.
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to