Debian Codegraph @

LspCpp/third_party/asio/release.pl

raw
1 #!/usr/bin/perl -w
2
3 use strict;
4 use Cwd qw(abs_path getcwd);
5 use Date::Format;
6 use File::Path;
7 use File::Copy;
8 use File::Basename;
9
10 our $version_major;
11 our $version_minor;
12 our $version_sub_minor;
13 our $asio_name;
14 our $boost_asio_name;
15
16 sub print_usage_and_exit
17 {
18 print("usage: ./release.pl <version>\n");
19 print(" or: ./release.pl --package-asio\n");
20 print("\n");
21 print("examples:\n");
22 print(" create new version and build packages for asio and boost.asio:\n");
23 print(" ./release.pl 1.2.0\n");
24 print(" create packages for asio only:\n");
25 print(" ./release.pl --package-asio\n");
26 exit(1);
27 }
28
29 sub determine_version($)
30 {
31 my $version_string = shift;
32 if ($version_string =~ /^([0-9]+)\.([0-9]+)\.([0-9]+)$/)
33 {
34 our $version_major = $1;
35 our $version_minor = $2;
36 our $version_sub_minor = $3;
37
38 our $asio_name = "asio";
39 $asio_name .= "-$version_major";
40 $asio_name .= ".$version_minor";
41 $asio_name .= ".$version_sub_minor";
42
43 our $boost_asio_name = "boost_asio";
44 $boost_asio_name .= "_$version_major";
45 $boost_asio_name .= "_$version_minor";
46 $boost_asio_name .= "_$version_sub_minor";
47 }
48 else
49 {
50 print_usage_and_exit();
51 }
52 }
53
54 sub determine_version_from_configure()
55 {
56 my $from = "configure.ac";
57 open(my $input, "<$from") or die("Can't open $from for reading");
58 while (my $line = <$input>)
59 {
60 chomp($line);
61 if ($line =~ /^AC_INIT\(\[asio\],\[(.*)\]\)$/)
62 {
63 our $asio_name = "asio-$1";
64 our $boost_asio_name = "boost_asio_$1";
65 last;
66 }
67 }
68 }
69
70 sub update_configure_ac
71 {
72 # Open the files.
73 my $from = "configure.ac";
74 my $to = $from . ".tmp";
75 open(my $input, "<$from") or die("Can't open $from for reading");
76 open(my $output, ">$to") or die("Can't open $to for writing");
77
78 # Copy the content.
79 while (my $line = <$input>)
80 {
81 chomp($line);
82 if ($line =~ /^AC_INIT\(\[asio\].*\)$/)
83 {
84 $line = "AC_INIT([asio],[";
85 $line .= "$version_major.$version_minor.$version_sub_minor";
86 $line .= "])";
87 }
88 print($output "$line\n");
89 }
90
91 # Close the files and move the temporary output into position.
92 close($input);
93 close($output);
94 move($to, $from);
95 unlink($to);
96 }
97
98 sub update_readme
99 {
100 # Open the files.
101 my $from = "README";
102 my $to = $from . ".tmp";
103 open(my $input, "<$from") or die("Can't open $from for reading");
104 open(my $output, ">$to") or die("Can't open $to for writing");
105
106 # Copy the content.
107 while (my $line = <$input>)
108 {
109 chomp($line);
110 if ($line =~ /^asio version/)
111 {
112 $line = "asio version ";
113 $line .= "$version_major.$version_minor.$version_sub_minor";
114 }
115 elsif ($line =~ /^Released/)
116 {
117 my @time = localtime;
118 $line = "Released " . strftime("%A, %d %B %Y", @time) . ".";
119 }
120 print($output "$line\n");
121 }
122
123 # Close the files and move the temporary output into position.
124 close($input);
125 close($output);
126 move($to, $from);
127 unlink($to);
128 }
129
130 sub update_asio_version_hpp
131 {
132 # Open the files.
133 my $from = "include/asio/version.hpp";
134 my $to = $from . ".tmp";
135 open(my $input, "<$from") or die("Can't open $from for reading");
136 open(my $output, ">$to") or die("Can't open $to for writing");
137
138 # Copy the content.
139 while (my $line = <$input>)
140 {
141 chomp($line);
142 if ($line =~ /^#define ASIO_VERSION /)
143 {
144 my $version = $version_major * 100000;
145 $version += $version_minor * 100;
146 $version += $version_sub_minor + 0;
147 $line = "#define ASIO_VERSION " . $version;
148 $line .= " // $version_major.$version_minor.$version_sub_minor";
149 }
150 print($output "$line\n");
151 }
152
153 # Close the files and move the temporary output into position.
154 close($input);
155 close($output);
156 move($to, $from);
157 unlink($to);
158 }
159
160 sub update_boost_asio_version_hpp
161 {
162 # Open the files.
163 my $from = "boost/boost/asio/version.hpp";
164 my $to = $from . ".tmp";
165 open(my $input, "<$from") or die("Can't open $from for reading");
166 open(my $output, ">$to") or die("Can't open $to for writing");
167
168 # Copy the content.
169 while (my $line = <$input>)
170 {
171 chomp($line);
172 if ($line =~ /^#define BOOST_ASIO_VERSION /)
173 {
174 my $version = $version_major * 100000;
175 $version += $version_minor * 100;
176 $version += $version_sub_minor + 0;
177 $line = "#define BOOST_ASIO_VERSION " . $version;
178 $line .= " // $version_major.$version_minor.$version_sub_minor";
179 }
180 print($output "$line\n");
181 }
182
183 # Close the files and move the temporary output into position.
184 close($input);
185 close($output);
186 move($to, $from);
187 unlink($to);
188 }
189
190 sub build_asio_doc
191 {
192 $ENV{BOOST_ROOT} = abs_path("boost");
193 system("rm -rf doc");
194 my $bjam = abs_path(glob("boost/b2"));
195 chdir("src/doc");
196 system("$bjam clean");
197 system("rm -rf html");
198 system("$bjam");
199 chdir("../..");
200 mkdir("doc");
201 system("cp -vR src/doc/html/* doc");
202 }
203
204 sub make_asio_packages
205 {
206 our $asio_name;
207 system("./autogen.sh");
208 system("./configure");
209 system("make dist");
210 system("tar tfz $asio_name.tar.gz | sed -e 's/^[^\\/]*//' | sort -df > asio.manifest");
211 }
212
213 sub build_boost_asio_doc
214 {
215 my $cwd = getcwd();
216 my $bjam = abs_path(glob("boost/b2"));
217 chdir("boost/doc");
218 system("rm -rf html/boost_asio");
219 chdir("../libs/asio/doc");
220 system("$bjam clean");
221 system("$bjam asio");
222 chdir($cwd);
223 }
224
225 our $boost_asio_readme = <<"EOF";
226 Copy the `boost', `doc' and `libs' directories into an existing boost
227 distribution.
228
229 Before using Boost.Asio, the Boost.System library needs to be built. This can
230 be done by running b2 in the libs/system directory. Consult the Boost Getting
231 Started page (http://www.boost.org/more/getting_started.html) for more
232 information on how to build the Boost libraries.
233 EOF
234
235 sub create_boost_asio_content
236 {
237 # Create directory structure.
238 system("rm -rf $boost_asio_name");
239 mkdir("$boost_asio_name");
240 mkdir("$boost_asio_name/doc");
241 mkdir("$boost_asio_name/doc/html");
242 mkdir("$boost_asio_name/boost");
243 mkdir("$boost_asio_name/boost/config");
244 mkdir("$boost_asio_name/libs");
245
246 # Copy files.
247 system("cp -vLR boost/doc/html/boost_asio.html $boost_asio_name/doc/html");
248 system("cp -vLR boost/doc/html/boost_asio $boost_asio_name/doc/html");
249 system("cp -vLR boost/boost/asio.hpp $boost_asio_name/boost");
250 system("cp -vLR boost/boost/asio $boost_asio_name/boost");
251 system("cp -vLR boost/boost/cerrno.hpp $boost_asio_name/boost");
252 system("cp -vLR boost/boost/config/warning_disable.hpp $boost_asio_name/boost/config");
253 system("cp -vLR boost/boost/system $boost_asio_name/boost");
254 system("cp -vLR boost/libs/asio $boost_asio_name/libs");
255 system("cp -vLR boost/libs/system $boost_asio_name/libs");
256
257 # Remove modular boost include directories.
258 system("rm -rf $boost_asio_name/libs/asio/include");
259 system("rm -rf $boost_asio_name/libs/system/include");
260
261 # Add dummy definitions of BOOST_SYMBOL* to boost/system/config.hpp.
262 my $from = "$boost_asio_name/boost/system/config.hpp";
263 my $to = "$boost_asio_name/boost/system/config.hpp.new";
264 open(my $input, "<$from") or die("Can't open $from for reading");
265 open(my $output, ">$to") or die("Can't open $to for writing");
266 while (my $line = <$input>)
267 {
268 print($output $line);
269 if ($line =~ /<boost\/config\.hpp>/)
270 {
271 print($output "\n// These #defines added by the separate Boost.Asio package.\n");
272 print($output "#if !defined(BOOST_SYMBOL_IMPORT)\n");
273 print($output "# if defined(BOOST_HAS_DECLSPEC)\n");
274 print($output "# define BOOST_SYMBOL_IMPORT __declspec(dllimport)\n");
275 print($output "# else // defined(BOOST_HAS_DECLSPEC)\n");
276 print($output "# define BOOST_SYMBOL_IMPORT\n");
277 print($output "# endif // defined(BOOST_HAS_DECLSPEC)\n");
278 print($output "#endif // !defined(BOOST_SYMBOL_IMPORT)\n");
279 print($output "#if !defined(BOOST_SYMBOL_EXPORT)\n");
280 print($output "# if defined(BOOST_HAS_DECLSPEC)\n");
281 print($output "# define BOOST_SYMBOL_EXPORT __declspec(dllexport)\n");
282 print($output "# else // defined(BOOST_HAS_DECLSPEC)\n");
283 print($output "# define BOOST_SYMBOL_EXPORT\n");
284 print($output "# endif // defined(BOOST_HAS_DECLSPEC)\n");
285 print($output "#endif // !defined(BOOST_SYMBOL_EXPORT)\n");
286 print($output "#if !defined(BOOST_SYMBOL_VISIBLE)\n");
287 print($output "# define BOOST_SYMBOL_VISIBLE\n");
288 print($output "#endif // !defined(BOOST_SYMBOL_VISIBLE)\n\n");
289 }
290 }
291 close($input);
292 close($output);
293 system("mv $to $from");
294
295 # Create readme.
296 $to = "$boost_asio_name/README.txt";
297 open($output, ">$to") or die("Can't open $to for writing");
298 print($output $boost_asio_readme);
299 close($output);
300
301 # Remove SVN and git files.
302 system("find $boost_asio_name -name .svn -exec rm -rf {} \\;");
303 system("find $boost_asio_name -name .git -exec rm -rf {} \\;");
304 system("find $boost_asio_name -name .gitignore -exec rm -rf {} \\;");
305 system("find $boost_asio_name -name .gitattributes -exec rm -rf {} \\;");
306 }
307
308 sub make_boost_asio_packages
309 {
310 our $boost_asio_name;
311 system("tar --format=pax -chf - $boost_asio_name | gzip -c >$boost_asio_name.tar.gz");
312 system("tar --format=pax -chf - $boost_asio_name | bzip2 -9 -c >$boost_asio_name.tar.bz2");
313 system("rm -f $boost_asio_name.zip");
314 system("zip -rq $boost_asio_name.zip $boost_asio_name");
315 system("rm -rf $boost_asio_name");
316 system("tar tfz $boost_asio_name.tar.gz | sed -e 's/^[^\\/]*//' | sort -df > boost_asio.manifest");
317 }
318
319 (scalar(@ARGV) == 1) or print_usage_and_exit();
320 my $new_version = 1;
321 my $package_asio = 1;
322 my $package_boost = 1;
323 if ($ARGV[0] eq "--package-asio")
324 {
325 $new_version = 0;
326 $package_boost = 0;
327 }
328
329 if ($new_version)
330 {
331 determine_version($ARGV[0]);
332 update_configure_ac();
333 update_readme();
334 update_asio_version_hpp();
335 update_boost_asio_version_hpp();
336 }
337 else
338 {
339 determine_version_from_configure();
340 }
341
342 if ($package_asio)
343 {
344 build_asio_doc();
345 make_asio_packages();
346 }
347
348 if ($package_boost)
349 {
350 build_boost_asio_doc();
351 create_boost_asio_content();
352 make_boost_asio_packages();
353 }