diff options
author | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2012-04-17 11:43:52 +0100 |
---|---|---|
committer | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2012-04-18 18:29:25 +0100 |
commit | 478dde1a3c7ca41f5ff1478706ffc76e7087527d (patch) | |
tree | 32f9ff334eeedc9752f54c19982083fcbf2b3567 /morph | |
parent | 4bb6b91088b0a0f52491deb30a020080a6cde937 (diff) | |
download | morph-478dde1a3c7ca41f5ff1478706ffc76e7087527d.tar.gz |
Add preliminary build2 subcommand
Diffstat (limited to 'morph')
-rwxr-xr-x | morph | 72 |
1 files changed, 70 insertions, 2 deletions
@@ -21,6 +21,7 @@ import collections import json import logging import os +import tempfile import morphlib from morphlib import buildworker @@ -191,8 +192,7 @@ class Morph(cliapp.Application): return pool - - def cmd_build(self, args): + def cmd_build_old(self, args): '''Build a binary from a morphology. Command line arguments are the repository, git tree-ish reference, @@ -236,6 +236,74 @@ class Morph(cliapp.Application): tempdir.remove() + def cmd_build(self, args): + '''Build a binary from a morphology. + + Command line arguments are the repository, git tree-ish reference, + and morphology filename. Morph takes care of building all dependencies + before building the morphology. All generated binaries are put into the + cache. + + (The triplet of command line arguments may be repeated as many + times as necessary.) + + ''' + + logging.debug('cmd_build starting') + + cachedir = self.settings['cachedir'] + if not os.path.exists(cachedir): + os.mkdir(cachedir) + + build_env = morphlib.buildenvironment.BuildEnvironment(self.settings) + ckc = morphlib.cachekeycomputer.CacheKeyComputer(build_env) + lac = morphlib.localartifactcache.LocalArtifactCache(cachedir) + lrc = morphlib.localrepocache.LocalRepoCache( + cachedir, + self.settings['git-base-url'], + bundle_base_url=self.settings['bundle-server']) + + for repo_name, ref, filename in self._itertriplets(args): + logging.debug('cmd_build: %s %s %s' % (repo_name, ref, filename)) + srcpool = self._create_source_pool(lrc, repo_name, ref, filename) + ar = morphlib.artifactresolver.ArtifactResolver(ckc) + artifacts = ar.resolve_artifacts(srcpool) + order = morphlib.buildorder.BuildOrder(artifacts) + + needed = [] + for group in order.groups: + for artifact in group: + if not lac.has(artifact): + needed.append(artifact) + + for artifact in needed: + repo = lrc.cache_repo(repo_name) + repo.update() + + if self.settings['bootstrap']: + staging_root = '/' + else: + staging_root = tempfile.mkdtemp() + staging_area = morphlib.stagingarea.StagingArea(staging_root) + + builder = morphlib.builder2.Builder(staging_area, lac, + build_env, + self.settings['max-jobs']) + for group in order.groups: + for artifact in group: + if artifact in needed: + builder.build_and_cache(artifact) + # install chunks only + chunk_artifacts = [x + for x in group + if x.source.morphology['kind'] == 'chunk'] + for artifact in chunk_artifacts: + handle = lac.get(artifact) + staging_area.install_artifact(handle) + + if staging_root != '/': + staging_area.remove() + def cmd_show_dependencies(self, args): '''Dumps the dependency tree of all input morphologies.''' |