summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2013-08-06 17:37:04 -0700
committerBen Longbons <b.r.longbons@gmail.com>2013-08-06 17:37:04 -0700
commit9fb3d2759f920bb6714ec6471a5c932720c6903a (patch)
tree9119ddcfdaa0f46dde05bb5bba0ee44c336c12bc
parent93215a82b4ebda6d322f75023cfea4cc7d4904d2 (diff)
downloadattobuild-9fb3d2759f920bb6714ec6471a5c932720c6903a.tar.gz
attobuild-9fb3d2759f920bb6714ec6471a5c932720c6903a.tar.bz2
attobuild-9fb3d2759f920bb6714ec6471a5c932720c6903a.tar.xz
attobuild-9fb3d2759f920bb6714ec6471a5c932720c6903a.zip
Write vars to makefile in order
-rw-r--r--attoconf/_version.py4
-rw-r--r--attoconf/classy.py9
-rw-r--r--attoconf/core.py5
-rw-r--r--attoconf/lib/arches.py6
-rw-r--r--attoconf/lib/config_hash.py1
-rw-r--r--attoconf/lib/install.py3
-rw-r--r--attoconf/lib/make.py13
7 files changed, 32 insertions, 9 deletions
diff --git a/attoconf/_version.py b/attoconf/_version.py
index 2f23d77..74a4f45 100644
--- a/attoconf/_version.py
+++ b/attoconf/_version.py
@@ -7,11 +7,11 @@ major = 0
# Incremented for releases with compatible API additions.
# This is the number that is usually incremented.
-minor = 3
+minor = 4
# Incremented if there is a bugfix release.
# Might not be contiguous.
-patch = 4
+patch = 0
# Reserved for distributors and forks.
# Contains arbitrary text, but no parentheses or newlines.
diff --git a/attoconf/classy.py b/attoconf/classy.py
index c7ecf5e..7a16372 100644
--- a/attoconf/classy.py
+++ b/attoconf/classy.py
@@ -42,16 +42,25 @@ class ClassyProject(Project):
super(ClassyProject, self).__init__(srcdir)
def jiggle(self):
+ self.order.append(None)
self.general()
+ self.order.append(None)
self.paths()
+ self.order.append(None)
self.arches()
+ self.order.append(None)
self.vars()
+ self.order.append(None)
self.features()
+ self.order.append(None)
self.packages()
+ self.order.append(None)
if 0:
self.tests()
+ self.order.append(None)
self.post()
+ self.order.append(None)
def general(self):
''' Registration hook for general options (usually unneeded).
diff --git a/attoconf/core.py b/attoconf/core.py
index 0fb780a..7efd91c 100644
--- a/attoconf/core.py
+++ b/attoconf/core.py
@@ -44,6 +44,7 @@ class Project(object):
'aliases',
'options',
'help',
+ 'order',
'checks',
)
def __init__(self, srcdir):
@@ -53,6 +54,7 @@ class Project(object):
self.aliases = {}
self.options = {}
self.help = Help()
+ self.order = []
self.checks = []
def add_help(self, text, hidden):
@@ -106,8 +108,9 @@ class Project(object):
init = type(init)
self.options[name] = Option(init=init, type=type, var=var)
if check is not None:
+ self.order.append(var)
self.checks.append(
- lambda bld: check(bld, **{help_var: bld.vars[var][0]}) )
+ lambda bld: check(bld, **{help_var: bld.vars[var][0]}))
if help_var is None:
help_var = var
diff --git a/attoconf/lib/arches.py b/attoconf/lib/arches.py
index 007f879..f2172b9 100644
--- a/attoconf/lib/arches.py
+++ b/attoconf/lib/arches.py
@@ -20,6 +20,9 @@ from __future__ import print_function, division, absolute_import
from ..classy import ClassyProject
from ..types import triple
+
+# TODO: see if there's a way to expose them sanely, without using Nones
+# (currently I never emit them: instead I pop the order)
def build(build, BUILD):
pass
@@ -47,10 +50,12 @@ class Arches2(ClassyProject):
type=triple, check=build,
help='configure for building on BUILD', hidden=False,
help_def='native')
+ self.order.pop()
self.add_option('--host', init=None,
type=triple, check=host,
help='cross-compile to build programs to run on HOST',
hidden=False, help_def='BUILD')
+ self.order.pop()
# TODO figure out the mro implications when I use this
class Arches3(Arches2):
@@ -61,3 +66,4 @@ class Arches3(Arches2):
type=triple, check=target,
help='configure for building compilers for TARGET',
hidden=False, help_def='HOST')
+ self.order.pop()
diff --git a/attoconf/lib/config_hash.py b/attoconf/lib/config_hash.py
index 5641558..42cdf21 100644
--- a/attoconf/lib/config_hash.py
+++ b/attoconf/lib/config_hash.py
@@ -44,5 +44,6 @@ class ConfigHash(ClassyProject):
__slots__ = ()
def post(self):
+ self.order.insert(0, 'CONFIG_HASH')
self.checks.append(add_config_hash)
super(ConfigHash, self).post()
diff --git a/attoconf/lib/install.py b/attoconf/lib/install.py
index 498b13b..2bbc7c7 100644
--- a/attoconf/lib/install.py
+++ b/attoconf/lib/install.py
@@ -121,7 +121,7 @@ def packagedatadir(build, DIR):
PACKAGE, prigin = build.vars['PACKAGE']
if origin != 'default' or prigin != 'default':
origin = 'derived'
- build.vars['DATADIR'] = (os.path.join(DATADIR, PACKAGE), origin)
+ build.vars['PACKAGEDATADIR'] = (os.path.join(DATADIR, PACKAGE), origin)
def infodir(build, DIR):
if DIR is None:
@@ -224,6 +224,7 @@ class Install(ClassyProject):
help='install architecture-dependent files in EPREFIX',
hidden=False,
var='EPREFIX', help_def='PREFIX')
+ self.order.append(None)
self.add_help('Fine tuning of the installation directories:',
hidden=False)
diff --git a/attoconf/lib/make.py b/attoconf/lib/make.py
index 816c444..7e2c9d3 100644
--- a/attoconf/lib/make.py
+++ b/attoconf/lib/make.py
@@ -41,13 +41,15 @@ class MakeHook(object):
with open(os.path.join(build.builddir, self.outfile), 'w') as out:
print('Generating a makefile ...')
out.write('# This part was generated by %s\n' % version_string)
- out.write('SRC_DIR = %s\n' % build.relative_source())
- out.write('\n')
- # TODO preserve *original* order?
- for var, (val, origin) in sorted(build.vars.iteritems()):
+ build.vars['SRC_DIR'] = (build.relative_source(), 'special')
+ for var in build.project.order:
+ if var is None:
+ out.write('\n')
+ continue
+ val, origin = build.vars[var]
out.write('%s = %s # %s\n' % (var, val, origin))
if self.infile is not None:
- out.write('\n# The rest was copied from %s\n' % self.infile)
+ out.write('# The rest was copied from %s\n' % self.infile)
infile = os.path.join(build.project.srcdir, self.infile)
with open(infile) as in_:
for line in in_:
@@ -76,4 +78,5 @@ class Make(ClassyProject):
def post(self):
super(Make, self).post()
+ self.order.insert(0, 'SRC_DIR')
self.checks.append(MakeHook(self.make_in, self.make_out))