From dfb48f45c27b729989ef8597fdb855653af01844 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kayra=20Kayg=C4=B1n?= Date: Wed, 21 Apr 2021 18:51:58 +0300 Subject: [PATCH] doc, tools: Improve docs around using clang-format with VS (#9782) * Improved the clarity of the extra step involving generation of a clang-format.exe when using VisualStudio * Added Get-Format function to OpenConsole.psm1 and updated the documentation accordingly. Closes #9777. --- doc/building.md | 8 +++++++- tools/OpenConsole.psm1 | 10 +++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/doc/building.md b/doc/building.md index 9a3eba6c6..b00d7c45f 100644 --- a/doc/building.md +++ b/doc/building.md @@ -9,7 +9,13 @@ git submodule update --init --recursive OpenConsole.sln may be built from within Visual Studio or from the command-line using a set of convenience scripts & tools in the **/tools** directory: -When using Visual Studio, be sure to set up the path for code formatting. This can be done in Visual Studio by going to Tools > Options > Text Editor > C++ > Formatting and checking "Use custom clang-format.exe file" and choosing the clang-format.exe in the repository at /dep/llvm/clang-format.exe by clicking "browse" right under the check box. +When using Visual Studio, be sure to set up the path for code formatting. To download the required clang-format.exe file, follow one of the building instructions below and run: +```powershell +Import-Module .\tools\OpenConsole.psm1 +Set-MsBuildDevEnvironment +Get-Format +``` +After, go to Tools > Options > Text Editor > C++ > Formatting and checking "Use custom clang-format.exe file" in Visual Studio and choose the clang-format.exe in the repository at /packages/clang-format.win-x86.10.0.0/tools/clang-format.exe by clicking "browse" right under the check box. ### Building in PowerShell diff --git a/tools/OpenConsole.psm1 b/tools/OpenConsole.psm1 index 6e2180ce2..655eacae5 100644 --- a/tools/OpenConsole.psm1 +++ b/tools/OpenConsole.psm1 @@ -430,4 +430,12 @@ function Invoke-CodeFormat() { } } -Export-ModuleMember -Function Set-MsbuildDevEnvironment,Invoke-OpenConsoleTests,Invoke-OpenConsoleBuild,Start-OpenConsole,Debug-OpenConsole,Invoke-CodeFormat,Invoke-XamlFormat,Verify-XamlFormat +#.SYNOPSIS +# Download clang-format.exe required for code formatting +function Get-Format() +{ + $root = Find-OpenConsoleRoot + & "$root\dep\nuget\nuget.exe" restore "$root\tools\packages.config" +} + +Export-ModuleMember -Function Set-MsbuildDevEnvironment,Invoke-OpenConsoleTests,Invoke-OpenConsoleBuild,Start-OpenConsole,Debug-OpenConsole,Invoke-CodeFormat,Invoke-XamlFormat,Verify-XamlFormat,Get-Format