...
1@echo off
2
3set ARGS=@@ARGS@@
4
5rem Remove the leading '(' and trailing ')' characters that surround the arguments
6set stripped_args=%ARGS:~1,-1%
7
8rem Unquote the arguments
9set stripped_args=%stripped_args:'=%
10
11rem Get the absolute path to the buildifier executable
12for /f "tokens=2" %%i in ('findstr /r "\<buildifier\.exe\>" MANIFEST') do (set buildifier_abs_path=%%i)
13
14powershell ^
15function Buildify($Root)^
16{^
17 $Folder = (New-Object -Com Scripting.FileSystemObject).GetFolder($Root);^
18 $Files = $Folder.Files ^| Where-Object {^
19 $_.Name -eq 'BUILD.bazel' `^
20 -or $_.Name -eq 'BUILD' `^
21 -or $_.Name -eq 'WORKSPACE' `^
22 -or $_.Name -eq 'WORKSPACE.bazel' `^
23 -or $_.Name -eq 'WORKSPACE.oss' `^
24 -or $_.Name -clike '*.bzl' `^
25 -or $_.Name -clike '*.sky' `^
26 -or $_.Name -clike '*.BUILD' `^
27 -or $_.Name -clike 'BUILD.*.bazel' `^
28 -or $_.Name -clike 'BUILD.*.oss' `^
29 -or $_.Name -clike 'WORKSPACE.*.bazel' `^
30 -or $_.Name -clike 'WORKSPACE.*.oss'^
31 };^
32 foreach ($File in $Files)^
33 {^
34 ^& '%buildifier_abs_path%' %stripped_args% $File.Path;^
35 };^
36 foreach ($SubFolder in $Folder.Subfolders)^
37 {^
38 $CurrentItem = Get-Item $SubFolder.Path -ErrorAction SilentlyContinue;^
39 if ($CurrentItem -and !$CurrentItem.Attributes.ToString().Contains('ReparsePoint'))^
40 {^
41 Buildify($SubFolder.Path);^
42 };^
43 };^
44};^
45Buildify('%BUILD_WORKSPACE_DIRECTORY%');
View as plain text