[liblouis-liblouisxml] Re: James Teh and others: SCONS

  • From: James Teh <jamie@xxxxxxxxxxxx>
  • To: liblouis-liblouisxml@xxxxxxxxxxxxx
  • Date: Wed, 29 Feb 2012 10:55:53 +1000

Hi John,

I've attached our liblouis sconscript. However:
* This can't be used stand-alone. Rather, it is called from NVDA's sconstruct. Therefore, some of the required set up is not included in this file (although that's probably only a few lines). * This is written for NVDA, so it outputs files in NVDA specific directories and only builds the dll, Python bindings and tables. The tools, documentation, tests, etc. are not handled at all. * There is one compiler flag specific to Windows, but that is only because of the way we build NVDA. * This uses configure.ac and the *.in files used by automake. If you were moving to scons completely, I'd guess it might be neater to get rid of these and instead pass compiler defines, though there are a few exceptions to this. * Scons in-built support for the Windows SDK tends to break from time to time (I'm not sure what the current status is), so we have written our own. I can provide this, though it's currently under the terms of the GPL (not LGPL).

Jamie

On 29/02/2012 10:10 AM, John J. Boyer wrote:
Hi Jamie,

There has been considerable discussion on the BrailleBlaster list of
SCONS in preparation for the next release. I am also thinking of using
it for liblouisutdml Could you send your SCONS files for liblouis as
attachments to this list? That would help us get started.

Thanks,
John


--
James Teh
Director, NV Access Limited
Email: jamie@xxxxxxxxxxxx
Web site: http://www.nvaccess.org/
Phone: +61 7 5667 8372
###
#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<name>.*), (?P<version>.*), 
(?P<maintainer>.*)\)")
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="/W0")
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",
]
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")
        ])

Other related posts: