Revision a7294878672fa92c5a6b368fd6e0da363aa5029b authored by gchabert on 27 January 2017, 08:04:11 UTC, committed by gchabert on 27 January 2017, 08:04:11 UTC
1 parent 3ea0d61
wscript
#! /usr/bin/env python
# encoding: utf-8
import shutil, os
def configure (conf):
# add "ibex/src/* " in the includes
conf.env.append_unique ("INCLUDES", [os.path.join(conf.srcnode.abspath(),"src/%s") % p for p in
"arithmetic bisector combinatorial contractor function numeric geometry parser set strategy symbolic system tools predicate integrate".split()])
conf.recurse("../plugins")
def build (bld):
INCDIR = "${PREFIX}/include/ibex"
bld.env['IBEX_SRC'] = bld.path.ant_glob ("**/*.(cpp|yc|l)")
bld.env['IBEX_HDR'] = bld.path.ant_glob ("**/ibex_*.h")
bld.env.IBEX_HDR.append ("ibex_Setting.h")
bld.env.settings = {}
bld.env.settings['_IBEX_RELEASE_']="\"%s\"" % bld.env['VERSION']
bld.env.settings['_IBEX_WITH_%s_' % bld.env['INTERVAL_LIB']]="1"
# add "__build__/src" in the includes, this is where ibex_Setting.h is stored
bld.env.append_unique("INCLUDES", os.path.join(bld.bldnode.abspath(),"src"))
# add "__build__/src/parser" in the includes, this is where parser.tab.hh is stored
bld.env.append_unique("INCLUDES", os.path.join(bld.bldnode.abspath(),"src/parser"))
bld.env['GLOBAL_DEPS'] = "gaol_objs gdtoa_objs ultim_objs filib_obj ampl_obj IBEX_DEPS"
bld.recurse("../plugins")
settings_string="// This file is automatically generated \n"
for key in bld.env.settings:
settings_string = settings_string+"#define "+key+" "+bld.env.settings[key]+'\n'
# generate settings header file
@bld.rule (
target = "ibex_Setting.h",
vars = ["INTERVAL_LIB"],
always = True,
name = "ibex_Setting_h_init"
)
def _(tsk):
tsk.outputs[0].write(settings_string)
# headers
@bld.rule (
target = "ibex.h",
name = "ibex_headers",
source = bld.env.IBEX_HDR,
install_path = INCDIR,
)
def _(tsk):
tsk.outputs[0].write (
"// This file is automatically generated\n"
+ "".join ('#include "%s"\n' % h.name for h in tsk.inputs))
bld.install_files (INCDIR, bld.env.IBEX_HDR)
bld.install_files (INCDIR, bld.path.ant_glob ("**/ibex_*.h_"))
# c++ compilation
tg_ibex = (bld.shlib if bld.env.ENABLE_SHARED else bld.stlib) (
target = "ibex",
use = bld.env.GLOBAL_DEPS,
source = bld.env.IBEX_SRC,
install_path = bld.env.LIBDIR,
)
if bld.env.WITH_JNI:
# *** TO FIX ***
# This task should go in the java plugin wscript. But I cannot
# ensure that ibex-java is properly linked with ibex (probably
# because "recurse" is called before the ibex "target" exists which
# makes the "use" flag below having no effect).
# I have to run twice "waf install" to make it works. Otherwise I
# get a UnsatisfiedLinkError with the java test program.
bld.shlib (
target = "../plugins/java/ibex-java",
source = "../plugins/java/src/ibex_Java.cpp",
use = "JAVA ibex",
install_path = bld.env.LIBDIR,
)
# pkg-config file
@bld.rule (
target = "ibex.pc",
vars = "PREFIX VERSION INCLUDES INCLUDES_IBEX_DEPS CXXFLAGS_IBEX_DEPS LIBPATH_IBEX_DEPS LIB_IBEX_DEPS".split(),
install_path = "${PREFIX}/share/pkgconfig",
)
def _ (tsk):
bld.env.include_pkgconfig=""
for p in bld.env.INCLUDES_IBEX_DEPS: # + bld.env.INCLUDES: --> useful?
if p not in [os.path.join (bld.env.PREFIX, "include")]:
bld.env.append_unique ("include_pkgconfig",p)
tsk.outputs[0].write("""
prefix=%s
includedir=${prefix}/include
libdir=${prefix}/lib
Name: ibex
Description: A C++ library for interval-based algorithm design
Version: %s
Cflags: -I${includedir} -I${includedir}/ibex %s %s
Libs: -L${libdir} %s -libex %s
""" % ( tsk.env.PREFIX, tsk.env.VERSION,
# extra CFLAGS
# TODO: maybe remove INCLUDES ?
" ".join(("-I%s" % p) for p in filter (os.path.isabs, tsk.env.include_pkgconfig)),
# FIXME: are we allowed to include arbitrary cflags (other that -I) ?
" ".join(tsk.env.CXXFLAGS_IBEX_DEPS),
# extra LIBPATH
" ".join(("-L%s" % p) for p in filter (os.path.isabs, tsk.env.LIBPATH_IBEX_DEPS)),
# extra LIB
" ".join(("-l%s" % l) for l in tsk.env.LIB_IBEX_DEPS),
))
Computing file changes ...