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.
This commit is contained in:
Vasily
2018-12-29 01:17:51 +01:00
parent 7449b1f1a9
commit b0bce08c2d
2 changed files with 17 additions and 17 deletions
+15 -15
View File
@@ -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.
+2 -2
View File
@@ -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.