aboutsummaryrefslogtreecommitdiff
path: root/projects/generate.bat
blob: d7a76f0522b7643fef6cc4aaf571bd33c3b3e908 (plain)
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
@echo off
rem ***************************************************************************
rem *                                  _   _ ____  _
rem *  Project                     ___| | | |  _ \| |
rem *                             / __| | | | |_) | |
rem *                            | (__| |_| |  _ <| |___
rem *                             \___|\___/|_| \_\_____|
rem *
rem * Copyright (C) 2014, Steve Holme, <steve_holme@hotmail.com>
rem *
rem * This software is licensed as described in the file COPYING, which
rem * you should have received as part of this distribution. The terms
rem * are also available at http://curl.haxx.se/docs/copyright.html.
rem *
rem * You may opt to use, copy, modify, merge, publish, distribute and/or sell
rem * copies of the Software, and permit persons to whom the Software is
rem * furnished to do so, under the terms of the COPYING file.
rem *
rem * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
rem * KIND, either express or implied.
rem *
rem ***************************************************************************
setlocal ENABLEDELAYEDEXPANSION

rem Generate VC8 project files
call :generate vc8 Windows\VC8\src\curlsrc.tmpl Windows\VC8\src\curlsrc.vcproj
call :generate vc8 Windows\VC8\lib\libcurl.tmpl Windows\VC8\lib\libcurl.vcproj

rem Generate VC9 project files
call :generate vc9 Windows\VC9\src\curlsrc.tmpl Windows\VC9\src\curlsrc.vcproj
call :generate vc9 Windows\VC9\lib\libcurl.tmpl Windows\VC9\lib\libcurl.vcproj

rem Generate VC10 project files
call :generate vc10 Windows\VC10\src\curlsrc.tmpl Windows\VC10\src\curlsrc.vcxproj
call :generate vc10 Windows\VC10\lib\libcurl.tmpl Windows\VC10\lib\libcurl.vcxproj

goto exit

rem Main generate function.
rem
rem %1 - IDE
rem %2 - Input template file
rem %3 - Output project file
rem
:generate
  echo.

  if not exist %2 (
    echo Error: Cannot open %CD%\%2
    exit /B
  )

  if exist %3 (  
    echo Deleting %3
    del %3
  )

  echo Generating %3
  for /f "delims=" %%i in (%2) do (
    if "%%i" == "CURL_SRC_C_FILES" (
      for /f %%c in ('dir /b ..\src\*.c') do call :element %1 src %%c %3
    ) else if "%%i" == "CURL_SRC_H_FILES" (
      for /f %%h in ('dir /b ..\src\*.h') do call :element %1 src %%h %3
    ) else if "%%i" == "CURL_SRC_RC_FILES" (
      for /f %%r in ('dir /b ..\src\*.rc') do call :element %1 src %%r %3
    ) else if "%%i" == "CURL_LIB_C_FILES" (
      for /f %%c in ('dir /b ..\lib\*.c') do call :element %1 lib %%c %3
    ) else if "%%i" == "CURL_LIB_H_FILES" (
      for /f %%h in ('dir /b ..\lib\*.h') do call :element %1 lib %%h %3
    ) else if "%%i" == "CURL_LIB_RC_FILES" (
      for /f %%r in ('dir /b ..\lib\*.rc') do call :element %1 lib %%r %3
    ) else if "%%i" == "CURL_LIB_VTLS_C_FILES" (
      for /f %%c in ('dir /b ..\lib\vtls\*.c') do call :element %1 lib\vtls %%c %3
    ) else if "%%i" == "CURL_LIB_VTLS_H_FILES" (
      for /f %%h in ('dir /b ..\lib\vtls\*.h') do call :element %1 lib\vtls %%h %3
    ) else (
      echo %%i>> %3
    )
  )
  exit /B

rem Generates a single file xml element.
rem
rem %1 - IDE
rem %2 - Directory (eg src, lib or lib\vtls)
rem %3 - Source filename
rem %4 - Output project file
rem
:element
  set "SPACES=    "
  if "%2" == "lib\vtls" (
    set "TABS=        "
  ) else (
    set "TABS=      "
  )

  call :extension %3 ext

  if "%1" == "vc10" (
    if "%ext%" == "c" (
      echo %SPACES%^<ClCompile Include=^"..\..\..\..\%2\%3^" /^>>> %4
    ) else if "%ext%" == "h" (
      echo %SPACES%^<ClInclude Include=^"..\..\..\..\%2\%3^" /^>>> %4
    ) else if "%ext%" == "rc" (
      echo %SPACES%^<ResourceCompile Include=^"..\..\..\..\%2\%3^" /^>>> %4
    )
  ) else (
    echo %TABS%^<File>> %4
    echo %TABS%  RelativePath="..\..\..\..\%2\%3">> %4
    echo %TABS%^>>> %4
    echo %TABS%^</File^>>> %4
  )

  exit /B

rem Returns the extension for a given filename.
rem
rem %1 - The filename
rem %2 - The return value
rem
:extension
  set fname=%1
  set ename=
:loop1
  if "%fname%"=="" (
    set %2=
    exit /B
  )

  if not "%fname:~-1%"=="." (
    set ename=%fname:~-1%%ename%
    set fname=%fname:~0,-1%
    goto loop1
  )

  set %2=%ename%
  exit /B

:exit
  echo.
  pause