From cd3e62f10f4cd85fe74199349c96e7f2f27c4f60 Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Sun, 22 Sep 2013 09:28:35 -0700 Subject: Implement config.status --- README | 3 ++- attoconf/_version.py | 2 +- attoconf/core.py | 19 ++++++++++++++++--- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/README b/README index 2497de8..c76a0ce 100644 --- a/README +++ b/README @@ -1,7 +1,8 @@ -Attoconf is A small and sensible replacement for GNU autoconf. +Attoconf is a small and sensible replacement for GNU autoconf. Principles: * Assume most build environments are sane, and ignore the rest. +* In the face of ambiguity, refuse the temptation to guess. * Never automatically toggle features based on the build environment. * Written in python2 for easy editing and wide portability. * GPL, but this does not apply to the program being built. 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)) -- cgit v1.2.3-70-g09d2