xref: /Universal-ctags/win32/appveyor.bat (revision 6c4f15ea8e34e86012922cf5b3186e18814d9996)
1@echo off
2:: Batch file for building/testing ctags on AppVeyor
3::
4:: Copyright (C) 2015 Ken Takata
5:: License: GPL-2 or later
6
7
8cd %APPVEYOR_BUILD_FOLDER%
9if "%1"=="" (
10  set target=build
11) else (
12  set target=%1
13)
14
15:: Daily builds or tag builds should be only built by msys2
16set normalbuild=yes
17if "%APPVEYOR_SCHEDULED_BUILD%"=="True" (
18  set normalbuild=no
19)
20if not "%APPVEYOR_REPO_TAG_NAME%"=="" (
21  set normalbuild=no
22)
23if "%normalbuild%"=="no" (
24  if not "%compiler%"=="msys2" (
25    exit 0
26  )
27)
28
29for %%i in (msbuild msvc msys2 mingw cygwin) do if "%compiler%"=="%%i" goto %compiler%_%target%
30
31echo Unknown build target.
32exit 1
33
34:msbuild_build
35:: ----------------------------------------------------------------------
36:: Using VC12 (VC2013) with msbuild, iconv disabled
37@echo on
38copy win32\config_mvc.h config.h
39copy win32\gnulib_h\langinfo.h gnulib
40copy win32\gnulib_h\fnmatch.h gnulib
41cd win32
42msbuild ctags_vs2013.sln /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /p:Configuration=%CONFIGURATION%
43
44@echo off
45goto :eof
46
47:msbuild_test
48cd win32
49@echo on
50:: Check filetype
51c:\cygwin64\bin\file %CONFIGURATION%\ctags.exe
52:: Check if it works
53%CONFIGURATION%\ctags --version || exit 1
54
55@echo off
56goto :eof
57
58:msbuild_package
59:: Do nothing.
60goto :eof
61
62
63:msvc_build
64:: ----------------------------------------------------------------------
65:: Using VC12 (VC2013) with nmake, iconv enabled
66:: Also create Makefile with msys2 and test the VC binary on msys2.
67set MSYS2_ARCH=x86_64
68set MSYS2_DIR=msys64
69set MSYSTEM=MINGW64
70call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" %ARCH%
71
72:: Build libiconv (MSVC port)
73set ICONV_BUILD_DIR=C:\projects\libiconv
74set "INCLUDE=%INCLUDE%;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include"
75git clone -q --branch=master --depth=1 https://github.com/koron/libiconv.git %ICONV_BUILD_DIR%
76cd %ICONV_BUILD_DIR%\msvc10
77nmake NODEBUG=1 NOMSVCRT=1
78
79:: Install libiconv to %ICONV_DIR%
80set ICONV_DIR=C:\projects\iconv
81mkdir %ICONV_DIR%\include
82mkdir %ICONV_DIR%\lib
83copy %ICONV_BUILD_DIR%\msvc10\iconv.h   %ICONV_DIR%\include     > nul
84copy %ICONV_BUILD_DIR%\msvc10\iconv.lib %ICONV_DIR%\lib         > nul
85copy %ICONV_BUILD_DIR%\msvc10\iconv.dll %APPVEYOR_BUILD_FOLDER% > nul
86
87:: Build ctags with nmake
88@echo on
89cd %APPVEYOR_BUILD_FOLDER%
90nmake -f mk_mvc.mak WITH_ICONV=yes ICONV_DIR=%ICONV_DIR% PDB=yes || exit 1
91
92@echo off
93goto :eof
94
95:msvc_test
96@echo on
97:: Prepare for msys2
98path C:\%MSYS2_DIR%\usr\bin;%PATH%
99set CHERE_INVOKING=yes
100
101:: Check filetype (VC binaries)
102c:\cygwin64\bin\file ctags.exe
103c:\cygwin64\bin\file readtags.exe
104:: Check if it works
105.\ctags --version || exit 1
106
107:: Run tests using misc/units.py on msys2
108bash -lc "py misc/units.py tmain ./Tmain --ctags=./ctags.exe --readtags=./readtags.exe --show-diff-output --shell=c:/msys64/usr/bin/sh" || exit 1
109bash -lc "py misc/units.py run ./Units --ctags=./ctags.exe --show-diff-output --with-timeout=10 --shell=c:/msys64/usr/bin/sh" || exit 1
110
111@echo off
112goto :eof
113
114:msvc_package
115:: Do nothing.
116goto :eof
117
118
119:msys2_build
120:: ----------------------------------------------------------------------
121:: Using msys2
122@echo on
123PATH C:\%MSYS2_DIR%\%MSYSTEM%\bin;C:\%MSYS2_DIR%\usr\bin;%PATH%
124set CHERE_INVOKING=yes
125@rem Reduce time required to install packages by disabling pacman's disk space checking.
126bash -lc "sed -i 's/^CheckSpace/#CheckSpace/g' /etc/pacman.conf"
127if "%normalbuild%"=="no" (
128  @rem Change build message: "Daily build: YYYY-MM-DD"
129  for /f "tokens=2-4 delims=/ " %%i in ('date /t') do appveyor UpdateBuild -Message "Daily build: %%k-%%i-%%j"
130
131  @rem Remove unused toolchain to reduce the time for updating
132  if "%MSYSTEM%"=="MINGW64" (
133    bash -lc "pacman --noconfirm -Rs mingw-w64-i686-toolchain"
134  ) else if "%MSYSTEM%"=="MINGW32" (
135    bash -lc "pacman --noconfirm -Rs mingw-w64-x86_64-toolchain"
136  )
137  @rem Synchronize package databases and upgrade the core system
138  C:\%MSYS2_DIR%\usr\bin\pacman --noconfirm --noprogressbar -Syu
139  @rem Run again to update the rest of packages
140  C:\%MSYS2_DIR%\usr\bin\pacman --noconfirm --noprogressbar -Su
141  @rem Also install packages needed for creating zip package
142  bash -lc "for i in {1..3}; do pacman --noconfirm --noprogressbar -S --needed mingw-w64-%MSYS2_ARCH%-python3-sphinx && break || sleep 15; done"
143)
144:: Install necessary packages
145bash -lc "for i in {1..3}; do pacman --noconfirm --noprogressbar -S --needed mingw-w64-%MSYS2_ARCH%-{jansson,libxml2,libyaml,pcre2} autoconf automake && break || sleep 15; done"
146
147bash -lc "./autogen.sh" || exit 1
148:: Use static link.
149bash -lc "./configure --disable-external-sort --enable-static && make -j2"
150
151@echo off
152goto :eof
153
154:msys2_test
155@echo on
156:: Check filetype (msys2 binaries)
157c:\cygwin64\bin\file ctags.exe
158c:\cygwin64\bin\file readtags.exe
159:: Check if it works
160.\ctags --version || exit 1
161
162:: Run tests
163if "%normalbuild%-%ARCH%"=="yes-x64" (
164  @echo Tests for msys2 x64 are skipped.
165  exit 0
166)
167bash -lc "make check PYTHON=py"
168
169@echo off
170goto :eof
171
172:msys2_package
173:: Only daily builds or tag builds need to create zip packages
174if "%normalbuild%"=="yes" (
175  exit 0
176)
177md package
178:: Build html docs and man pages
179bash -lc "make -C docs html && make -C man html" || exit 1
180move docs\_build\html package\docs > nul
181rd /s/q package\docs\_sources
182
183:: Get version
184if "%APPVEYOR_REPO_TAG_NAME%"=="" (
185  for /f %%i in ('git describe --tags --always') do set ver=%%i
186) else (
187  set ver=%APPVEYOR_REPO_TAG_NAME%
188)
189set ver=%ver:/=_%
190
191:: Create zip package
192set filelist=ctags.exe readtags.exe README.md
193set dirlist=docs license man
194robocopy . package %filelist% > nul
195robocopy win32\license package\license > nul
196copy COPYING package\license > nul
197copy win32\mkstemp\COPYING.MinGW-w64-runtime.txt package\license > nul
198robocopy man package\man *.html > nul
199cd package
200for %%i in (*.exe) do call :strip %%i
2017z a ..\ctags-%ver%-%ARCH%.zip %filelist% %dirlist%
2027z a ..\ctags-%ver%-%ARCH%.debuginfo.zip *.exe.debug
203cd ..
204goto :eof
205
206:strip
207objcopy --only-keep-debug %1 %1.debug
208strip %1
209objcopy --add-gnu-debuglink=%1.debug %1
210goto :eof
211
212
213:mingw_build
214:: ----------------------------------------------------------------------
215:: Using MinGW-w64 without autotools, iconv disabled
216@echo on
217set MSYS2_ARCH=x86_64
218set MSYS2_DIR=msys64
219set MSYSTEM=MINGW64
220PATH C:\%MSYS2_DIR%\%MSYSTEM%\bin;C:\%MSYS2_DIR%\usr\bin;%PATH%
221make -f mk_mingw.mak -j2
222
223@echo off
224goto :eof
225
226:mingw_test
227@echo on
228:: Check filetype
229c:\cygwin64\bin\file ctags.exe
230c:\cygwin64\bin\file readtags.exe
231:: Check if it works
232.\ctags --version || exit 1
233
234@echo off
235goto :eof
236
237:mingw_package
238:: Do nothing.
239goto :eof
240
241
242:cygwin_build
243:: ----------------------------------------------------------------------
244:: Using Cygwin, iconv enabled
245@echo on
246c:\cygwin64\setup-x86_64.exe -qnNdO -P dos2unix,libiconv-devel,libjansson-devel,libxml2-devel,libyaml-devel,pcre2,perl
247PATH c:\cygwin64\bin;%PATH%
248set CHERE_INVOKING=yes
249bash -lc "./autogen.sh"
250bash -lc "./configure && make -j2"
251
252@echo off
253goto :eof
254
255:cygwin_test
256@echo on
257:: Check filetype
258c:\cygwin64\bin\file ctags.exe
259c:\cygwin64\bin\file readtags.exe
260:: Check if it works
261.\ctags --version || exit 1
262:: Run tests
263bash -lc "make check PYTHON=py"
264
265@echo off
266goto :eof
267
268:cygwin_package
269:: Do nothing.
270goto :eof
271