mirror of
https://github.com/capstone-engine/capstone.git
synced 2025-02-03 12:34:44 +00:00
Python: Automatically conform to PEP440 for version numbers. ported from Unicorn Python binding
This commit is contained in:
parent
76b94cba23
commit
617c64fbb5
@ -14,7 +14,6 @@ from distutils.command.sdist import sdist
|
||||
from setuptools.command.bdist_egg import bdist_egg
|
||||
|
||||
SYSTEM = sys.platform
|
||||
VERSION = '4.0.0'
|
||||
|
||||
# adapted from commit e504b81 of Nguyen Tan Cong
|
||||
# Reference: https://docs.python.org/2/library/platform.html#cross-platform
|
||||
@ -27,6 +26,36 @@ HEADERS_DIR = os.path.join(ROOT_DIR, 'capstone', 'include')
|
||||
SRC_DIR = os.path.join(ROOT_DIR, 'src')
|
||||
BUILD_DIR = SRC_DIR if os.path.exists(SRC_DIR) else os.path.join(ROOT_DIR, '../..')
|
||||
|
||||
# Parse version from pkgconfig.mk
|
||||
VERSION_DATA = {}
|
||||
with open(os.path.join(BUILD_DIR, 'pkgconfig.mk')) as fp:
|
||||
lines = fp.readlines()
|
||||
for line in lines:
|
||||
line = line.strip()
|
||||
if len(line) == 0:
|
||||
continue
|
||||
if line.startswith('#'):
|
||||
continue
|
||||
if '=' not in line:
|
||||
continue
|
||||
|
||||
k, v = line.split('=', 1)
|
||||
k = k.strip()
|
||||
v = v.strip()
|
||||
if len(k) == 0 or len(v) == 0:
|
||||
continue
|
||||
VERSION_DATA[k] = v
|
||||
|
||||
if 'PKG_MAJOR' not in VERSION_DATA or \
|
||||
'PKG_MINOR' not in VERSION_DATA or \
|
||||
'PKG_EXTRA' not in VERSION_DATA:
|
||||
raise Exception("Malformed pkgconfig.mk")
|
||||
|
||||
if 'PKG_TAG' in VERSION_DATA:
|
||||
VERSION = '{PKG_MAJOR}.{PKG_MINOR}.{PKG_EXTRA}.{PKG_TAG}'.format(**VERSION_DATA)
|
||||
else:
|
||||
VERSION = '{PKG_MAJOR}.{PKG_MINOR}.{PKG_EXTRA}'.format(**VERSION_DATA)
|
||||
|
||||
if SYSTEM == 'darwin':
|
||||
VERSIONED_LIBRARY_FILE = "libcapstone.4.dylib"
|
||||
LIBRARY_FILE = "libcapstone.dylib"
|
||||
@ -69,6 +98,7 @@ def copy_sources():
|
||||
src.extend(glob.glob(os.path.join(BUILD_DIR, "RELEASE_NOTES")))
|
||||
src.extend(glob.glob(os.path.join(BUILD_DIR, "make.sh")))
|
||||
src.extend(glob.glob(os.path.join(BUILD_DIR, "CMakeLists.txt")))
|
||||
src.extend(glob.glob(os.path.join(BUILD_DIR, "pkgconfig.mk")))
|
||||
|
||||
for filename in src:
|
||||
outpath = os.path.join(SRC_DIR, os.path.basename(filename))
|
||||
|
@ -6,4 +6,7 @@ PKG_MAJOR = 4
|
||||
PKG_MINOR = 0
|
||||
|
||||
# version bugfix level. Example: PKG_EXTRA = 1
|
||||
PKG_EXTRA =
|
||||
PKG_EXTRA = 0
|
||||
|
||||
# version tag. Examples: rc1, b2, post1
|
||||
PKG_TAG = rc1
|
||||
|
Loading…
x
Reference in New Issue
Block a user