sconscript 2.06 KB
###
#This file is a part of the NVDA project.
#URL: http://www.nvda-project.org/
#Copyright 2006-2012 NVDA contributers.
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License version 2.0, as published by
#the Free Software Foundation.
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#This license can be found at:
#http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
###

import os
import re

Import([
	"env",
	"sourceDir",
])

louisRootDir = env.Dir("#include/liblouis")
louisSourceDir = louisRootDir.Dir("liblouis")
outDir = sourceDir.Dir("louis")

RE_AC_INIT = re.compile(r"^AC_INIT\(\[(?P<package>.*)\], \[(?P<version>.*)\], \[(?P<bugReport>.*)\], \[(?P<tarName>.*)\], \[(?P<url>.*)\]\)")
def getLouisVersion():
	# Get the version from configure.ac.
	with file(louisRootDir.File("configure.ac").abspath) as f:
		for line in f:
			m = RE_AC_INIT.match(line)
			if m:
				return m.group("version")
	return "unknown"

env = env.Clone()
env.Append(CCFLAGS="/W2")
env.Append(CPPDEFINES=[
	("PACKAGE_VERSION", r'\"%s\"' % getLouisVersion()),
	("UNICODE_BITS", 16),
])
env.Prepend(CPPPATH=[".", louisSourceDir])

liblouisH = env.Substfile("liblouis.h", louisSourceDir.File("liblouis.h.in"),
	SUBST_DICT={"@WIDECHAR_TYPE@": "unsigned short int"})

sourceFiles = [
	"compileTranslationTable.c",
	"lou_translateString.c",
	"lou_backTranslateString.c",
	"wrappers.c",
	"logging.c",
]
objs = [env.Object("%s.obj" % f, louisSourceDir.File(f)) for f in sourceFiles]
louisLib = env.SharedLibrary("liblouis", objs + ["liblouis.def"])
env.Install(sourceDir, louisLib)

louisPython = env.Substfile(outDir.File("__init__.py"), louisRootDir.File("python/louis/__init__.py.in"),
	SUBST_DICT={"###LIBLOUIS_SONAME###": louisLib[0].name})

env.Install(outDir.Dir("tables"),
	[f for f in env.Glob("%s/tables/*" % louisRootDir)
		if f.name not in ("Makefile", "Makefile.am", "Makefile.in", "README", "maketablelist.sh")
	])