-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathMakefile.bat
146 lines (125 loc) · 4.4 KB
/
Makefile.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
@echo off
rem Set "cleaner-xsd" if the path to your cleaner_markup_language.xsd is not one of the following:
rem - ..\doc\cleaner_markup_language.xsd
rem - ..\bleachbit\doc\cleaner_markup_language.xsd
rem DON'T FORGET TO REMOVE THE "rem " AT THE BEGINNING OF THE NEXT LINE !!!
rem set cleaner-xsd=I:\GitHub\bleachbit\doc\cleaner_markup_language.xsd
rem Use a system environment variable for MinGW:
set Path-MinGW=%Path%;C:\MinGW\msys\1.0\bin
rem Use a system environment variable for Cygwin:
set Path-Cygwin=%Path%;C:\cygwin64\bin
rem Short way to add MinGW & Cygwin to the system environment variable "Path" (workaround):
rem DON'T FORGET TO REMOVE THE "rem " AT THE BEGINNING OF THE NEXT LINE !!!
rem set Path=%Path%;%Path-Cygwin%;%Path-MinGW%
if not "%Path-MinGW%"=="" set tool-path=%Path-MinGW%
if not "%Path-Cygwin%"=="" set tool-path=%Path-Cygwin%
if "%1"=="" goto shorthelp
if "%1"=="-help" goto help
if "%1"=="-file" goto help
if "%1"=="-folder" goto help
goto shorthelp
:help
echo.
echo Copyright (C) 2019 by Tobias B. Besemer for BleachBit.org. All rights reserved.
echo License is GNU GPL version 3 or later - http://gnu.org/licenses/gpl.html.
echo This is free software: You are free to change and redistribute it.
echo There is NO WARRANTY, to the extent permitted by law.
echo.
echo Based on "Makefile" of Andrew Ziem from BleachBit.org.
echo.
echo Version: 0.7.5
echo Date: 2019-11-12
echo.
if "%1"=="-file" goto file
if "%1"=="-folder" goto folder
echo Requirements with MinGW:
echo - MinGW
echo - msys-libxml2-bin of MinGW and its dependencies
echo - msys-diffutils-bin of MinGW and its dependencies
rem echo - msys-grep-bin of MinGW and its dependencies
echo - Path to MinGW\msys\1.0\bin\ in the system environment variable "path"
echo.
echo Or Requirements with Cygwin:
echo - Cygwin
echo - libxml2 of Cygwin
echo - diffutils (included in the standard installation of Cygwin)
echo - Path to \cygwin\bin or \cygwin64\bin in the system environment variable "path"
echo.
if "%1"=="-help" goto shorthelp
:errorfile
echo [file] missing!
goto shorthelp
:errorfolder
echo [folder] missing!
goto shorthelp
:shorthelp
echo.
echo Makefile.bat makes CleanerML files pretty and test them.
echo.
echo Usage: Makefile.bat [option] [file/folder]
echo -help : Shows more help
echo -file : Makes the [file] pretty and tests it
echo -folder : Makes the files in [folder] pretty and test them
echo.
echo CleanerML on GitHub: https://github.com/bleachbit/cleanerml
goto end
:folder
if "%2"=="" goto errorfolder
for %%f in (.\%2\*.xml) do Makefile.bat -file %%f
goto end
:file
if "%2"=="" goto errorfile
rem Make pretty:
if not "%tool-path%"=="" %tool-path%\xmllint --format %2 >%2.pretty
if not "%tool-path%"=="" %tool-path%\diff -q %2 %2.pretty
if not "%tool-path%"=="" goto after-lint
xmllint --format %2 >%2.pretty
diff -q %2 %2.pretty
:after-lint
echo.
rem A "if not" to prevent 0-Byte-File because e.g. xmllint not found...
if not exist %2.pretty goto somethingmissing
rem ...and some code to prevent 0-Byte-File because e.g. XML Syntax Problems...
FOR /F "usebackq" %%A IN ('%2.pretty') DO set size=%%~zA
if %size% LSS 1 (
echo We got a problem !!! 0-Byte !!! I revert !!!
del %2.pretty
goto end
)
rem -> File there, and no 0-Bytes! ->
del %2
move %2.pretty %2
echo.
echo %2 is pretty now!
echo.
:test
rem Make test:
:workaround-xmllint-schema-crash
rem goto end
if "%cleaner-xsd%"=="" goto cleaner-xsd-empty
if not "%tool-path%"=="" %tool-path%\xmllint --noout --schema %cleaner-xsd% %2
if not "%tool-path%"=="" goto end
xmllint --noout --schema %cleaner-xsd% %2
goto end
:cleaner-xsd-empty
if not exist ..\doc\cleaner_markup_language.xsd goto no-doc-cml
if not "%tool-path%"=="" %tool-path%\xmllint --noout --schema ..\doc\cleaner_markup_language.xsd %2
if not "%tool-path%"=="" goto end
xmllint --noout --schema ..\doc\cleaner_markup_language.xsd %2
goto end
:no-doc-cml
if not exist ..\bleachbit\doc\cleaner_markup_language.xsd goto no-bb-doc-cml
if not "%tool-path%"=="" %tool-path%\xmllint --noout --schema ..\bleachbit\doc\cleaner_markup_language.xsd %2
if not "%tool-path%"=="" goto end
xmllint --noout --schema ..\bleachbit\doc\cleaner_markup_language.xsd %2
goto end
:no-bb-doc-cml
echo.
echo cleaner_markup_language.xsd missing !!!
goto end
:somethingmissing
echo Something missing !!!
echo Do you have installed xmllint ???
echo Do you have the path to MinGW\msys\1.0\bin\ in the system environment variable "path" ???
goto end
:end