| 1 |
This directory contains a VSPackage project to generate a Visual Studio extension |
| 2 |
for clang-format. |
| 3 |
|
| 4 |
Build prerequisites are: |
| 5 |
- Visual Studio 2015 |
| 6 |
- Extensions SDK (you'll be prompted to install it if you open ClangFormat.sln) |
| 7 |
|
| 8 |
The extension is built using CMake to generate the usual LLVM.sln by setting |
| 9 |
the following CMake vars: |
| 10 |
|
| 11 |
- BUILD_CLANG_FORMAT_VS_PLUGIN=ON |
| 12 |
|
| 13 |
- NUGET_EXE_DIR=path/to/nuget_dir (unless nuget.exe is already available in PATH) |
| 14 |
|
| 15 |
example: |
| 16 |
cd /d C:\code\llvm |
| 17 |
mkdir build & cd build |
| 18 |
cmake -DBUILD_CLANG_FORMAT_VS_PLUGIN=ON -DNUGET_EXE_DIR=C:\nuget .. |
| 19 |
|
| 20 |
Once LLVM.sln is generated, build the clang_format_vsix target, which will build |
| 21 |
ClangFormat.sln, the C# extension application. |
| 22 |
|
| 23 |
The CMake build will copy clang-format.exe and LICENSE.TXT into the ClangFormat/ |
| 24 |
directory so they can be bundled with the plug-in, as well as creating |
| 25 |
ClangFormat/source.extension.vsixmanifest. Once the plug-in has been built with |
| 26 |
CMake once, it can be built manually from the ClangFormat.sln solution in Visual |
| 27 |
Studio. |
| 28 |
|
| 29 |
=========== |
| 30 |
Debugging |
| 31 |
=========== |
| 32 |
|
| 33 |
Once you've built the clang_format_vsix project from LLVM.sln at least once, |
| 34 |
open ClangFormat.sln in Visual Studio, then: |
| 35 |
|
| 36 |
- Make sure the "Debug" target is selected |
| 37 |
- Open the ClangFormat project properties |
| 38 |
- Select the Debug tab |
| 39 |
- Set "Start external program:" to where your devenv.exe is installed. Typically |
| 40 |
it's "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe" |
| 41 |
- Set "Command line arguments" to: /rootsuffix Exp |
| 42 |
- You can now set breakpoints if you like |
| 43 |
- Press F5 to build and run with debugger |
| 44 |
|
| 45 |
If all goes well, a new instance of Visual Studio will be launched in a special |
| 46 |
mode where it uses the experimental hive instead of the normal configuration hive. |
| 47 |
By default, when you build a VSIX project in Visual Studio, it auto-registers the |
| 48 |
extension in the experimental hive, allowing you to test it. In the new Visual Studio |
| 49 |
instance, open or create a C++ solution, and you should now see the Clang Format |
| 50 |
entries in the Tool menu. You can test it out, and any breakpoints you set will be |
| 51 |
hit where you can debug as usual. |