build: Added VC11 support to the project file generator
[platform/upstream/curl.git] / projects / generate.bat
1 @echo off
2 rem ***************************************************************************
3 rem *                                  _   _ ____  _
4 rem *  Project                     ___| | | |  _ \| |
5 rem *                             / __| | | | |_) | |
6 rem *                            | (__| |_| |  _ <| |___
7 rem *                             \___|\___/|_| \_\_____|
8 rem *
9 rem * Copyright (C) 2014, Steve Holme, <steve_holme@hotmail.com>
10 rem *
11 rem * This software is licensed as described in the file COPYING, which
12 rem * you should have received as part of this distribution. The terms
13 rem * are also available at http://curl.haxx.se/docs/copyright.html.
14 rem *
15 rem * You may opt to use, copy, modify, merge, publish, distribute and/or sell
16 rem * copies of the Software, and permit persons to whom the Software is
17 rem * furnished to do so, under the terms of the COPYING file.
18 rem *
19 rem * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 rem * KIND, either express or implied.
21 rem *
22 rem ***************************************************************************
23 setlocal ENABLEDELAYEDEXPANSION
24
25 echo Generating VC8 project files
26 call :generate vcproj Windows\VC8\src\curlsrc.tmpl Windows\VC8\src\curlsrc.vcproj
27 call :generate vcproj Windows\VC8\lib\libcurl.tmpl Windows\VC8\lib\libcurl.vcproj
28
29 echo.
30 echo Generating VC9 project files
31 call :generate vcproj Windows\VC9\src\curlsrc.tmpl Windows\VC9\src\curlsrc.vcproj
32 call :generate vcproj Windows\VC9\lib\libcurl.tmpl Windows\VC9\lib\libcurl.vcproj
33
34 echo.
35 echo Generating VC10 project files
36 call :generate vcxproj Windows\VC10\src\curlsrc.tmpl Windows\VC10\src\curlsrc.vcxproj
37 call :generate vcxproj Windows\VC10\lib\libcurl.tmpl Windows\VC10\lib\libcurl.vcxproj
38
39 echo.
40 echo Generating VC11 project files
41 call :generate vcxproj Windows\VC11\src\curlsrc.tmpl Windows\VC11\src\curlsrc.vcxproj
42 call :generate vcxproj Windows\VC11\lib\libcurl.tmpl Windows\VC11\lib\libcurl.vcxproj
43
44 goto exit
45
46 rem Main generate function.
47 rem
48 rem %1 - Project Type (dsp, vcproj or vcxproj)
49 rem %2 - Input template file
50 rem %3 - Output project file
51 rem
52 :generate
53   if not exist %2 (
54     echo.
55     echo Error: Cannot open %CD%\%2
56     exit /B
57   )
58
59   if exist %3 (  
60     del %3
61   )
62
63   echo * %CD%\%3
64   for /f "delims=" %%i in (%2) do (
65     if "%%i" == "CURL_SRC_C_FILES" (
66       for /f %%c in ('dir /b ..\src\*.c') do call :element %1 src %%c %3
67     ) else if "%%i" == "CURL_SRC_H_FILES" (
68       for /f %%h in ('dir /b ..\src\*.h') do call :element %1 src %%h %3
69     ) else if "%%i" == "CURL_SRC_RC_FILES" (
70       for /f %%r in ('dir /b ..\src\*.rc') do call :element %1 src %%r %3
71     ) else if "%%i" == "CURL_LIB_C_FILES" (
72       for /f %%c in ('dir /b ..\lib\*.c') do call :element %1 lib %%c %3
73     ) else if "%%i" == "CURL_LIB_H_FILES" (
74       for /f %%h in ('dir /b ..\lib\*.h') do call :element %1 lib %%h %3
75     ) else if "%%i" == "CURL_LIB_RC_FILES" (
76       for /f %%r in ('dir /b ..\lib\*.rc') do call :element %1 lib %%r %3
77     ) else if "%%i" == "CURL_LIB_VTLS_C_FILES" (
78       for /f %%c in ('dir /b ..\lib\vtls\*.c') do call :element %1 lib\vtls %%c %3
79     ) else if "%%i" == "CURL_LIB_VTLS_H_FILES" (
80       for /f %%h in ('dir /b ..\lib\vtls\*.h') do call :element %1 lib\vtls %%h %3
81     ) else (
82       echo %%i>> %3
83     )
84   )
85   exit /B
86
87 rem Generates a single file xml element.
88 rem
89 rem %1 - Project Type (dsp, vcproj or vcxproj)
90 rem %2 - Directory (src, lib or lib\vtls)
91 rem %3 - Source filename
92 rem %4 - Output project file
93 rem
94 :element
95   set "SPACES=    "
96   if "%2" == "lib\vtls" (
97     set "TABS=        "
98   ) else (
99     set "TABS=      "
100   )
101
102   call :extension %3 ext
103
104   if "%1" == "vcproj" (
105     echo %TABS%^<File>> %4
106     echo %TABS%  RelativePath="..\..\..\..\%2\%3">> %4
107     echo %TABS%^>>> %4
108     echo %TABS%^</File^>>> %4
109   ) else if "%1" == "vcxproj" (
110     if "%ext%" == "c" (
111       echo %SPACES%^<ClCompile Include=^"..\..\..\..\%2\%3^" /^>>> %4
112     ) else if "%ext%" == "h" (
113       echo %SPACES%^<ClInclude Include=^"..\..\..\..\%2\%3^" /^>>> %4
114     ) else if "%ext%" == "rc" (
115       echo %SPACES%^<ResourceCompile Include=^"..\..\..\..\%2\%3^" /^>>> %4
116     )
117   )
118
119   exit /B
120
121 rem Returns the extension for a given filename.
122 rem
123 rem %1 - The filename
124 rem %2 - The return value
125 rem
126 :extension
127   set fname=%1
128   set ename=
129 :loop1
130   if "%fname%"=="" (
131     set %2=
132     exit /B
133   )
134
135   if not "%fname:~-1%"=="." (
136     set ename=%fname:~-1%%ename%
137     set fname=%fname:~0,-1%
138     goto loop1
139   )
140
141   set %2=%ename%
142   exit /B
143
144 :exit
145   echo.
146   endlocal
147   pause