Hi klimek,

I seem to have managed to bake the .exe into the .vsix and run it from the 
install dir. Tested in VS 2010 and 2012.

Careful review would be appreciated since I don't really know how these things 
work.

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

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

Index: tools/clang-format-vs/ClangFormat/ClangFormat.csproj
===================================================================
--- tools/clang-format-vs/ClangFormat/ClangFormat.csproj
+++ tools/clang-format-vs/ClangFormat/ClangFormat.csproj
@@ -178,6 +178,9 @@
     <None Include="Resources\Images_32bit.bmp" />
   </ItemGroup>
   <ItemGroup>
+    <Content Include="clang-format.exe">
+      <IncludeInVSIX>true</IncludeInVSIX>
+    </Content>
     <Content Include="Resources\Package.ico" />
   </ItemGroup>
   <ItemGroup>
Index: tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
===================================================================
--- tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
+++ tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
@@ -22,6 +22,7 @@
 using System.ComponentModel;
 using System.ComponentModel.Design;
 using System.IO;
+using System.Reflection;
 using System.Runtime.InteropServices;
 using System.Xml.Linq;
 
@@ -128,9 +129,12 @@
         /// </summary>
         private string RunClangFormat(string text, int offset, int length, 
string path)
         {
+            string vsixPath = Path.GetDirectoryName(Uri.UnescapeDataString(
+                new 
UriBuilder(Assembly.GetExecutingAssembly().CodeBase).Path));
+
             System.Diagnostics.Process process = new 
System.Diagnostics.Process();
             process.StartInfo.UseShellExecute = false;
-            process.StartInfo.FileName = "clang-format.exe";
+            process.StartInfo.FileName = vsixPath + "\\clang-format.exe";
             // Poor man's escaping - this will not work when quotes are 
already escaped
             // in the input (but we don't need more).
             string style = GetStyle().Replace("\"", "\\\"");
Index: tools/clang-format-vs/README.txt
===================================================================
--- tools/clang-format-vs/README.txt
+++ tools/clang-format-vs/README.txt
@@ -5,3 +5,6 @@
 - Visual Studio 2012 Professional
 - Visual Studio 2010 Professional
 - Visual Studio 2010 SDK.
+
+clang-format.exe must be copied into the ClangFormat/ directory before 
building.
+It will be bundled into the .vsix file.
Index: tools/clang-format-vs/ClangFormat/ClangFormat.csproj
===================================================================
--- tools/clang-format-vs/ClangFormat/ClangFormat.csproj
+++ tools/clang-format-vs/ClangFormat/ClangFormat.csproj
@@ -178,6 +178,9 @@
     <None Include="Resources\Images_32bit.bmp" />
   </ItemGroup>
   <ItemGroup>
+    <Content Include="clang-format.exe">
+      <IncludeInVSIX>true</IncludeInVSIX>
+    </Content>
     <Content Include="Resources\Package.ico" />
   </ItemGroup>
   <ItemGroup>
Index: tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
===================================================================
--- tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
+++ tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
@@ -22,6 +22,7 @@
 using System.ComponentModel;
 using System.ComponentModel.Design;
 using System.IO;
+using System.Reflection;
 using System.Runtime.InteropServices;
 using System.Xml.Linq;
 
@@ -128,9 +129,12 @@
         /// </summary>
         private string RunClangFormat(string text, int offset, int length, string path)
         {
+            string vsixPath = Path.GetDirectoryName(Uri.UnescapeDataString(
+                new UriBuilder(Assembly.GetExecutingAssembly().CodeBase).Path));
+
             System.Diagnostics.Process process = new System.Diagnostics.Process();
             process.StartInfo.UseShellExecute = false;
-            process.StartInfo.FileName = "clang-format.exe";
+            process.StartInfo.FileName = vsixPath + "\\clang-format.exe";
             // Poor man's escaping - this will not work when quotes are already escaped
             // in the input (but we don't need more).
             string style = GetStyle().Replace("\"", "\\\"");
Index: tools/clang-format-vs/README.txt
===================================================================
--- tools/clang-format-vs/README.txt
+++ tools/clang-format-vs/README.txt
@@ -5,3 +5,6 @@
 - Visual Studio 2012 Professional
 - Visual Studio 2010 Professional
 - Visual Studio 2010 SDK.
+
+clang-format.exe must be copied into the ClangFormat/ directory before building.
+It will be bundled into the .vsix file.
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to