Initial support of `make format` for Windows
authorSergey Sharybin <sergey.vfx@gmail.com>
Tue, 16 Apr 2019 13:34:32 +0000 (15:34 +0200)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Tue, 16 Apr 2019 13:41:32 +0000 (15:41 +0200)
There are couple of caviats currently:

- The script requires system-wide Python 3 available in the current
  search PATH as python.exe.

  This will get addressed soon by distributing unpacked Python binary
  in our libraries.

- Since the libraries folder is to be known, this requires to have
  MSVC detected. Not too bad, since formatting is still way slower
  than detection, but still doesn't feel ideal.

build_files/windows/format.cmd [new file with mode: 0644]
build_files/windows/parse_arguments.cmd
build_files/windows/reset_variables.cmd
make.bat

diff --git a/build_files/windows/format.cmd b/build_files/windows/format.cmd
new file mode 100644 (file)
index 0000000..b33ebdc
--- /dev/null
@@ -0,0 +1,10 @@
+REM TODO(sergey): Switch to Python from libraries when available.
+set PYTHON="python.exe"
+set FORMAT_PATHS=%BLENDER_DIR%\source\tools\utils\clang_format_paths.py
+
+REM The formatting script expects clang-format to be in the current PATH.
+set PATH=%BUILD_VS_LIBDIR%\llvm\bin;%PATH%
+
+%PYTHON% %FORMAT_PATHS% --expand-tabs
+
+:EOF
index ada78e1defb79a967409ebe7d57242ce0af2358b..ed54ee9d13a744a7e2dd433a75c494ff43d7b680 100644 (file)
@@ -81,6 +81,8 @@ if NOT "%1" == "" (
                set MUST_CLEAN=1
        ) else if "%1" == "verbose" (
                set VERBOSE=1
+       ) else if "%1" == "format" (
+               set FORMAT=1
        ) else (
                echo Command "%1" unknown, aborting!
                exit /b 1
index ba584a7f34a829ba0df62602472d9a851bcfb792..efac15785cada91b484fe914722488fb3c8a6351 100644 (file)
@@ -27,3 +27,4 @@ set CLANG_CMAKE_ARGS=
 set ASAN_CMAKE_ARGS=
 set WITH_PYDEBUG=
 set PYDEBUG_CMAKE_ARGS=
+set FORMAT=
index 5fb428fbed034709df994aada23e7abd61855c3a..4245071870cd84eb22daf8790ef3b376a5a51317 100644 (file)
--- a/make.bat
+++ b/make.bat
@@ -47,13 +47,18 @@ if "%BUILD_VS_YEAR%" == "" (
        )
 )
 
+call "%BLENDER_DIR%\build_files\windows\check_libraries.cmd"
+if errorlevel 1 goto EOF
+
+if "%FORMAT%" == "1" (
+       call "%BLENDER_DIR%\build_files\windows\format.cmd"
+       goto EOF
+)
+
 call "%BLENDER_DIR%\build_files\windows\set_build_dir.cmd"
 
 echo Building blender with VS%BUILD_VS_YEAR% for %BUILD_ARCH% in %BUILD_DIR%
 
-call "%BLENDER_DIR%\build_files\windows\check_libraries.cmd"
-if errorlevel 1 goto EOF
-
 call "%BLENDER_DIR%\build_files\windows\check_submodules.cmd"
 if errorlevel 1 goto EOF