harfbuzz/win32/setup.py
fanc999 ad52e044bc Win32/NMake builds: Support builds from GIT (#498)
Add Python scripts to generate the full win32/config.h.win32 and
src/hb-version.h which can be used to build directly from a GIT
checkout.  Since the scripts are currently intended for building from a
GIT checkout, these are not distributed in the release tarballs.

Also, support the re-build of Ragel-generated .hh headers using the NMake
build system, and allow one to specify the path of the Ragel executable
if a suitable one cannot be found in the PATH.

Update the Win32/NMake build documentation to let people know about how
these mechanisms can be utilized.
2017-06-21 18:49:57 +04:30

63 lines
2.2 KiB
Python

#!/usr/bin/python
# vim: encoding=utf-8
#expand *.in files
#this script is only intended for building from git, not for building from the released tarball, which already includes all necessary files
import os
import sys
import re
import string
import subprocess
import optparse
from pc_base import BasePCItems
from replace import replace_multi
def get_version_items(srcroot):
ver = {}
RE_VERSION_LINE_START = re.compile(r'^AC_INIT\(\[(.+)\], *\n')
RE_VERSION_LINE_BODY = re.compile(r'^ \[(.+)\], *\n')
RE_VERSION_LINE_END = re.compile(r'^ \[(.+)\]\) *\n')
# Read from the AC_INIT lines to get the version/name/URLs info
with open(os.path.join(srcroot, 'configure.ac'), 'r') as ac:
for i in ac:
mo_init = RE_VERSION_LINE_START.search(i)
mo_pkg_info = RE_VERSION_LINE_BODY.search(i)
mo_pkg_url = RE_VERSION_LINE_END.search(i)
if mo_init:
ver['@PACKAGE_NAME@'] = mo_init.group(1)
if mo_pkg_info:
if mo_pkg_info.group(1).startswith('http'):
ver['@PACKAGE_BUGREPORT@'] = mo_pkg_info.group(1)
elif mo_pkg_info.group(1)[0].isdigit():
ver['@PACKAGE_VERSION@'] = mo_pkg_info.group(1)
else:
ver['@PACKAGE_TARNAME@'] = mo_pkg_info.group(1)
if mo_pkg_url:
ver['@PACKAGE_URL@'] = mo_pkg_url.group(1)
ver['@HB_VERSION@'] = ver['@PACKAGE_VERSION@']
pkg_ver_parts = ver['@PACKAGE_VERSION@'].split('.')
ver['@HB_VERSION_MAJOR@'] = pkg_ver_parts[0]
ver['@HB_VERSION_MINOR@'] = pkg_ver_parts[1]
ver['@HB_VERSION_MICRO@'] = pkg_ver_parts[2]
return ver
def main(argv):
pc = BasePCItems()
srcroot = pc.top_srcdir
srcdir = pc.srcdir
ver = get_version_items(srcroot)
replace_multi(os.path.join(srcdir, 'config.h.win32.in'),
os.path.join(srcdir, 'config.h.win32'),
ver)
replace_multi(os.path.join(srcroot, 'src', 'hb-version.h.in'),
os.path.join(srcroot, 'src', 'hb-version.h'),
ver)
return 0
if __name__ == '__main__':
sys.exit(main(sys.argv))