Skip to content

Commit 3afda5d

Browse files
author
blep
committed
- added the following step to make_release: fix EOL in distribution source, generate source tarball.
- devtools/ was made into a python module and common utilities are being moved in this module git-svn-id: https://jsoncpp.svn.sourceforge.net/svnroot/jsoncpp/trunk/jsoncpp@113 1f120ed1-78a5-a849-adca-83f0a9e25bb6
1 parent ffbeb3d commit 3afda5d

File tree

7 files changed

+146
-280
lines changed

7 files changed

+146
-280
lines changed

devtools/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# module

devtools/fixeol.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import os.path
2+
3+
def fix_source_eol( path, is_dry_run = True, verbose = True, eol = '\n' ):
4+
"""Makes sure that all sources have the specified eol sequence (default: unix)."""
5+
if not os.path.isfile( path ):
6+
raise ValueError( 'Path "%s" is not a file' % path )
7+
try:
8+
f = open(path, 'rb')
9+
except IOError, msg:
10+
print >> sys.stderr, "%s: I/O Error: %s" % (file, str(msg))
11+
return False
12+
try:
13+
raw_lines = f.readlines()
14+
finally:
15+
f.close()
16+
fixed_lines = [line.rstrip('\r\n') + eol for line in raw_lines]
17+
if raw_lines != fixed_lines:
18+
print '%s =>' % path,
19+
if not is_dry_run:
20+
f = open(path, "wb")
21+
try:
22+
f.writelines(fixed_lines)
23+
finally:
24+
f.close()
25+
if verbose:
26+
print is_dry_run and ' NEED FIX' or ' FIXED'
27+
return True
28+
##
29+
##
30+
##
31+
##def _do_fix( is_dry_run = True ):
32+
## from waftools import antglob
33+
## python_sources = antglob.glob( '.',
34+
## includes = '**/*.py **/wscript **/wscript_build',
35+
## excludes = antglob.default_excludes + './waf.py',
36+
## prune_dirs = antglob.prune_dirs + 'waf-* ./build' )
37+
## for path in python_sources:
38+
## _fix_python_source( path, is_dry_run )
39+
##
40+
## cpp_sources = antglob.glob( '.',
41+
## includes = '**/*.cpp **/*.h **/*.inl',
42+
## prune_dirs = antglob.prune_dirs + 'waf-* ./build' )
43+
## for path in cpp_sources:
44+
## _fix_source_eol( path, is_dry_run )
45+
##
46+
##
47+
##def dry_fix(context):
48+
## _do_fix( is_dry_run = True )
49+
##
50+
##def fix(context):
51+
## _do_fix( is_dry_run = False )
52+
##
53+
##def shutdown():
54+
## pass
55+
##
56+
##def check(context):
57+
## # Unit tests are run when "check" target is used
58+
## ut = UnitTest.unit_test()
59+
## ut.change_to_testfile_dir = True
60+
## ut.want_to_see_test_output = True
61+
## ut.want_to_see_test_error = True
62+
## ut.run()
63+
## ut.print_results()

