Skip to content

Commit d6f21bd

Browse files
committed
CMake: enable building the clang-format vs plugin
This makes it possible to build the clang-format vs plugin from the cmake build. It is a hack, as it shells out to "devenv" to actually build 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. Differential Revision: http://llvm-reviews.chandlerc.com/D2310 llvm-svn: 196299
1 parent c6b26f0 commit d6f21bd

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

clang/tools/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ add_subdirectory(diagtool)
22
add_subdirectory(driver)
33
if(CLANG_ENABLE_REWRITER)
44
add_subdirectory(clang-format)
5+
add_subdirectory(clang-format-vs)
56
endif()
67

78
if(CLANG_ENABLE_ARCMT)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
option(BUILD_CLANG_FORMAT_VS_PLUGIN "Build clang-format VS plugin" OFF)
2+
if (BUILD_CLANG_FORMAT_VS_PLUGIN)
3+
add_custom_target(clang_format_exe_for_vsix
4+
${CMAKE_COMMAND} -E copy_if_different
5+
"${LLVM_TOOLS_BINARY_DIR}/clang-format.exe"
6+
"${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/clang-format.exe"
7+
DEPENDS clang-format)
8+
9+
add_custom_target(clang_format_vsix ALL
10+
devenv "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat.sln" /Build Release
11+
DEPENDS clang_format_exe_for_vsix
12+
COMMAND ${CMAKE_COMMAND} -E copy_if_different
13+
"${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/bin/Release/ClangFormat.vsix"
14+
"${LLVM_TOOLS_BINARY_DIR}/ClangFormat.vsix"
15+
DEPENDS clang_format_exe_for_vsix)
16+
endif()

clang/tools/clang-format-vs/README.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ Build prerequisites are:
88

99
clang-format.exe must be copied into the ClangFormat/ directory before building.
1010
It will be bundled into the .vsix file.
11+
12+
The extension can be built manually from ClangFormat.sln (e.g. by opening it in
13+
Visual Studio), or with cmake by setting the BUILD_CLANG_FORMAT_VS_PLUGIN flag.

0 commit comments

Comments
 (0)