Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/mpl/preprocessed/preprocess.py @ 44

Last change on this file since 44 was 29, checked in by landauf, 16 years ago

updated boost from 1_33_1 to 1_34_1

File size: 2.7 KB
Line 
1
2# Copyright Aleksey Gurtovoy 2001-2004
3#
4# Distributed under the Boost Software License, Version 1.0.
5# (See accompanying file LICENSE_1_0.txt or copy at
6# http://www.boost.org/LICENSE_1_0.txt)
7#
8# See http://www.boost.org/libs/mpl for documentation.
9
10# $Source: /cvsroot/boost/boost/libs/mpl/preprocessed/preprocess.py,v $
11# $Date: 2005/10/04 08:35:29 $
12# $Revision: 1.5 $
13
14import pp
15import shutil
16import os.path
17import os
18import string
19import sys
20
21preprocess_cmd = open( "preprocess.cmd" ).readlines()[0]
22
23def process( file, boost_root, dst_dir, mode ):
24    file_path = "%s.hpp" % os.path.splitext( file )[0]
25    os.system( preprocess_cmd % {
26          'boost_root': boost_root
27        , 'mode': mode
28        , 'file': file
29        , 'file_path': file_path
30        } )
31
32    os.rename( file_path, "%s.tmp" % file_path )
33    pp.main( "%s.tmp" % file_path, file_path )
34    os.remove( "%s.tmp" % file_path )
35
36    filename = os.path.basename(file_path)
37    dst_dir = os.path.join( dst_dir, mode )
38    dst_file = os.path.join( dst_dir, filename )
39
40    if os.path.exists( dst_file ):
41        shutil.copymode( filename, dst_file )
42       
43    shutil.copy( filename, dst_dir )
44    os.remove( filename )
45
46
47def process_all( root, boost_root, dst_dir, mode ):
48    files = os.listdir( root )
49    for file in files:
50        path = os.path.join( root, file )
51        if os.path.splitext( file )[1] == ".cpp":
52            process( path, boost_root, dst_dir, mode )
53        else:
54            if os.path.isdir( path ):
55                process_all( path, boost_root, dst_dir, mode )
56
57
58def main( all_modes, src_dir, dst_dir ):
59    if len( sys.argv ) < 2:
60        print "\nUsage:\n\t %s <mode> <boost_root> [<source_file>]" % os.path.basename( sys.argv[0] )
61        print "\nPurpose:\n\t updates preprocessed version(s) of the header(s) in \"%s\" directory" % dst_dir
62        print "\nExample:\n\t the following command will re-generate and update all 'apply.hpp' headers:"
63        print "\n\t\t %s all f:\\cvs\\boost apply.cpp" % os.path.basename( sys.argv[0] )
64        sys.exit( -1 )
65
66    if sys.argv[1] == "all":
67        modes = all_modes
68    else:
69        modes = [sys.argv[1]]
70
71    boost_root = sys.argv[2]
72    dst_dir = os.path.join( boost_root, dst_dir )
73   
74    for mode in modes:
75        if len( sys.argv ) > 3:
76            file = os.path.join( os.path.join( os.getcwd(), src_dir ), sys.argv[3] )
77            process( file, boost_root, dst_dir, mode )
78        else:
79            process_all( os.path.join( os.getcwd(), src_dir ), boost_root, dst_dir, mode )
80
81
82if __name__ == '__main__':
83   
84    main(
85          ["bcc", "bcc551", "gcc", "msvc60", "msvc70", "mwcw", "dmc", "no_ctps", "no_ttp", "plain"]
86        , "src"
87        , os.path.join( "boost", "mpl", "aux_", "preprocessed" )
88        )
Note: See TracBrowser for help on using the repository browser.