summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2014-07-16 17:39:52 -0700
committerBen Longbons <b.r.longbons@gmail.com>2014-07-16 18:10:44 -0700
commitd6052fda42c8d59486bd95b025b6d6b436e00424 (patch)
treef77b6686e8f9c36c5ffc6d56f56cc47dc31f09a6
parent0f0e6300534b8b847f139c04b9e6ed1cc1100d90 (diff)
downloadattobuild-d6052fda42c8d59486bd95b025b6d6b436e00424.tar.gz
attobuild-d6052fda42c8d59486bd95b025b6d6b436e00424.tar.bz2
attobuild-d6052fda42c8d59486bd95b025b6d6b436e00424.tar.xz
attobuild-d6052fda42c8d59486bd95b025b6d6b436e00424.zip
Remove possibility of custom vars
Retained temporary backward-compatibility vars until 1.0
-rw-r--r--attoconf/_version.py2
-rw-r--r--attoconf/core.py20
-rw-r--r--attoconf/lib/c.py44
-rw-r--r--attoconf/lib/install.py6
4 files changed, 37 insertions, 35 deletions
diff --git a/attoconf/_version.py b/attoconf/_version.py
index 4199a0e..28024a6 100644
--- a/attoconf/_version.py
+++ b/attoconf/_version.py
@@ -11,7 +11,7 @@ minor = 8
# Incremented if there is a bugfix release.
# Might not be contiguous.
-patch = 5
+patch = 6
# Reserved for distributors and forks.
# Contains arbitrary text, but no parentheses or newlines.
diff --git a/attoconf/core.py b/attoconf/core.py
index b5cb008..bb9d2ba 100644
--- a/attoconf/core.py
+++ b/attoconf/core.py
@@ -24,7 +24,7 @@ import sys
from .help import Help
# Nothing to see here. Move along.
-Option = namedtuple('Option', ['type', 'init', 'var'])
+Option = namedtuple('Option', ['type', 'init'])
class ArgumentError(Exception): pass
def as_var(name):
@@ -78,7 +78,7 @@ class Project(object):
self.help.add_option(key, help, hidden)
def add_option(self, name, init, type, check,
- help, hidden, var=None,
+ help, hidden,
help_var=None, help_def=None):
''' Add an actual option.
@@ -96,17 +96,16 @@ class Project(object):
'''
if name in self.options:
raise KeyError(name)
+ var = as_var(name)
if check is not None:
assert type.__module__ == 'attoconf.types'
- if var is None:
- var = as_var(name)
else:
# used by some tests ... should this be fixed there instead?
if help_var is None:
- help_var = as_var(name)
+ help_var = var
if init is not None:
init = type(init)
- self.options[name] = Option(init=init, type=type, var=var)
+ self.options[name] = Option(init=init, type=type)
if check is not None:
self.order.append(var)
self.checks.append(
@@ -153,9 +152,8 @@ class Build(object):
'''
self.project = project
self.builddir = trim_trailing_slashes(builddir)
- self.vars = {o.var: o.init
- for o in project.options.itervalues()
- if o.var is not None}
+ self.vars = {as_var(k): o.init
+ for (k, o) in project.options.iteritems()}
self._seen_args = OrderedDict()
def apply_arg(self, arg):
@@ -184,7 +182,7 @@ class Build(object):
opt = self.project.options.get(k)
if opt is None:
raise sys.exit('Unknown option %s' % k)
- self.vars[opt.var] = opt.type(a)
+ self.vars[as_var(k)] = opt.type(a)
def finish(self):
''' With the current set of variables, run all the checks
@@ -218,7 +216,7 @@ class Build(object):
if val is not None:
self._seen_args[k] = val
opt = self.project.options[k]
- self.vars[opt.var] = opt.type(val)
+ self.vars[as_var(k)] = opt.type(val)
for arg in args:
self.apply_arg(arg)
diff --git a/attoconf/lib/c.py b/attoconf/lib/c.py
index 062e695..3b6f05f 100644
--- a/attoconf/lib/c.py
+++ b/attoconf/lib/c.py
@@ -75,17 +75,17 @@ def try_compile_c(build, body, CFLAGS=[], CPPFLAGS=[]):
if status:
raise TestError(error)
-def try_compile_link_c(build, body, CFLAGS=[], CPPFLAGS=[], LDFLAGS=[], LDLIBS=[]):
+def try_compile_link_c(build, body, CFLAGS=[], CPPFLAGS=[], LDFLAGS=[], LIBS=[]):
CC = build.vars['CC']
CFLAGS = build.vars['CFLAGS'] + CFLAGS
CPPFLAGS = build.vars['CPPFLAGS'] + CPPFLAGS
LDFLAGS = build.vars['LDFLAGS'] + LDFLAGS
- LDLIBS = build.vars['LDLIBS'] + LDLIBS
+ LIBS = build.vars['LIBS'] + LIBS
in_ = 'atto-test.c'
ins = [in_]
out = 'atto-test'
- args = CC + CFLAGS + CPPFLAGS + LDFLAGS + ins + LDLIBS + ['-o', out]
+ args = CC + CFLAGS + CPPFLAGS + LDFLAGS + ins + LIBS + ['-o', out]
with TempFile(in_, body), TempFile(out, None):
status, error = do_exec(build, args)
if status:
@@ -104,41 +104,41 @@ def try_compile_cxx(build, body, CXXFLAGS=[], CPPFLAGS=[]):
if status:
raise TestError(error)
-def try_compile_link_cxx(build, body, CXXFLAGS=[], CPPFLAGS=[], LDFLAGS=[], LDLIBS=[]):
+def try_compile_link_cxx(build, body, CXXFLAGS=[], CPPFLAGS=[], LDFLAGS=[], LIBS=[]):
CXX = build.vars['CXX']
CXXFLAGS = build.vars['CXXFLAGS'] + CXXFLAGS
CPPFLAGS = build.vars['CPPFLAGS'] + CPPFLAGS
LDFLAGS = build.vars['LDFLAGS'] + LDFLAGS
- LDLIBS = build.vars['LDLIBS'] + LDLIBS
+ LIBS = build.vars['LIBS'] + LIBS
in_ = 'atto-test.cxx'
ins = [in_]
out = 'atto-test'
- args = CXX + CXXFLAGS + CPPFLAGS + LDFLAGS + ins + LDLIBS + ['-o', out]
+ args = CXX + CXXFLAGS + CPPFLAGS + LDFLAGS + ins + LIBS + ['-o', out]
with TempFile(in_, body), TempFile(out, None):
status, error = do_exec(build, args)
if status:
raise TestError(error)
if 0:
- def try_linkonly_c(build, ins, LDFLAGS=[], LDLIBS=[]):
+ def try_linkonly_c(build, ins, LDFLAGS=[], LIBS=[]):
CC = build.vars['CC']
LDFLAGS = build.vars['LDFLAGS'] + LDFLAGS
- LDLIBS = build.vars['LDLIBS'] + LDLIBS
+ LIBS = build.vars['LIBS'] + LIBS
out = 'atto-test'
- args = CC + LDFLAGS + ins + LDLIBS + ['-o', out]
+ args = CC + LDFLAGS + ins + LIBS + ['-o', out]
with TempFile(out, None):
status, error = do_exec(build, args)
if status:
raise TestError(error)
-def try_compile_link2_c(build, body, CFLAGS=[], CPPFLAGS=[], LDFLAGS=[], LDLIBS=[]):
+def try_compile_link2_c(build, body, CFLAGS=[], CPPFLAGS=[], LDFLAGS=[], LIBS=[]):
CC = build.vars['CC']
CFLAGS = build.vars['CFLAGS'] + CFLAGS
CPPFLAGS = build.vars['CPPFLAGS'] + CPPFLAGS
LDFLAGS = build.vars['LDFLAGS'] + LDFLAGS
- LDLIBS = build.vars['LDLIBS'] + LDLIBS
+ LIBS = build.vars['LIBS'] + LIBS
in_ = 'atto-test.c'
ins = [in_]
mid = 'atto-test.o'
@@ -146,7 +146,7 @@ def try_compile_link2_c(build, body, CFLAGS=[], CPPFLAGS=[], LDFLAGS=[], LDLIBS=
out = 'atto-test'
args1 = CC + CFLAGS + CPPFLAGS + ['-c', '-o', mid, in_]
- args2 = CC + LDFLAGS + mids + LDLIBS + ['-o', out]
+ args2 = CC + LDFLAGS + mids + LIBS + ['-o', out]
with TempFile(mid, None):
with TempFile(in_, body):
status, error = do_exec(build, args1)
@@ -159,24 +159,24 @@ def try_compile_link2_c(build, body, CFLAGS=[], CPPFLAGS=[], LDFLAGS=[], LDLIBS=
raise TestError(error)
if 0:
- def try_linkonly_cxx(build, ins, LDFLAGS=[], LDLIBS=[]):
+ def try_linkonly_cxx(build, ins, LDFLAGS=[], LIBS=[]):
CXX = build.vars['CXX']
LDFLAGS = build.vars['LDFLAGS'] + LDFLAGS
- LDLIBS = build.vars['LDLIBS'] + LDLIBS
+ LIBS = build.vars['LIBS'] + LIBS
out = 'atto-test'
- args = CXX + LDFLAGS + ins + LDLIBS + ['-o', out]
+ args = CXX + LDFLAGS + ins + LIBS + ['-o', out]
with TempFile(out, None):
status, error = do_exec(build, args)
if status:
raise TestError(error)
-def try_compile_link2_cxx(build, body, CXXFLAGS=[], CPPFLAGS=[], LDFLAGS=[], LDLIBS=[]):
+def try_compile_link2_cxx(build, body, CXXFLAGS=[], CPPFLAGS=[], LDFLAGS=[], LIBS=[]):
CXX = build.vars['CXX']
CXXFLAGS = build.vars['CXXFLAGS'] + CXXFLAGS
CPPFLAGS = build.vars['CPPFLAGS'] + CPPFLAGS
LDFLAGS = build.vars['LDFLAGS'] + LDFLAGS
- LDLIBS = build.vars['LDLIBS'] + LDLIBS
+ LIBS = build.vars['LIBS'] + LIBS
in_ = 'atto-test.cxx'
ins = [in_]
mid = 'atto-test.o'
@@ -184,7 +184,7 @@ def try_compile_link2_cxx(build, body, CXXFLAGS=[], CPPFLAGS=[], LDFLAGS=[], LDL
out = 'atto-test'
args1 = CXX + CXXFLAGS + CPPFLAGS + ['-c', '-o', mid, in_]
- args2 = CXX + LDFLAGS + mids + LDLIBS + ['-o', out]
+ args2 = CXX + LDFLAGS + mids + LIBS + ['-o', out]
with TempFile(mid, None):
with TempFile(in_, body):
status, error = do_exec(build, args1)
@@ -200,8 +200,9 @@ def try_compile_link2_cxx(build, body, CXXFLAGS=[], CPPFLAGS=[], LDFLAGS=[], LDL
def ldflags(build, LDFLAGS):
pass
-def libs(build, LDLIBS):
- pass
+def libs(build, LIBS):
+ # compatibility
+ build.vars['LDLIBS'] = LIBS
def cppflags(build, CPPFLAGS):
pass
@@ -233,7 +234,8 @@ class Link(Arches2):
self.add_option('LIBS', init=[],
type=ShellList, check=libs,
help='libraries to pass to the linker, e.g. -l<library>',
- hidden=False, var='LDLIBS')
+ hidden=False)
+ self.order.append('LDLIBS')
class Preprocess(Arches2):
__slots__ = ()
diff --git a/attoconf/lib/install.py b/attoconf/lib/install.py
index b3eb989..1a55c29 100644
--- a/attoconf/lib/install.py
+++ b/attoconf/lib/install.py
@@ -35,7 +35,8 @@ def prefix(build, PREFIX):
def exec_prefix(build, EPREFIX):
if EPREFIX is None:
PREFIX = build.vars['PREFIX']
- build.vars['EPREFIX'] = PREFIX
+ build.vars['EXEC_PREFIX'] = PREFIX
+ build.vars['EPREFIX'] = build.vars['EXEC_PREFIX']
def bindir(build, DIR):
if DIR is None:
@@ -182,7 +183,8 @@ class Install(ClassyProject):
type=filepath, check=exec_prefix,
help='install architecture-dependent files in EPREFIX',
hidden=False,
- var='EPREFIX', help_def='PREFIX')
+ help_var='EPREFIX', help_def='PREFIX')
+ self.order.append('EPREFIX')
self.order.append(None)
self.add_help('Fine tuning of the installation directories:',