From: Hans Wennborg Date: Mon, 2 Dec 2013 17:31:52 +0000 (+0000) Subject: clang-format vs plugin: bake clang-format.exe into the vsix X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f6de081f6b761d4f3b0bf76a5a197186725fa7c9;p=clang clang-format vs plugin: bake clang-format.exe into the vsix 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 --- diff --git a/tools/clang-format-vs/ClangFormat/ClangFormat.csproj b/tools/clang-format-vs/ClangFormat/ClangFormat.csproj index 65ccaba0f1..2f49221d14 100644 --- a/tools/clang-format-vs/ClangFormat/ClangFormat.csproj +++ b/tools/clang-format-vs/ClangFormat/ClangFormat.csproj @@ -178,6 +178,9 @@ + + true + diff --git a/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs b/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs index 797d467885..492e4f2b38 100644 --- a/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs +++ b/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs @@ -22,6 +22,7 @@ using System; 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 @@ namespace LLVM.ClangFormat /// 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("\"", "\\\""); diff --git a/tools/clang-format-vs/README.txt b/tools/clang-format-vs/README.txt index 9b75bc3065..d74060e19a 100644 --- a/tools/clang-format-vs/README.txt +++ b/tools/clang-format-vs/README.txt @@ -5,3 +5,6 @@ Build prerequisites are: - 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.