]> granicus.if.org Git - clang/commitdiff
clang-format vs plugin: bake clang-format.exe into the vsix
authorHans Wennborg <hans@hanshq.net>
Mon, 2 Dec 2013 17:31:52 +0000 (17:31 +0000)
committerHans Wennborg <hans@hanshq.net>
Mon, 2 Dec 2013 17:31:52 +0000 (17:31 +0000)
This makes the clang-format plugin self-contained. Instead of
requiring clang-format.exe to be available on the PATH, this
includes it in the plugin's installer (.vsix file) and runs it
from the install directory.

Differential Revision: http://llvm-reviews.chandlerc.com/D2281

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196122 91177308-0d34-0410-b5e6-96231b3b80d8

tools/clang-format-vs/ClangFormat/ClangFormat.csproj
tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
tools/clang-format-vs/README.txt

index 65ccaba0f181c7c78bf68ff6068d583fb456c06c..2f49221d14b356b3625c157f2417fa21bd066d75 100644 (file)
     <None Include="Resources\Images_32bit.bmp" />\r
   </ItemGroup>\r
   <ItemGroup>\r
+    <Content Include="clang-format.exe">\r
+      <IncludeInVSIX>true</IncludeInVSIX>\r
+    </Content>\r
     <Content Include="Resources\Package.ico" />\r
   </ItemGroup>\r
   <ItemGroup>\r
index 797d467885783df73e2a7f891e7325b2c620e80b..492e4f2b38fcc936de76461b79a3881d92ff9449 100644 (file)
@@ -22,6 +22,7 @@ using System;
 using System.ComponentModel;\r
 using System.ComponentModel.Design;\r
 using System.IO;\r
+using System.Reflection;\r
 using System.Runtime.InteropServices;\r
 using System.Xml.Linq;\r
 \r
@@ -128,9 +129,12 @@ namespace LLVM.ClangFormat
         /// </summary>\r
         private string RunClangFormat(string text, int offset, int length, string path)\r
         {\r
+            string vsixPath = Path.GetDirectoryName(Uri.UnescapeDataString(\r
+                new UriBuilder(Assembly.GetExecutingAssembly().CodeBase).Path));\r
+\r
             System.Diagnostics.Process process = new System.Diagnostics.Process();\r
             process.StartInfo.UseShellExecute = false;\r
-            process.StartInfo.FileName = "clang-format.exe";\r
+            process.StartInfo.FileName = vsixPath + "\\clang-format.exe";\r
             // Poor man's escaping - this will not work when quotes are already escaped\r
             // in the input (but we don't need more).\r
             string style = GetStyle().Replace("\"", "\\\"");\r
index 9b75bc30657c582d71dd4cabe2abef235fa865e3..d74060e19a42750b503fc52f3eecdca6b93832b2 100644 (file)
@@ -5,3 +5,6 @@ Build prerequisites are:
 - Visual Studio 2012 Professional\r
 - Visual Studio 2010 Professional\r
 - Visual Studio 2010 SDK.\r
+\r
+clang-format.exe must be copied into the ClangFormat/ directory before building.\r
+It will be bundled into the .vsix file.\r