summaryrefslogtreecommitdiff
path: root/attoconf
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2013-09-22 09:28:35 -0700
committerBen Longbons <b.r.longbons@gmail.com>2013-09-22 09:28:35 -0700
commitcd3e62f10f4cd85fe74199349c96e7f2f27c4f60 (patch)
treecea84629c2e012d26decf149e5044f3c27232383 /attoconf
parent74db20592869396232ca35456f4e2c63c7d937b3 (diff)
downloadattobuild-cd3e62f10f4cd85fe74199349c96e7f2f27c4f60.tar.gz
attobuild-cd3e62f10f4cd85fe74199349c96e7f2f27c4f60.tar.bz2
attobuild-cd3e62f10f4cd85fe74199349c96e7f2f27c4f60.tar.xz
attobuild-cd3e62f10f4cd85fe74199349c96e7f2f27c4f60.zip
Implement config.status
Diffstat (limited to 'attoconf')
-rw-r--r--attoconf/_version.py2
-rw-r--r--attoconf/core.py19
2 files changed, 17 insertions, 4 deletions
diff --git a/attoconf/_version.py b/attoconf/_version.py
index 68a4244..76c1c3d 100644
--- a/attoconf/_version.py
+++ b/attoconf/_version.py
@@ -11,7 +11,7 @@ minor = 6
# Incremented if there is a bugfix release.
# Might not be contiguous.
-patch = 0
+patch = 1
# Reserved for distributors and forks.
# Contains arbitrary text, but no parentheses or newlines.
diff --git a/attoconf/core.py b/attoconf/core.py
index 7efd91c..624d578 100644
--- a/attoconf/core.py
+++ b/attoconf/core.py
@@ -146,6 +146,7 @@ class Build(object):
'builddir',
'project',
'vars',
+ '_seen_args',
)
def __init__(self, project, builddir):
''' A Build is initially constructed from a project and a build dir.
@@ -155,6 +156,7 @@ class Build(object):
self.vars = {o.var: (o.init, 'default')
for o in project.options.itervalues()
if o.var is not None}
+ self._seen_args = []
def apply_arg(self, arg):
''' Parse a single argument, expanding aliases.
@@ -174,6 +176,7 @@ class Build(object):
raise ArgumentError('Unknown option %s' % arg)
else:
raise ArgumentError('Unknown environment variable %s' % arg)
+ self._seen_args.append(arg)
k, a = arg.split('=', 1)
opt = self.project.options.get(k)
@@ -187,6 +190,18 @@ class Build(object):
'''
for check in self.project.checks:
check(self)
+ status_file = os.path.join(self.builddir, 'config.status')
+ # open fd to control +x mode
+ status_fd = os.open(status_file, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0777)
+ with os.fdopen(status_fd, 'w') as status:
+ status.write('#!%s\n' % sys.executable)
+ status.write('import os\n')
+ status.write('import sys\n')
+ status.write('old_build_dir = os.path.dirname(sys.argv[0])\n')
+ status.write('configure = os.path.join(old_build_dir, %r, "configure")\n'
+ % self.relative_source())
+ status.write('os.execvp(configure, [configure] + %r)\n'
+ % self._seen_args)
def configure(self, args, env):
''' First apply variables from the environment,
@@ -210,9 +225,7 @@ class Build(object):
'''
srcdir = self.project.srcdir
builddir = self.builddir
- if os.path.isabs(srcdir):
- return srcdir
- if os.path.isabs(builddir):
+ if os.path.isabs(srcdir) or os.path.isabs(builddir):
return os.path.realpath(srcdir)
return os.path.relpath(os.path.realpath(srcdir),
os.path.realpath(builddir))