diff --git a/.hgignore b/.hgignore index 7e37eb9..0bc7b92 100644 --- a/.hgignore +++ b/.hgignore @@ -4,6 +4,8 @@ syntax: glob *.pyc *.o *.a +*.dll +*.so *.exe *.app drone diff --git a/binding/binding.pro b/binding/binding.pro new file mode 100644 index 0000000..68b7a58 --- /dev/null +++ b/binding/binding.pro @@ -0,0 +1,4 @@ +TEMPLATE = lib +CONFIG += pkg_info + +include(../version.pri) diff --git a/binding/setup.py b/binding/setup.py index 3e9040a..96f0810 100644 --- a/binding/setup.py +++ b/binding/setup.py @@ -17,42 +17,43 @@ import json import os -import re import shutil import sys -from setuptools import setup +from setuptools import Command, setup +from setuptools.command.sdist import sdist as _sdist def read(fname): - return open(fname).read() + return open(os.path.join(os.path.dirname(__file__), fname)).read() -def get_pkg_info(): - info = {} - t = open('../server/version.cpp').read() - info['version'] = re.search('version = "([^"]*)"', t).group(1) - info['revision'] = re.search('revision = "([^"]*)"', t).group(1) - return info - -# ------- script starts from here ------- # - -if len(sys.argv) >= 2 and sys.argv[1] == 'clean_sdist': - shutil.rmtree('dist', ignore_errors = True) - shutil.rmtree('ostinato.egg-info', ignore_errors = True) - if os.path.exists('pkg_info.json'): - os.remove('pkg_info.json') - sys.exit(0) - -if len(sys.argv) >= 2 and sys.argv[1] == 'sdist': +def ensure_cwd(): if os.path.split(os.getcwd())[1] != 'binding': - print 'This script needs to be run from the binding directory' + print 'ERROR: This script needs to be run from the binding directory' print 'Current Working Directory is %s' % os.getcwd() sys.exit(1) - pkg_info = get_pkg_info() - with open('pkg_info.json', 'wt') as f: - json.dump(pkg_info, f, indent=4) -else: - with open('pkg_info.json') as f: - pkg_info = json.load(f) +class sdist(_sdist): + def run(self): + ensure_cwd() + _sdist.run(self) + +class sdist_clean(Command): + description = 'clean stuff generated by sdist' + user_options = [] + def initialize_options(self): + return + + def finalize_options(self): + return + + def run(self): + ensure_cwd() + shutil.rmtree('dist', ignore_errors = True) + shutil.rmtree('ostinato.egg-info', ignore_errors = True) + +# ------- script starts from here ------- # + +with open(os.path.join(os.path.dirname(__file__), 'pkg_info.json')) as f: + pkg_info = json.load(f) setup(name = 'ostinato', version = pkg_info['version'], @@ -72,6 +73,9 @@ setup(name = 'ostinato', 'Intended Audience :: Telecommunications Industry', 'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)', 'Topic :: Software Development :: Testing :: Traffic Generation', - 'Topic :: System :: Networking'] + 'Topic :: System :: Networking'], + cmdclass={ + 'sdist': sdist, + 'sdist_clean': sdist_clean}, ) diff --git a/client/ostinato.pro b/client/ostinato.pro index d5fd459..9a4af25 100644 --- a/client/ostinato.pro +++ b/client/ostinato.pro @@ -1,5 +1,5 @@ TEMPLATE = app -CONFIG += qt +CONFIG += qt ver_info macx: TARGET = Ostinato win32:RC_FILE = ostinato.rc macx:ICON = icons/logo.icns diff --git a/ost.pro b/ost.pro index 9e8bbea..0e758eb 100644 --- a/ost.pro +++ b/ost.pro @@ -6,4 +6,6 @@ SUBDIRS = \ common/ostproto.pro \ common/ostprotogui.pro \ server/drone.pro \ - client/ostinato.pro + client/ostinato.pro \ + binding/binding.pro + diff --git a/server/drone.pro b/server/drone.pro index be69521..54efd8b 100644 --- a/server/drone.pro +++ b/server/drone.pro @@ -1,5 +1,5 @@ TEMPLATE = app -CONFIG += qt +CONFIG += qt ver_info QT += network script QT -= gui DEFINES += HAVE_REMOTE WPCAP diff --git a/version.pri b/version.pri index 718ce69..a76c889 100644 --- a/version.pri +++ b/version.pri @@ -2,18 +2,41 @@ APP_VERSION = 0.5.1 APP_REVISION = $(shell hg identify -i) #uncomment the below line in a source package and fill-in the correct revision #APP_REVISION = @ -APP_VERSION_FILE = version.cpp -revtarget.target = $$APP_VERSION_FILE -win32:revtarget.commands = echo "const char *version = \"$$APP_VERSION\";" \ - "const char *revision = \"$$APP_REVISION\";" \ - > $$APP_VERSION_FILE -unix:revtarget.commands = echo \ - "\"const char *version = \\\"$$APP_VERSION\\\";" \ - "const char *revision = \\\"$$APP_REVISION\\\";\"" \ - > $$APP_VERSION_FILE -revtarget.depends = $$SOURCES $$HEADERS $$FORMS $$POST_TARGETDEPS -SOURCES += $$APP_VERSION_FILE -QMAKE_EXTRA_TARGETS += revtarget -POST_TARGETDEPS += $$APP_VERSION_FILE -QMAKE_DISTCLEAN += $$APP_VERSION_FILE +ver_info { + APP_VERSION_FILE = version.cpp + revtarget.target = $$APP_VERSION_FILE + win32:revtarget.commands = echo "const char *version = \"$$APP_VERSION\";" \ + "const char *revision = \"$$APP_REVISION\";" \ + > $$APP_VERSION_FILE + unix:revtarget.commands = echo \ + "\"const char *version = \\\"$$APP_VERSION\\\";" \ + "const char *revision = \\\"$$APP_REVISION\\\";\"" \ + > $$APP_VERSION_FILE + revtarget.depends = $$SOURCES $$HEADERS $$FORMS $$POST_TARGETDEPS + + SOURCES += $$APP_VERSION_FILE + QMAKE_EXTRA_TARGETS += revtarget + POST_TARGETDEPS += $$APP_VERSION_FILE + QMAKE_DISTCLEAN += $$APP_VERSION_FILE +} + +pkg_info { + PKG_INFO_FILE = pkg_info.json + pkginfo.target = $$PKG_INFO_FILE + pkginfo.CONFIG = recursive + win32:pkginfo.commands = echo "{" \ + " \"version\": \"$$APP_VERSION\"," \ + " \"revision\": \"$$APP_REVISION\"" \ + "}" \ + > $$PKG_INFO_FILE + unix:pkginfo.commands = echo "\"{" \ + " \\\"version\\\": \\\"$$APP_VERSION\\\"," \ + " \\\"revision\\\": \\\"$$APP_REVISION\\\"" \ + "}\"" \ + > $$PKG_INFO_FILE + + QMAKE_EXTRA_TARGETS += pkginfo + POST_TARGETDEPS += $$PKG_INFO_FILE + QMAKE_DISTCLEAN += $$PKG_INFO_FILE +}