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 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440
|
#!/usr/bin/perl -w
use strict;
use Cwd qw(abs_path getcwd);
use Date::Format;
use File::Path;
use File::Copy;
use File::Basename;
our $version_major;
our $version_minor;
our $version_sub_minor;
our $asio_name;
our $boost_asio_name;
sub print_usage_and_exit
{
print("usage: ./release.pl <version>\n");
print(" or: ./release.pl --package-asio\n");
print("\n");
print("examples:\n");
print(" create new version and build packages for asio and boost.asio:\n");
print(" ./release.pl 1.2.0\n");
print(" create packages for asio only:\n");
print(" ./release.pl --package-asio\n");
exit(1);
}
sub determine_version($)
{
my $version_string = shift;
if ($version_string =~ /^([0-9]+)\.([0-9]+)\.([0-9]+)$/)
{
our $version_major = $1;
our $version_minor = $2;
our $version_sub_minor = $3;
our $asio_name = "asio";
$asio_name .= "-$version_major";
$asio_name .= ".$version_minor";
$asio_name .= ".$version_sub_minor";
our $boost_asio_name = "boost_asio";
$boost_asio_name .= "_$version_major";
$boost_asio_name .= "_$version_minor";
$boost_asio_name .= "_$version_sub_minor";
}
else
{
print_usage_and_exit();
}
}
sub determine_version_from_configure()
{
my $from = "configure.ac";
open(my $input, "<$from") or die("Can't open $from for reading");
while (my $line = <$input>)
{
chomp($line);
if ($line =~ /^AC_INIT\(asio.*\[(.*)\]\)$/)
{
our $asio_name = "asio-$1";
our $boost_asio_name = "boost_asio_$1";
last;
}
}
}
sub update_configure_ac
{
# Open the files.
my $from = "configure.ac";
my $to = $from . ".tmp";
open(my $input, "<$from") or die("Can't open $from for reading");
open(my $output, ">$to") or die("Can't open $to for writing");
# Copy the content.
while (my $line = <$input>)
{
chomp($line);
if ($line =~ /^AC_INIT\(asio.*\)$/)
{
$line = "AC_INIT(asio, [";
$line .= "$version_major.$version_minor.$version_sub_minor";
$line .= "])";
}
print($output "$line\n");
}
# Close the files and move the temporary output into position.
close($input);
close($output);
move($to, $from);
unlink($to);
}
sub update_readme
{
# Open the files.
my $from = "README";
my $to = $from . ".tmp";
open(my $input, "<$from") or die("Can't open $from for reading");
open(my $output, ">$to") or die("Can't open $to for writing");
# Copy the content.
while (my $line = <$input>)
{
chomp($line);
if ($line =~ /^asio version/)
{
$line = "asio version ";
$line .= "$version_major.$version_minor.$version_sub_minor";
}
elsif ($line =~ /^Released/)
{
my @time = localtime;
$line = "Released " . strftime("%A, %d %B %Y", @time) . ".";
}
print($output "$line\n");
}
# Close the files and move the temporary output into position.
close($input);
close($output);
move($to, $from);
unlink($to);
}
sub update_asio_version_hpp
{
# Open the files.
my $from = "include/asio/version.hpp";
my $to = $from . ".tmp";
open(my $input, "<$from") or die("Can't open $from for reading");
open(my $output, ">$to") or die("Can't open $to for writing");
# Copy the content.
while (my $line = <$input>)
{
chomp($line);
if ($line =~ /^#define ASIO_VERSION /)
{
my $version = $version_major * 100000;
$version += $version_minor * 100;
$version += $version_sub_minor + 0;
$line = "#define ASIO_VERSION " . $version;
$line .= " // $version_major.$version_minor.$version_sub_minor";
}
print($output "$line\n");
}
# Close the files and move the temporary output into position.
close($input);
close($output);
move($to, $from);
unlink($to);
}
sub update_boost_asio_version_hpp
{
# Open the files.
my $from = "../boost/boost/asio/version.hpp";
my $to = $from . ".tmp";
open(my $input, "<$from") or die("Can't open $from for reading");
open(my $output, ">$to") or die("Can't open $to for writing");
# Copy the content.
while (my $line = <$input>)
{
chomp($line);
if ($line =~ /^#define BOOST_ASIO_VERSION /)
{
my $version = $version_major * 100000;
$version += $version_minor * 100;
$version += $version_sub_minor + 0;
$line = "#define BOOST_ASIO_VERSION " . $version;
$line .= " // $version_major.$version_minor.$version_sub_minor";
}
print($output "$line\n");
}
# Close the files and move the temporary output into position.
close($input);
close($output);
move($to, $from);
unlink($to);
}
sub build_asio_doc
{
$ENV{BOOST_ROOT} = abs_path("../boost");
system("rm -rf doc");
my $bjam = abs_path(glob("../boost/bjam"));
chdir("src/doc");
system("$bjam clean");
system("rm -rf html");
system("$bjam");
chdir("../..");
mkdir("doc");
system("cp -vR src/doc/html/* doc");
}
sub build_example_diffs
{
my @cpp11_files = `find src/examples/cpp11 -type f -name "*.*pp"`;
foreach my $cpp11_file (@cpp11_files)
{
chomp($cpp11_file);
my $cpp03_file = $cpp11_file;
$cpp03_file =~ s/\/cpp11\//\/cpp03\//;
my $output_diff = $cpp11_file;
$output_diff =~ s/src\/examples\/cpp11\///g;
my ($output_diff_name, $output_dir) = fileparse($output_diff);
my $output_html = $output_diff . ".html";
mkpath("doc/examples/diffs/$output_dir");
system("diff -U1000000 $cpp03_file $cpp11_file > doc/examples/diffs/$output_diff");
system("cd doc/examples/diffs && diff2html.py -i $output_diff -o $output_html");
unlink("doc/examples/diffs/$output_diff");
}
}
sub make_asio_packages
{
our $asio_name;
system("./autogen.sh");
system("./configure");
system("make dist");
system("tar tfz $asio_name.tar.gz | sed -e 's/^[^\\/]*//' | sort -df > asio.manifest");
}
sub build_boost_asio_doc
{
my $cwd = getcwd();
my $bjam = abs_path(glob("../boost/bjam"));
chdir("../boost/doc");
system("rm -rf html/boost_asio");
chdir("../libs/asio/doc");
system("$bjam clean");
system("$bjam asio");
chdir($cwd);
}
our $boost_asio_readme = <<"EOF";
Copy the `boost', `doc' and `libs' directories into an existing boost 1.33.0,
1.33.1, 1.34, 1.34.1, 1.35 or 1.36 distribution.
Before using Boost.Asio, the Boost.System library needs to be built. This can
be done by running bjam in the libs/system/build directory. Consult the Boost
Getting Started page (http://www.boost.org/more/getting_started.html) for more
information on how to build the Boost libraries.
EOF
our $boost_system_jamfile = <<"EOF";
# Boost System Library Build Jamfile
# (C) Copyright Beman Dawes 2002, 2006
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or www.boost.org/LICENSE_1_0.txt)
# See library home page at http://www.boost.org/libs/system
subproject libs/system/build ;
SOURCES = error_code ;
lib boost_system
: ../src/$(SOURCES).cpp
: # build requirements
<define>BOOST_SYSTEM_STATIC_LINK
<sysinclude>$(BOOST_AUX_ROOT) <sysinclude>$(BOOST_ROOT)
# common-variant-tag ensures that the library will
# be named according to the rules used by the install
# and auto-link features:
common-variant-tag
: debug release # build variants
;
dll boost_system
: ../src/$(SOURCES).cpp
: # build requirements
<define>BOOST_SYSTEM_DYN_LINK=1 # tell source we're building dll's
<runtime-link>dynamic # build only for dynamic runtimes
<sysinclude>$(BOOST_AUX_ROOT) <sysinclude>$(BOOST_ROOT)
# common-variant-tag ensures that the library will
# be named according to the rules used by the install
# and auto-link features:
common-variant-tag
: debug release # build variants
;
install system lib
: <lib>boost_system <dll>boost_system
;
stage stage/lib : <lib>boost_system <dll>boost_system
:
# copy to a path rooted at BOOST_ROOT:
<locate>$(BOOST_ROOT)
# make sure the names of the libraries are correctly named:
common-variant-tag
# add this target to the "stage" and "all" psuedo-targets:
<target>stage
<target>all
:
debug release
;
# end
EOF
sub create_boost_asio_content
{
# Create directory structure.
system("rm -rf $boost_asio_name");
mkdir("$boost_asio_name");
mkdir("$boost_asio_name/doc");
mkdir("$boost_asio_name/doc/html");
mkdir("$boost_asio_name/boost");
mkdir("$boost_asio_name/boost/config");
mkdir("$boost_asio_name/libs");
# Copy files.
system("cp -vLR ../boost/doc/html/boost_asio.html $boost_asio_name/doc/html");
system("cp -vLR ../boost/doc/html/boost_asio $boost_asio_name/doc/html");
system("cp -vLR ../boost/boost/asio.hpp $boost_asio_name/boost");
system("cp -vLR ../boost/boost/asio $boost_asio_name/boost");
system("cp -vLR ../boost/boost/cerrno.hpp $boost_asio_name/boost");
system("cp -vLR ../boost/boost/config/warning_disable.hpp $boost_asio_name/boost/config");
system("cp -vLR ../boost/boost/system $boost_asio_name/boost");
system("cp -vLR ../boost/libs/asio $boost_asio_name/libs");
system("cp -vLR ../boost/libs/system $boost_asio_name/libs");
# Remove modular boost include directories.
system("rm -rf $boost_asio_name/libs/asio/include");
system("rm -rf $boost_asio_name/libs/system/include");
# Add dummy definitions of BOOST_SYMBOL* to boost/system/config.hpp.
my $from = "$boost_asio_name/boost/system/config.hpp";
my $to = "$boost_asio_name/boost/system/config.hpp.new";
open(my $input, "<$from") or die("Can't open $from for reading");
open(my $output, ">$to") or die("Can't open $to for writing");
while (my $line = <$input>)
{
print($output $line);
if ($line =~ /<boost\/config\.hpp>/)
{
print($output "\n// These #defines added by the separate Boost.Asio package.\n");
print($output "#if !defined(BOOST_SYMBOL_IMPORT)\n");
print($output "# if defined(BOOST_HAS_DECLSPEC)\n");
print($output "# define BOOST_SYMBOL_IMPORT __declspec(dllimport)\n");
print($output "# else // defined(BOOST_HAS_DECLSPEC)\n");
print($output "# define BOOST_SYMBOL_IMPORT\n");
print($output "# endif // defined(BOOST_HAS_DECLSPEC)\n");
print($output "#endif // !defined(BOOST_SYMBOL_IMPORT)\n");
print($output "#if !defined(BOOST_SYMBOL_EXPORT)\n");
print($output "# if defined(BOOST_HAS_DECLSPEC)\n");
print($output "# define BOOST_SYMBOL_EXPORT __declspec(dllexport)\n");
print($output "# else // defined(BOOST_HAS_DECLSPEC)\n");
print($output "# define BOOST_SYMBOL_EXPORT\n");
print($output "# endif // defined(BOOST_HAS_DECLSPEC)\n");
print($output "#endif // !defined(BOOST_SYMBOL_EXPORT)\n");
print($output "#if !defined(BOOST_SYMBOL_VISIBLE)\n");
print($output "# define BOOST_SYMBOL_VISIBLE\n");
print($output "#endif // !defined(BOOST_SYMBOL_VISIBLE)\n\n");
}
}
close($input);
close($output);
system("mv $to $from");
# Create readme.
$to = "$boost_asio_name/README.txt";
open($output, ">$to") or die("Can't open $to for writing");
print($output $boost_asio_readme);
close($output);
# Create Boost.System Jamfile.
$to = "$boost_asio_name/libs/system/build/Jamfile";
open($output, ">$to") or die("Can't open $to for writing");
print($output $boost_system_jamfile);
close($output);
# Remove SVN and git files.
system("find $boost_asio_name -name .svn -exec rm -rf {} \\;");
system("find $boost_asio_name -name .git -exec rm -rf {} \\;");
system("find $boost_asio_name -name .gitignore -exec rm -rf {} \\;");
system("find $boost_asio_name -name .gitattributes -exec rm -rf {} \\;");
}
sub make_boost_asio_packages
{
our $boost_asio_name;
system("tar --format=ustar -chf - $boost_asio_name | gzip -c >$boost_asio_name.tar.gz");
system("tar --format=ustar -chf - $boost_asio_name | bzip2 -9 -c >$boost_asio_name.tar.bz2");
system("rm -f $boost_asio_name.zip");
system("zip -rq $boost_asio_name.zip $boost_asio_name");
system("rm -rf $boost_asio_name");
system("tar tfz $boost_asio_name.tar.gz | sed -e 's/^[^\\/]*//' | sort -df > boost_asio.manifest");
}
(scalar(@ARGV) == 1) or print_usage_and_exit();
my $new_version = 1;
my $package_asio = 1;
my $package_boost = 1;
if ($ARGV[0] eq "--package-asio")
{
$new_version = 0;
$package_boost = 0;
}
if ($new_version)
{
determine_version($ARGV[0]);
update_configure_ac();
update_readme();
update_asio_version_hpp();
update_boost_asio_version_hpp();
}
else
{
determine_version_from_configure();
}
if ($package_asio)
{
build_asio_doc();
build_example_diffs();
make_asio_packages();
}
if ($package_boost)
{
build_boost_asio_doc();
create_boost_asio_content();
make_boost_asio_packages();
}
|