File: preprocess.pl

package info (click to toggle)
boost1.83 1.83.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 545,632 kB
  • sloc: cpp: 3,857,086; xml: 125,552; ansic: 34,414; python: 25,887; asm: 5,276; sh: 4,799; ada: 1,681; makefile: 1,629; perl: 1,212; pascal: 1,139; sql: 810; yacc: 478; ruby: 102; lisp: 24; csh: 6
file content (122 lines) | stat: -rw-r--r-- 3,212 bytes parent folder | download | duplicates (12)
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
# // (C) Copyright Tobias Schwinger
# //
# // Use modification and distribution are subject to the boost Software License
# // Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt).

# // Preprocess and run this script.
# //
# // Invocation example using the GNU preprocessor:
# //
# //   g++ -I$BOOST_ROOT -x c++ preprocess.pl -E |perl
# //
# // or in two steps:
# //
# //   g++ -I$BOOST_ROOT -x c++ preprocess.pl -E >temp.pl
# //   perl temp.pl

#define die(x) 1
die("ERROR: this script has to be preprocessed, stopped");
#undef die

use strict vars;
use File::Spec updir,curdir,catfile,canonpath,splitpath,file_name_is_absolute;

# // --- Settings
my $up = File::Spec->updir();

# // Relative path to the destination directory.
my $path = File::Spec->catdir($up,$up,$up,'boost','typeof');

my $license = qq@
/\/ Copyright (C) 2005 Arkadiy Vertleyb
/\/ Copyright (C) 2005 Peder Holt
/\/ 
/\/ Use modification and distribution are subject to the boost Software License,
/\/ Version 1.0. (See http:/\/www.boost.org/LICENSE_1_0.txt).

/\/ Preprocessed code, do not edit manually !

@;
# //---

# // Find this script's directory if run directly from the shell (not piped)
$path = File::Spec->canonpath
( File::Spec->catfile
  ( File::Spec->file_name_is_absolute($0)
    ? $0 : (File::Spec->curdir(),$0)
  , $up
  , File::Spec->splitpath($path)
  )
) unless ($0 eq '-');
die 
( ($0 eq '-')
  ? "ERROR: please run from this script's directory, stopped" 
  : "ERROR: target directoty not found, stopped" 
) unless (-d $path);

# // Tidy up the contents and write it to a file
sub write_down(name,contents)
{
  my($name,$contents) = @_; 
  my $filename = $name;

  my $fqfname = File::Spec->catfile($path,$filename);
  $contents =~ s"(((\n|^)\s*\#[^\n]+)|(\s*\n)){2,}"\n"g; # "
  print STDERR "Writing file: '$filename'\n";
  open my($file),">$fqfname" 
    or die "ERROR: unable to open file '$filename' for writing, stopped";
  print $file $license;
  print $file $contents;
  close $file;
}

# // Include external components to ensure they don't end up in the recorded
# // output
#define BOOST_TYPEOF_PP_INCLUDE_EXTERNAL
my $sewer = <<'%--%-EOF-%--%'
#include <boost/typeof/vector.hpp>
#undef  BOOST_TYPEOF_VECTOR_HPP_INCLUDED
%--%-EOF-%--%
; $sewer = '';


#define BOOST_TYPEOF_PREPROCESSING_MODE
#define BOOST_TYPEOF_LIMIT_SIZE 50
#define BOOST_TYPEOF_PP_NEXT_SIZE 100

&write_down('vector50.hpp',<<'%--%-EOF-%--%'
#include <boost/typeof/vector.hpp>
%--%-EOF-%--%
);
#undef  BOOST_TYPEOF_VECTOR_HPP_INCLUDED

#undef  BOOST_TYPEOF_LIMIT_SIZE
#define BOOST_TYPEOF_LIMIT_SIZE 100
#define BOOST_TYPEOF_PP_NEXT_SIZE 149

&write_down('vector100.hpp',<<'%--%-EOF-%--%'
#include <boost/typeof/vector.hpp>
%--%-EOF-%--%
);
#undef  BOOST_TYPEOF_VECTOR_HPP_INCLUDED

#undef  BOOST_TYPEOF_LIMIT_SIZE
#define BOOST_TYPEOF_LIMIT_SIZE 150
#define BOOST_TYPEOF_PP_NEXT_SIZE 199


&write_down('vector150.hpp',<<'%--%-EOF-%--%'
#include <boost/typeof/vector.hpp>
%--%-EOF-%--%
);
#undef  BOOST_TYPEOF_VECTOR_HPP_INCLUDED

#undef  BOOST_TYPEOF_LIMIT_SIZE
#define BOOST_TYPEOF_LIMIT_SIZE 200
#define BOOST_TYPEOF_PP_NEXT_SIZE 250

&write_down('vector200.hpp',<<'%--%-EOF-%--%'
#include <boost/typeof/vector.hpp>
%--%-EOF-%--%
);