diff options
author | Ben Longbons <b.r.longbons@gmail.com> | 2013-08-06 16:29:24 -0700 |
---|---|---|
committer | Ben Longbons <b.r.longbons@gmail.com> | 2013-08-06 16:31:11 -0700 |
commit | 93215a82b4ebda6d322f75023cfea4cc7d4904d2 (patch) | |
tree | e8157186ca7026807fb602921b96b793a16314a0 | |
parent | 7b5f69de3f7b52b718507fe16c2560901e48a70c (diff) | |
download | attobuild-93215a82b4ebda6d322f75023cfea4cc7d4904d2.tar.gz attobuild-93215a82b4ebda6d322f75023cfea4cc7d4904d2.tar.bz2 attobuild-93215a82b4ebda6d322f75023cfea4cc7d4904d2.tar.xz attobuild-93215a82b4ebda6d322f75023cfea4cc7d4904d2.zip |
Add config hash
-rw-r--r-- | attoconf/_version.py | 2 | ||||
-rw-r--r-- | attoconf/lib/arches.py | 4 | ||||
-rw-r--r-- | attoconf/lib/config_hash.py | 48 | ||||
-rw-r--r-- | attoconf/lib/install.py | 40 | ||||
-rwxr-xr-x | demo-project/configure | 3 |
5 files changed, 73 insertions, 24 deletions
diff --git a/attoconf/_version.py b/attoconf/_version.py index 41d536a..2f23d77 100644 --- a/attoconf/_version.py +++ b/attoconf/_version.py @@ -11,7 +11,7 @@ minor = 3 # Incremented if there is a bugfix release. # Might not be contiguous. -patch = 3 +patch = 4 # Reserved for distributors and forks. # Contains arbitrary text, but no parentheses or newlines. diff --git a/attoconf/lib/arches.py b/attoconf/lib/arches.py index 595b396..007f879 100644 --- a/attoconf/lib/arches.py +++ b/attoconf/lib/arches.py @@ -27,14 +27,14 @@ def host(build, HOST): if HOST is None: BUILD, origin = build.vars['BUILD'] if origin != 'default': - origin = 'derived from BUILD' + origin = 'derived' build.vars['HOST'] = (BUILD, origin) def target(build, TARGET): if TARGET is None: HOST, origin = build.vars['HOST'] if origin != 'default': - origin = 'derived from HOST' + origin = 'derived' build.vars['TARGET'] = (HOST, origin) class Arches2(ClassyProject): diff --git a/attoconf/lib/config_hash.py b/attoconf/lib/config_hash.py new file mode 100644 index 0000000..5641558 --- /dev/null +++ b/attoconf/lib/config_hash.py @@ -0,0 +1,48 @@ +# Copyright 2013 Ben Longbons <b.r.longbons@gmail.com> +# +# This file is part of attoconf. +# +# attoconf is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# attoconf is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with attoconf. If not, see <http://www.gnu.org/licenses/>. + +from __future__ import print_function, division, absolute_import + +from hashlib import md5 +import os + +from ..classy import ClassyProject + + +def calc_hash(build): + hash = md5() + for var, (val, origin), in sorted(build.vars.iteritems()): + # origin is not included in the hash + hash.update('%s = %s\n' % (var, val)) + return hash.hexdigest() + + +def add_config_hash(build): + print('Generating a hash of config options ...') + build.vars['CONFIG_HASH'] = (calc_hash(build), 'special') + + +class ConfigHash(ClassyProject): + ''' Post hook add the build hash. + + This should be run before any other post hooks. + ''' + __slots__ = () + + def post(self): + self.checks.append(add_config_hash) + super(ConfigHash, self).post() diff --git a/attoconf/lib/install.py b/attoconf/lib/install.py index a807666..498b13b 100644 --- a/attoconf/lib/install.py +++ b/attoconf/lib/install.py @@ -39,63 +39,63 @@ def exec_prefix(build, EPREFIX): if EPREFIX is None: PREFIX, origin = build.vars['PREFIX'] if origin != 'default': - origin = 'derived from PREFIX' + origin = 'derived' build.vars['EPREFIX'] = (PREFIX, origin) def bindir(build, DIR): if DIR is None: EPREFIX, origin = build.vars['EPREFIX'] if origin != 'default': - origin = 'derived from EPREFIX' + origin = 'derived' build.vars['BINDIR'] = (os.path.join(EPREFIX, 'bin'), origin) def sbindir(build, DIR): if DIR is None: EPREFIX, origin = build.vars['EPREFIX'] if origin != 'default': - origin = 'derived from EPREFIX' + origin = 'derived' build.vars['SBINDIR'] = (os.path.join(EPREFIX, 'sbin'), origin) def libexecdir(build, DIR): if DIR is None: EPREFIX, origin = build.vars['EPREFIX'] if origin != 'default': - origin = 'derived from EPREFIX' + origin = 'derived' build.vars['LIBEXECDIR'] = (os.path.join(EPREFIX, 'libexec'), origin) def sysconfdir(build, DIR): if DIR is None: PREFIX, origin = build.vars['PREFIX'] if origin != 'default': - origin = 'derived from PREFIX' + origin = 'derived' build.vars['SYSCONFDIR'] = (os.path.join(PREFIX, 'etc'), origin) def sharedstatedir(build, DIR): if DIR is None: PREFIX, origin = build.vars['PREFIX'] if origin != 'default': - origin = 'derived from PREFIX' + origin = 'derived' build.vars['SHAREDSTATEDIR'] = (os.path.join(PREFIX, 'com'), origin) def localstatedir(build, DIR): if DIR is None: PREFIX, origin = build.vars['PREFIX'] if origin != 'default': - origin = 'derived from PREFIX' + origin = 'derived' build.vars['LOCALSTATEDIR'] = (os.path.join(PREFIX, 'var'), origin) def libdir(build, DIR): if DIR is None: EPREFIX, origin = build.vars['EPREFIX'] if origin != 'default': - origin = 'derived from EPREFIX' + origin = 'derived' build.vars['LIBDIR'] = (os.path.join(EPREFIX, 'lib'), origin) def includedir(build, DIR): if DIR is None: PREFIX, origin = build.vars['PREFIX'] if origin != 'default': - origin = 'derived from PREFIX' + origin = 'derived' build.vars['INCLUDEDIR'] = (os.path.join(PREFIX, 'include'), origin) def oldincludedir(build, DIR): @@ -105,14 +105,14 @@ def datarootdir(build, DIR): if DIR is None: PREFIX, origin = build.vars['PREFIX'] if origin != 'default': - origin = 'derived from PREFIX' + origin = 'derived' build.vars['DATAROOTDIR'] = (os.path.join(PREFIX, 'share'), origin) def datadir(build, DIR): if DIR is None: DATAROOTDIR, origin = build.vars['DATAROOTDIR'] if origin != 'default': - origin = 'derived from DATAROOTDIR' + origin = 'derived' build.vars['DATADIR'] = (DATAROOTDIR, origin) def packagedatadir(build, DIR): @@ -120,28 +120,28 @@ def packagedatadir(build, DIR): DATADIR, origin = build.vars['DATADIR'] PACKAGE, prigin = build.vars['PACKAGE'] if origin != 'default' or prigin != 'default': - origin = 'derived from DATADIR and PACKAGE' + origin = 'derived' build.vars['DATADIR'] = (os.path.join(DATADIR, PACKAGE), origin) def infodir(build, DIR): if DIR is None: DATAROOTDIR, origin = build.vars['DATAROOTDIR'] if origin != 'default': - origin = 'derived from DATAROOTDIR' + origin = 'derived' build.vars['INFODIR'] = (os.path.join(DATAROOTDIR, 'info'), origin) def localedir(build, DIR): if DIR is None: DATAROOTDIR, origin = build.vars['DATAROOTDIR'] if origin != 'default': - origin = 'derived from DATAROOTDIR' + origin = 'derived' build.vars['LOCALEDIR'] = (os.path.join(DATAROOTDIR, 'locale'), origin) def mandir(build, DIR): if DIR is None: DATAROOTDIR, origin = build.vars['DATAROOTDIR'] if origin != 'default': - origin = 'derived from DATAROOTDIR' + origin = 'derived' build.vars['MANDIR'] = (os.path.join(DATAROOTDIR, 'man'), origin) def docdir(build, DIR): @@ -149,35 +149,35 @@ def docdir(build, DIR): DATAROOTDIR, origin = build.vars['DATAROOTDIR'] PACKAGE, origin2 = build.vars['PACKAGE'] if origin != 'default' or origin2 != 'default': - origin = 'derived from DATAROOTDIR and PACKAGE' + origin = 'derived' build.vars['DOCDIR'] = (os.path.join(DATAROOTDIR, 'doc', PACKAGE), origin) def htmldir(build, DIR): if DIR is None: DOCDIR, origin = build.vars['DOCDIR'] if origin != 'default': - origin = 'derived from DOCDIR' + origin = 'derived' build.vars['HTMLDIR'] = (DOCDIR, origin) def dvidir(build, DIR): if DIR is None: DOCDIR, origin = build.vars['DOCDIR'] if origin != 'default': - origin = 'derived from DOCDIR' + origin = 'derived' build.vars['DVIDIR'] = (DOCDIR, origin) def pdfdir(build, DIR): if DIR is None: DOCDIR, origin = build.vars['DOCDIR'] if origin != 'default': - origin = 'derived from DOCDIR' + origin = 'derived' build.vars['PDFDIR'] = (DOCDIR, origin) def psdir(build, DIR): if DIR is None: DOCDIR, origin = build.vars['DOCDIR'] if origin != 'default': - origin = 'derived from DOCDIR' + origin = 'derived' build.vars['PSDIR'] = (DOCDIR, origin) diff --git a/demo-project/configure b/demo-project/configure index a3e49ee..c26e557 100755 --- a/demo-project/configure +++ b/demo-project/configure @@ -28,10 +28,11 @@ require_version(0, 2) from attoconf.classy import add_slots from attoconf.lib.c import C from attoconf.lib.install import Install +from attoconf.lib.config_hash import ConfigHash from attoconf.lib.make import Make @add_slots -class Configuration(C, Install, Make): +class Configuration(C, Install, ConfigHash, Make): # usually you'll only have vars, features, and packages # the rest should only be inherited def __init__(self, srcdir): |