from optparse import OptionParser
from subprocess import Popen, PIPE, STDOUT
from itertools import takewhile
from os.path import realpath, dirname, join, splitext, exists, relpath, basename, getctime
pyversion = float(sys.version_info[0]) + float(sys.version_info[1]) / 10.0
root = realpath(dirname(dirname(__file__)))
test_path = "tests/tools-cxx"
properties_path = join(root,'build.properties')
state_path = join(root,'build.json')
props = None ### build properties (filled below)
state = None ### build state (filled below)
return bytes(s,sys.getdefaultencoding())
return bs.decode(sys.getdefaultencoding(),"strict")
if isinstance(output,bytes) or isinstance(output,bytearray):
return str_decode(output)
elif isinstance(output,tuple):
return (None if output[0] is None else str_decode(output[0]),None if output[1] is None else str_decode(output[1]))
### process command line arguments
argp.add_option( "-A", "--all", dest="all",
action="store_true", help="run all available tests",
argp.add_option( "-T", "--time", dest="timecheck",
action="store_false", help="do NOT check timestamps, compile all",
argp.add_option( "-L", "--list-tests", dest="list_tests",
action="store_true", help="display available tests",
argp.add_option( "-D", "--debug", dest="debug", action="store_true",
help="build with debugging information", default=False )
argp.add_option( "-R", "--debug-opt", dest="relwithdebinfo", action="store_true",
help="build with debugging information and optimization turned on", default=False )
argp.add_option( "-V", "--verbose", dest="verbose", action="store_true",
help="display verbose output", default=False )
argp.add_option( "-C", "--compile", dest="compile", action="store_true",
help="display compiling information", default=False )
(options, tests) = argp.parse_args()
### sort function that allows sorting and the using the sorted list directly
### check if destination (exe) is newer than the source (src) file
def up_to_date( src, exe ):
return exists(exe) and getctime(src) < getctime(exe)
### see Roberto's comment in:
### https://stackoverflow.com/questions/3595363/properties-file-in-python-similar-to-java-properties
def load_properties(filepath, sep='=', comment_char='#'):
Read the file passed as parameter as a properties file.
with open(filepath, "rt") as f:
if l and not l.startswith(comment_char):