diff options
-rwxr-xr-x | morph | 1 | ||||
-rw-r--r-- | morphlib/artifact.py | 2 | ||||
-rw-r--r-- | morphlib/builder2.py | 4 | ||||
-rw-r--r-- | morphlib/builder2_tests.py | 1 | ||||
-rw-r--r-- | morphlib/buildsystem.py | 2 | ||||
-rw-r--r-- | morphlib/morph2.py | 8 | ||||
-rw-r--r-- | morphlib/morph2_tests.py | 8 | ||||
-rwxr-xr-x | tests/build-system-autotools.script | 57 | ||||
-rw-r--r-- | tests/build-system-autotools.stdout | 8 | ||||
-rwxr-xr-x | tests/build-system-python-distutils.script | 61 | ||||
-rw-r--r-- | tests/build-system-python-distutils.stdout | 11 |
11 files changed, 153 insertions, 10 deletions
@@ -197,6 +197,7 @@ class Morph(cliapp.Application): artifacts = ar.resolve_artifacts(srcpool) for artifact in artifacts: artifact.cache_key = ckc.compute_key(artifact) + artifact.cache_id = ckc.get_cache_id(artifact) order = morphlib.buildorder.BuildOrder(artifacts) needed = [] diff --git a/morphlib/artifact.py b/morphlib/artifact.py index cea2f2f3..9be47d48 100644 --- a/morphlib/artifact.py +++ b/morphlib/artifact.py @@ -23,6 +23,7 @@ class Artifact(object): * ``source`` -- the source from which the artifact is built * ``name`` -- the name of the artifact * ``cache_key`` -- a cache key to uniquely identify the artifact + * ``cache_id`` -- a dict describing the components of the cache key * ``dependencies`` -- list of Artifacts that need to be built beforehand * ``dependents`` -- list of Artifacts that need this Artifact to be built @@ -34,6 +35,7 @@ class Artifact(object): def __init__(self, source, name): self.source = source self.name = name + self.cache_id = None self.cache_key = None self.dependencies = [] self.dependents = [] diff --git a/morphlib/builder2.py b/morphlib/builder2.py index 5dd4b994..b8c51539 100644 --- a/morphlib/builder2.py +++ b/morphlib/builder2.py @@ -54,6 +54,8 @@ class BuilderBase(object): 'original_ref': self.artifact.source.original_ref, 'sha1': self.artifact.source.sha1, 'morphology': self.artifact.source.filename, + 'cache-key': self.artifact.cache_key, + 'cache-id': self.artifact.cache_id, } return meta @@ -82,7 +84,7 @@ class BuilderBase(object): # Unit tests use StringIO, which in Python 2.6 isn't usable with # the "with" statement. So we don't do it with "with". f = self._open(filename, 'w') - f.write(json.dumps(meta)) + f.write(json.dumps(meta, indent=4, sort_keys=True)) f.close() def new_artifact(self, artifact_name): diff --git a/morphlib/builder2_tests.py b/morphlib/builder2_tests.py index 53fd6711..44608c75 100644 --- a/morphlib/builder2_tests.py +++ b/morphlib/builder2_tests.py @@ -55,6 +55,7 @@ class FakeArtifact(object): self.name = name self.source = FakeSource() self.cache_key = 'blahblah' + self.cache_id = {} class FakeBuildEnv(object): diff --git a/morphlib/buildsystem.py b/morphlib/buildsystem.py index 8847ab4c..ab12e730 100644 --- a/morphlib/buildsystem.py +++ b/morphlib/buildsystem.py @@ -139,7 +139,7 @@ class PythonDistutilsBuildSystem(BuildSystem): self.test_commands = [ ] self.install_commands = [ - 'python setup.py install --root "$DESTDIR"', + 'python setup.py install --prefix "$PREFIX" --root "$DESTDIR"', ] def used_by_project(self, exists): diff --git a/morphlib/morph2.py b/morphlib/morph2.py index b5517f46..b825f8cf 100644 --- a/morphlib/morph2.py +++ b/morphlib/morph2.py @@ -27,10 +27,10 @@ class Morphology(object): ''' static_defaults = [ - ('configure-commands', []), - ('build-commands', []), - ('test-commands', []), - ('install-commands', []), + ('configure-commands', None), + ('build-commands', None), + ('test-commands', None), + ('install-commands', None), ('chunks', {}), ('sources', []), ('strata', []), diff --git a/morphlib/morph2_tests.py b/morphlib/morph2_tests.py index 6cda67df..a862a3a8 100644 --- a/morphlib/morph2_tests.py +++ b/morphlib/morph2_tests.py @@ -33,10 +33,10 @@ class MorphologyTests(unittest.TestCase): self.assertEqual(m['name'], 'foo') self.assertEqual(m['kind'], 'chunk') self.assertEqual(m['build-system'], 'manual') - self.assertEqual(m['configure-commands'], []) - self.assertEqual(m['build-commands'], []) - self.assertEqual(m['test-commands'], []) - self.assertEqual(m['install-commands'], []) + self.assertEqual(m['configure-commands'], None) + self.assertEqual(m['build-commands'], None) + self.assertEqual(m['test-commands'], None) + self.assertEqual(m['install-commands'], None) self.assertEqual(m['max-jobs'], None) self.assertEqual(m['chunks'], {}) diff --git a/tests/build-system-autotools.script b/tests/build-system-autotools.script new file mode 100755 index 00000000..edee7adb --- /dev/null +++ b/tests/build-system-autotools.script @@ -0,0 +1,57 @@ +#!/bin/sh +# +# Convert the hello-chunk project to something autotools-like, then +# build it. +# +# Copyright (C) 2011, 2012 Codethink Limited +# +# This program 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; version 2 of the License. +# +# This program 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 this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + +set -eu + +chunkrepo="$DATADIR/chunk-repo" +cd "$chunkrepo" + +git checkout --quiet farrokh + +cat <<'EOF' >Makefile +all: hello + +install: all + install -d "$(DESTDIR)/etc" + install -d "$(DESTDIR)/bin" + install hello "$(DESTDIR)/bin/hello" +EOF +git add Makefile + +cat <<EOF > hello.morph +{ + "name": "hello", + "kind": "chunk", + "build-system": "autotools", + "configure-commands": [] +} +EOF +git add hello.morph +git commit --quiet -m "Convert hello to an autotools project" + +"$SRCDIR/scripts/test-morph" build chunk-repo farrokh hello.morph + +for chunk in "$DATADIR/cache/"*.chunk.* +do + echo "$chunk:" | sed 's/[^.]*//' + tar -tf "$chunk" | LC_ALL=C sort | sed '/^\.\/./s:^\./::' + echo +done diff --git a/tests/build-system-autotools.stdout b/tests/build-system-autotools.stdout new file mode 100644 index 00000000..8077cac2 --- /dev/null +++ b/tests/build-system-autotools.stdout @@ -0,0 +1,8 @@ +.chunk.hello: +./ +baserock/ +baserock/hello.meta +bin/ +bin/hello +etc/ + diff --git a/tests/build-system-python-distutils.script b/tests/build-system-python-distutils.script new file mode 100755 index 00000000..2c7c7df6 --- /dev/null +++ b/tests/build-system-python-distutils.script @@ -0,0 +1,61 @@ +#!/bin/sh +# +# Convert the hello-chunk project to python with distutils +# +# Copyright (C) 2011, 2012 Codethink Limited +# +# This program 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; version 2 of the License. +# +# This program 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 this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + +set -eu + +chunkrepo="$DATADIR/chunk-repo" +cd "$chunkrepo" + +git checkout --quiet farrokh + +git rm --quiet hello.c +cat <<EOF >hello +#!/usr/bin/python +print "hello, world" +EOF +git add hello + +cat <<EOF >setup.py +#!/usr/bin/python +from distutils.core import setup +setup(name='hello', + scripts=['hello']) +EOF +git add setup.py + +cat <<EOF >hello.morph +{ + "name": "hello", + "kind": "chunk", + "build-system": "python-distutils" +} +EOF +git add hello.morph + +git commit --quiet -m 'convert hello into a python project' + +"$SRCDIR/scripts/test-morph" build --prefix= chunk-repo farrokh hello.morph + +for chunk in "$DATADIR/cache/"*.chunk.* +do + echo "$chunk:" | sed 's/[^.]*//' + tar -tf "$chunk" | LC_ALL=C sort | sed '/^\.\/./s:^\./::' + echo +done diff --git a/tests/build-system-python-distutils.stdout b/tests/build-system-python-distutils.stdout new file mode 100644 index 00000000..b78b608f --- /dev/null +++ b/tests/build-system-python-distutils.stdout @@ -0,0 +1,11 @@ +.chunk.hello: +./ +baserock/ +baserock/hello.meta +bin/ +bin/hello +lib/ +lib/python2.7/ +lib/python2.7/site-packages/ +lib/python2.7/site-packages/hello-0.0.0-py2.7.egg-info + |