forked from open-source-parsers/jsoncpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- added the following step to make_release: fix EOL in distribution s…
…ource, generate source tarball. - devtools/ was made into a python module and common utilities are being moved in this module
- Loading branch information
Showing
7 changed files
with
146 additions
and
280 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import os.path | ||
|
||
def fix_source_eol( path, is_dry_run = True, verbose = True, eol = '\n' ): | ||
"""Makes sure that all sources have the specified eol sequence (default: unix).""" | ||
if not os.path.isfile( path ): | ||
raise ValueError( 'Path "%s" is not a file' % path ) | ||
try: | ||
f = open(path, 'rb') | ||
except IOError, msg: | ||
print >> sys.stderr, "%s: I/O Error: %s" % (file, str(msg)) | ||
return False | ||
try: | ||
raw_lines = f.readlines() | ||
finally: | ||
f.close() | ||
fixed_lines = [line.rstrip('\r\n') + eol for line in raw_lines] | ||
if raw_lines != fixed_lines: | ||
print '%s =>' % path, | ||
if not is_dry_run: | ||
f = open(path, "wb") | ||
try: | ||
f.writelines(fixed_lines) | ||
finally: | ||
f.close() | ||
if verbose: | ||
print is_dry_run and ' NEED FIX' or ' FIXED' | ||
return True | ||
## | ||
## | ||
## | ||
##def _do_fix( is_dry_run = True ): | ||
## from waftools import antglob | ||
## python_sources = antglob.glob( '.', | ||
## includes = '**/*.py **/wscript **/wscript_build', | ||
## excludes = antglob.default_excludes + './waf.py', | ||
## prune_dirs = antglob.prune_dirs + 'waf-* ./build' ) | ||
## for path in python_sources: | ||
## _fix_python_source( path, is_dry_run ) | ||
## | ||
## cpp_sources = antglob.glob( '.', | ||
## includes = '**/*.cpp **/*.h **/*.inl', | ||
## prune_dirs = antglob.prune_dirs + 'waf-* ./build' ) | ||
## for path in cpp_sources: | ||
## _fix_source_eol( path, is_dry_run ) | ||
## | ||
## | ||
##def dry_fix(context): | ||
## _do_fix( is_dry_run = True ) | ||
## | ||
##def fix(context): | ||
## _do_fix( is_dry_run = False ) | ||
## | ||
##def shutdown(): | ||
## pass | ||
## | ||
##def check(context): | ||
## # Unit tests are run when "check" target is used | ||
## ut = UnitTest.unit_test() | ||
## ut.change_to_testfile_dir = True | ||
## ut.want_to_see_test_output = True | ||
## ut.want_to_see_test_error = True | ||
## ut.run() | ||
## ut.print_results() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import os.path | ||
import gzip | ||
import tarfile | ||
|
||
TARGZ_DEFAULT_COMPRESSION_LEVEL = 9 | ||
|
||
def make_tarball(tarball_path, sources, base_dir, prefix_dir=''): | ||
"""Parameters: | ||
tarball_path: output path of the .tar.gz file | ||
sources: list of sources to include in the tarball, relative to the current directory | ||
base_dir: if a source file is in a sub-directory of base_dir, then base_dir is stripped | ||
from path in the tarball. | ||
prefix_dir: all files stored in the tarball be sub-directory of prefix_dir. Set to '' | ||
to make them child of root. | ||
""" | ||
base_dir = os.path.normpath( os.path.abspath( base_dir ) ) | ||
def archive_name( path ): | ||
"""Makes path relative to base_dir.""" | ||
path = os.path.normpath( os.path.abspath( path ) ) | ||
common_path = os.path.commonprefix( (base_dir, path) ) | ||
archive_name = path[len(common_path):] | ||
if os.path.isabs( archive_name ): | ||
archive_name = archive_name[1:] | ||
return os.path.join( prefix_dir, archive_name ) | ||
def visit(tar, dirname, names): | ||
for name in names: | ||
path = os.path.join(dirname, name) | ||
if os.path.isfile(path): | ||
path_in_tar = archive_name(path) | ||
tar.add(path, path_in_tar ) | ||
compression = TARGZ_DEFAULT_COMPRESSION_LEVEL | ||
fileobj = gzip.GzipFile( tarball_path, 'wb', compression ) | ||
tar = tarfile.TarFile(os.path.splitext(tarball_path)[0], 'w', fileobj) | ||
for source in sources: | ||
source_path = source | ||
if os.path.isdir( source ): | ||
os.path.walk(source_path, visit, tar) | ||
else: | ||
path_in_tar = archive_name(source_path) | ||
tar.add(source_path, path_in_tar ) # filename, arcname | ||
tar.close() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.