mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-10-15 15:16:47 +02:00
- 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
This commit is contained in:
44
doxybuild.py
44
doxybuild.py
@@ -6,47 +6,7 @@ import os
|
||||
import os.path
|
||||
import sys
|
||||
import shutil
|
||||
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()
|
||||
|
||||
from devtools import tarball
|
||||
|
||||
def find_program(filename):
|
||||
"""find a program in folders path_lst, and sets env[var]
|
||||
@@ -171,7 +131,7 @@ def build_doc( options, make_release=False ):
|
||||
'version'
|
||||
]
|
||||
tarball_basedir = os.path.join( full_output_dir, html_output_dirname )
|
||||
make_tarball( tarball_path, tarball_sources, tarball_basedir, html_output_dirname )
|
||||
tarball.make_tarball( tarball_path, tarball_sources, tarball_basedir, html_output_dirname )
|
||||
|
||||
def main():
|
||||
usage = """%prog
|
||||
|
Reference in New Issue
Block a user