From b0bce08c2d2379b4fcbf1dc6e2ff160a7c2966fa Mon Sep 17 00:00:00 2001 From: Vasily Date: Sat, 29 Dec 2018 01:17:51 +0100 Subject: [PATCH] Convert win formatting script to use LLVM_LOC instead of CLANG_FORMAT_LOC The path to the bin dir for LLVM can be used for both clang-cl.exe and clang-format.exe. Changing this will reduce the amount of environment variables in play, leading to better long term quality. --- build_scripts/win/format.cmd | 30 +++++++++++++++--------------- docs/building_for_windows.md | 4 ++-- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/build_scripts/win/format.cmd b/build_scripts/win/format.cmd index ac87b88..dae47d2 100644 --- a/build_scripts/win/format.cmd +++ b/build_scripts/win/format.cmd @@ -23,38 +23,38 @@ IF NOT DEFINED project_dir ( ECHO %current_activity%: Testing if clang-format can be located: -IF NOT DEFINED CLANG_FORMAT_LOC ( - ECHO %current_activity%: CLANG_FORMAT_LOC not defined. Using default value. - SET CLANG_FORMAT_LOC="C:\Program Files\LLVM\bin\clang-format.exe" +IF NOT DEFINED LLVM_LOC ( + ECHO %current_activity%: LLVM_LOC not defined. Using default value. + SET LLVM_LOC="C:\Program Files\LLVM\bin\" ) -ECHO %current_activity%: CLANG_FORMAT_LOC set to '%CLANG_FORMAT_LOC%'. +ECHO %current_activity%: LLVM_LOC set to '%LLVM_LOC%'. REM EXIST won't find items in the PATH. WHERE will. -SET CLANG_FORMAT_VALID=0 -IF EXIST %CLANG_FORMAT_LOC% SET CLANG_FORMAT_VALID=1 -IF %CLANG_FORMAT_VALID% EQU 0 ( - WHERE /Q %CLANG_FORMAT_LOC% - IF NOT ERRORLEVEL 1 SET CLANG_FORMAT_VALID=1 +SET LLVM_VALID=0 +IF EXIST %LLVM_LOC% SET LLVM_VALID=1 +IF %LLVM_VALID% EQU 0 ( + WHERE /Q %LLVM_LOC%\clang-format.exe + IF NOT ERRORLEVEL 1 SET LLVM_VALID=1 ) -IF %CLANG_FORMAT_VALID% EQU 1 ( - ECHO %current_activity%: CLANG_FORMAT_LOC exists. +IF %LLVM_VALID% EQU 1 ( + ECHO %current_activity%: LLVM_LOC exists. ) ELSE ( - ECHO %current_activity%: CLANG_FORMAT_LOC directory does not exist. Exiting. + ECHO %current_activity%: LLVM_LOC directory does not exist. Exiting. EXIT /B %exit_code_failure_build_locations% ) ECHO %current_activity%: Clang-format located. -%CLANG_FORMAT_LOC% --version +%LLVM_LOC%\clang-format.exe --version REM First iteration. -FOR /R %project_dir%\src\ %%F IN (*.cpp *.h) DO (%CLANG_FORMAT_LOC% --style=file -i %%F & ECHO Iteration 1. %%F) +FOR /R %project_dir%\src\ %%F IN (*.cpp *.h) DO (%LLVM_LOC%\clang-format.exe --style=file -i %%F & ECHO Iteration 1. %%F) REM Clang-format is sometimes indecisive about which exact rules to apply, REM leading to differences between first and second iteration. REM Do it twice, just to be sure. -FOR /R %project_dir%\src\ %%F IN (*.cpp *.h) DO (%CLANG_FORMAT_LOC% --style=file -i %%F & ECHO Iteration 2. %%F) +FOR /R %project_dir%\src\ %%F IN (*.cpp *.h) DO (%LLVM_LOC%\clang-format.exe --style=file -i %%F & ECHO Iteration 2. %%F) ECHO %current_activity%: %current_activity% DONE. diff --git a/docs/building_for_windows.md b/docs/building_for_windows.md index c3a64cf..8a2dcf5 100644 --- a/docs/building_for_windows.md +++ b/docs/building_for_windows.md @@ -38,7 +38,7 @@ The following environmental variables are relevant for building the project. | `JOM_LOC` | Path to an `.exe` of `jom.exe`. Usually installed with Qt. `jom` is a wrapper around `nmake` allowing more threads to be used. It is not required, but using `nmake`is slower. If `JOM_LOC` isn't defined, or the `.exe` can't be found `nmake` will be used by default. To force using `nmake`, set `JOM_LOC` to a non-valid path like `1`. | | `ZIP_LOC` | Path to your 7zip `.exe`. Both portable and installer will work. | | `NSIS_LOC` | Path to your installation of NSIS containing the `makensis` file. Both portable and installer will work. | -| `CLANG_FORMAT_LOC` | Path to your `clang-format.exe`. Not necessary for building, but necessary for pushing changes to the repo. | +| `LLVM_LOC` | Path to your LLVM bin directory containing `clang-format.exe`. Not necessary for building with the MSVC compiler, but necessary for pushing changes to the repo. Leave as empty string if your `clang-format`.exe` and `clang-cl.exe` are in the path. | If an environment variable isn't set a default value will be provided. The default values are shown in the table below. @@ -49,7 +49,7 @@ If an environment variable isn't set a default value will be provided. The defau | `JOM_LOC` | `"C:\Qt\Tools\QtCreator\bin\jom.exe"`| | `ZIP_LOC` | `"C:\Program Files\7-Zip\7z.exe"` | | `NSIS_LOC` | `"C:\Program Files (x86)\NSIS\"` | -| `CLANG_FORMAT_LOC` | `"C:\Program Files\LLVM\bin\clang-format.exe"` | +| `LLVM_LOC` | `"C:\Program Files\LLVM\bin\"` | Additionally, these optional environment variables are supported.