devtools/tarball.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import os.path
2+
import gzip
3+
import tarfile
4+
5+
TARGZ_DEFAULT_COMPRESSION_LEVEL = 9
6+
7+
def make_tarball(tarball_path, sources, base_dir, prefix_dir=''):
8+
"""Parameters:
9+
tarball_path: output path of the .tar.gz file
10+
sources: list of sources to include in the tarball, relative to the current directory
11+
base_dir: if a source file is in a sub-directory of base_dir, then base_dir is stripped
12+
from path in the tarball.
13+
prefix_dir: all files stored in the tarball be sub-directory of prefix_dir. Set to ''
14+
to make them child of root.
15+
"""
16+
base_dir = os.path.normpath( os.path.abspath( base_dir ) )
17+
def archive_name( path ):
18+
"""Makes path relative to base_dir."""
19+
path = os.path.normpath( os.path.abspath( path ) )
20+
common_path = os.path.commonprefix( (base_dir, path) )
21+
archive_name = path[len(common_path):]
22+
if os.path.isabs( archive_name ):
23+
archive_name = archive_name[1:]
24+
return os.path.join( prefix_dir, archive_name )
25+
def visit(tar, dirname, names):
26+
for name in names:
27+
path = os.path.join(dirname, name)
28+
if os.path.isfile(path):
29+
path_in_tar = archive_name(path)
30+
tar.add(path, path_in_tar )
31+
compression = TARGZ_DEFAULT_COMPRESSION_LEVEL
32+
fileobj = gzip.GzipFile( tarball_path, 'wb', compression )
33+
tar = tarfile.TarFile(os.path.splitext(tarball_path)[0], 'w', fileobj)
34+
for source in sources:
35+
source_path = source
36+
if os.path.isdir( source ):
37+
os.path.walk(source_path, visit, tar)
38+
else:
39+
path_in_tar = archive_name(source_path)
40+
tar.add(source_path, path_in_tar ) # filename, arcname
41+
tar.close()

devtools/wscript

Lines changed: 0 additions & 225 deletions
This file was deleted.

doxybuild.py

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,47 +6,7 @@
66
import os.path
77
import sys
88
import shutil
9-
import gzip
10-
import tarfile
11-
12-
TARGZ_DEFAULT_COMPRESSION_LEVEL = 9
13-
14-
def make_tarball(tarball_path, sources, base_dir, prefix_dir=''):
15-
"""Parameters:
16-
tarball_path: output path of the .tar.gz file
17-
sources: list of sources to include in the tarball, relative to the current directory
18-
base_dir: if a source file is in a sub-directory of base_dir, then base_dir is stripped
19-
from path in the tarball.
20-
prefix_dir: all files stored in the tarball be sub-directory of prefix_dir. Set to ''
21-
to make them child of root.
22-
"""
23-
base_dir = os.path.normpath( os.path.abspath( base_dir ) )
24-
def archive_name( path ):
25-
"""Makes path relative to base_dir."""
26-
path = os.path.normpath( os.path.abspath( path ) )
27-
common_path = os.path.commonprefix( (base_dir, path) )
28-
archive_name = path[len(common_path):]
29-
if os.path.isabs( archive_name ):
30-
archive_name = archive_name[1:]
31-
return os.path.join( prefix_dir, archive_name )
32-
def visit(tar, dirname, names):
33-
for name in names:
34-
path = os.path.join(dirname, name)
35-
if os.path.isfile(path):
36-
path_in_tar = archive_name(path)
37-
tar.add(path, path_in_tar )
38-
compression = TARGZ_DEFAULT_COMPRESSION_LEVEL
39-
fileobj = gzip.GzipFile( tarball_path, 'wb', compression )
40-
tar = tarfile.TarFile(os.path.splitext(tarball_path)[0], 'w', fileobj)
41-
for source in sources:
42-
source_path = source
43-
if os.path.isdir( source ):
44-
os.path.walk(source_path, visit, tar)
45-
else:
46-
path_in_tar = archive_name(source_path)
47-
tar.add(source_path, path_in_tar ) # filename, arcname
48-
tar.close()
49-
9+
from devtools import tarball
5010

5111
def find_program(filename):
5212
"""find a program in folders path_lst, and sets env[var]
@@ -171,7 +131,7 @@ def yesno( bool ):
171131
'version'
172132
]
173133
tarball_basedir = os.path.join( full_output_dir, html_output_dirname )
174-
make_tarball( tarball_path, tarball_sources, tarball_basedir, html_output_dirname )
134+
tarball.make_tarball( tarball_path, tarball_sources, tarball_basedir, html_output_dirname )
175135

176136
def main():
177137
usage = """%prog

0 commit comments

Comments
 (0)