You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by st...@apache.org on 2016/03/06 03:22:17 UTC

[4/4] incubator-mynewt-newt git commit: first cut at rewrite of newt package & project management. can understand multiple package repositories, and uses project nomenclature discussed. packages are now broken into multiple files. commands are broken

first cut at rewrite of newt package & project management.  can understand multiple package repositories, and uses project nomenclature discussed.  packages are now broken into multiple files.  commands are broken out of newt.go


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/653e2697
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/653e2697
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/653e2697

Branch: refs/heads/rename_project_app
Commit: 653e2697cbca63d72d5d88ece2b96cb5aff0dafe
Parents: 7c3ff1b
Author: Sterling Hughes <st...@apache.org>
Authored: Sat Mar 5 18:22:01 2016 -0800
Committer: Sterling Hughes <st...@apache.org>
Committed: Sat Mar 5 18:22:01 2016 -0800

----------------------------------------------------------------------
 newt/README.md             |   32 -
 newt/builder/build.go      |   44 ++
 newt/cli/build.go          |  243 -------
 newt/cli/builtpkg.go       |   53 --
 newt/cli/compiler.go       |  625 -----------------
 newt/cli/deps.go           |  268 --------
 newt/cli/image.go          |  322 ---------
 newt/cli/legacy.go         |  109 ---
 newt/cli/pkg.go            |  796 ---------------------
 newt/cli/pkglist.go        |  998 ---------------------------
 newt/cli/project.go        |  501 --------------
 newt/cli/remoterepo.go     |  125 ----
 newt/cli/repo.go           |  371 ----------
 newt/cli/target.go         |  889 ------------------------
 newt/cli/util.go           |   44 +-
 newt/cli/vars.go           |   86 ---
 newt/coding_style.txt      |   76 ---
 newt/design.txt            |  389 -----------
 newt/newt.go               | 1443 +--------------------------------------
 newt/pkg/cmds.go           |   39 ++
 newt/pkg/dependency.go     |  134 ++++
 newt/pkg/identity.go       |   44 ++
 newt/pkg/localpackage.go   |  268 ++++++++
 newt/pkg/package.go        |   78 +++
 newt/pkg/version.go        |  178 +++++
 newt/project/cmds.go       |   64 ++
 newt/project/project.go    |  185 +++++
 newt/repo/repo.go          |   64 ++
 newt/target/target.go      |   25 +
 newt/toolchain/compiler.go |  627 +++++++++++++++++
 newt/toolchain/deps.go     |  270 ++++++++
 31 files changed, 2075 insertions(+), 7315 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/653e2697/newt/README.md
----------------------------------------------------------------------
diff --git a/newt/README.md b/newt/README.md
deleted file mode 100644
index c74bc10..0000000
--- a/newt/README.md
+++ /dev/null
@@ -1,32 +0,0 @@
-<!--
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-#  KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
--->
-
-# Newt
-
-Newt is a build and package management tool for embedded projects. Newt makes
-it easy to create reusable components, and provides a framework for building
-them for multiple different architectures. For more information on Newt, please
-go to: http://mynewt.apache.org/
-
-Note: The newt tool depends on the yaml.v2 Go package
-(https://gopkg.in/yaml.v2).  This package is licensed under the LGPLv3, which
-is incompatible with the Apache 2.0 license.  This incompatibility will be
-resolved in a future beta release of the newt tool.

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/653e2697/newt/builder/build.go
----------------------------------------------------------------------
diff --git a/newt/builder/build.go b/newt/builder/build.go
new file mode 100644
index 0000000..6555bca
--- /dev/null
+++ b/newt/builder/build.go
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package builder
+
+import "mynewt.apache.org/newt/newt/pkg"
+
+type CompilerInfo struct {
+	Includes []string
+	Cflags   []string
+	Lflags   []string
+	Aflags   []string
+}
+
+type BuildPackage struct {
+	pkg.LocalPackage
+
+	compilerInfo *CompilerInfo
+	loaded       bool
+}
+
+type Builder struct {
+	Packages []*BuildPackage
+}
+
+func (b *Builder) Init(target *target.Target) error {
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/653e2697/newt/cli/build.go
----------------------------------------------------------------------
diff --git a/newt/cli/build.go b/newt/cli/build.go
deleted file mode 100644
index 9e0c2c9..0000000
--- a/newt/cli/build.go
+++ /dev/null
@@ -1,243 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package cli
-
-import (
-	"os"
-	"sort"
-	"strings"
-)
-
-// Recursively iterates through an pkg's dependencies, adding each pkg
-// encountered to the supplied set.
-func collectDepsAux(pkgList *PkgList, pkg *Pkg, set *map[*Pkg]bool) error {
-	if (*set)[pkg] {
-		return nil
-	}
-
-	(*set)[pkg] = true
-
-	for _, dep := range pkg.Deps {
-		if dep.Name == "" {
-			break
-		}
-
-		// Get pkg structure
-		dpkg, err := pkgList.ResolvePkgName(dep.Name)
-		if err != nil {
-			return err
-		}
-
-		collectDepsAux(pkgList, dpkg, set)
-	}
-
-	return nil
-}
-
-// Recursively iterates through an pkg's dependencies.  The resulting array
-// contains a pointer to each encountered pkg.
-func collectDeps(pkgList *PkgList, pkg *Pkg) ([]*Pkg, error) {
-	set := map[*Pkg]bool{}
-
-	err := collectDepsAux(pkgList, pkg, &set)
-	if err != nil {
-		return nil, err
-	}
-
-	arr := []*Pkg{}
-	for p, _ := range set {
-		arr = append(arr, p)
-	}
-
-	return arr, nil
-}
-
-// Calculates the include paths exported by the specified pkg and all of
-// its recursive dependencies.
-func recursiveIncludePaths(pkgList *PkgList, pkg *Pkg,
-	t *Target) ([]string, error) {
-
-	deps, err := collectDeps(pkgList, pkg)
-	if err != nil {
-		return nil, err
-	}
-
-	incls := []string{}
-	for _, p := range deps {
-		pkgIncls, err := p.GetIncludes(t)
-		if err != nil {
-			return nil, err
-		}
-		incls = append(incls, pkgIncls...)
-	}
-
-	return incls, nil
-}
-
-// Calculates the include paths exported by the specified target's BSP and all
-// of its recursive dependencies.
-func BspIncludePaths(pkgList *PkgList, t *Target) ([]string, error) {
-	if t.Bsp == "" {
-		return nil, NewNewtError("Expected a BSP")
-	}
-
-	bspPkg, err := pkgList.ResolvePkgName(t.Bsp)
-	if err != nil {
-		return nil, NewNewtError("No BSP pkg for " + t.Bsp + " exists")
-	}
-
-	return recursiveIncludePaths(pkgList, bspPkg, t)
-}
-
-func buildBsp(t *Target, pkgList *PkgList, incls *[]string,
-	libs *[]string, capPkgs map[string]string) (string, error) {
-
-	if t.Bsp == "" {
-		return "", NewNewtError("Expected a BSP")
-	}
-
-	bspPkg, err := pkgList.ResolvePkgName(t.Bsp)
-	if err != nil {
-		return "", NewNewtError("No BSP pkg for " + t.Bsp + " exists")
-	}
-
-	if err = pkgList.Build(t, t.Bsp, *incls, libs); err != nil {
-		return "", err
-	}
-
-	// A BSP doesn't have to contain source; don't fail if no library was
-	// built.
-	if lib := pkgList.GetPkgLib(t, bspPkg); NodeExist(lib) {
-		*libs = append(*libs, lib)
-	}
-
-	var linkerScript string
-	if bspPkg.LinkerScript != "" {
-		linkerScript = bspPkg.BasePath + "/" + bspPkg.LinkerScript
-	} else {
-		linkerScript = ""
-	}
-
-	return linkerScript, nil
-}
-
-// Creates the set of compiler flags that should be specified when building a
-// particular target-entity pair.  The "entity" is what is being built; either
-// an pkg or a project.
-func CreateCflags(pkgList *PkgList, c *Compiler, t *Target,
-	entityCflags string) string {
-
-	cflagsSlice := []string{}
-	cflagsSlice = append(cflagsSlice, strings.Fields(c.Cflags)...)
-	cflagsSlice = append(cflagsSlice, strings.Fields(entityCflags)...)
-	cflagsSlice = append(cflagsSlice, strings.Fields(t.Cflags)...)
-
-	// The 'test' identity causes the TEST symbol to be defined.  This allows
-	// pkg code to behave differently in test builds.
-	if t.HasIdentity("test") {
-		cflagsSlice = append(cflagsSlice, "-DTEST")
-	}
-
-	cflagsSlice = append(cflagsSlice, "-DARCH_"+t.Arch)
-
-	// If a non-BSP pkg is being built, add the BSP's C flags to the list.
-	// The BSP's compiler flags get exported to all pkgs.
-	bspPkg, err := pkgList.ResolvePkgName(t.Bsp)
-	if err == nil && bspPkg.Cflags != entityCflags {
-		cflagsSlice = append(cflagsSlice, strings.Fields(bspPkg.Cflags)...)
-	}
-
-	cflagsSlice = UniqueStrings(cflagsSlice)
-	sort.Strings(cflagsSlice)
-	return strings.Join(cflagsSlice, " ")
-}
-
-func CreateLflags(c *Compiler, t *Target, entityLflags string) string {
-	fields := SortFields(c.Lflags, entityLflags, t.Lflags)
-	return strings.Join(fields, " ")
-}
-
-func CreateAflags(c *Compiler, t *Target, entityAflags string) string {
-	fields := SortFields(c.Aflags, entityAflags, t.Aflags)
-	return strings.Join(fields, " ")
-}
-
-func PkgIncludeDirs(pkg *Pkg, t *Target) []string {
-	srcDir := pkg.BasePath + "/src/"
-
-	incls := pkg.Includes
-	incls = append(incls, srcDir)
-	incls = append(incls, srcDir+"/arch/"+t.Arch)
-
-	if t.HasIdentity("test") {
-		testSrcDir := srcDir + "/test"
-		incls = append(incls, testSrcDir)
-		incls = append(incls, testSrcDir+"/arch/"+t.Arch)
-	}
-
-	return incls
-}
-
-// Recursively compiles all the .c and .s files in the specified directory.
-// Architecture-specific files are also compiled.
-func BuildDir(srcDir string, c *Compiler, t *Target, ignDirs []string) error {
-	var err error
-
-	StatusMessage(VERBOSITY_VERBOSE, "compiling src in base directory: %s\n",
-		srcDir)
-
-	// First change into the pkg src directory, and build all the objects
-	// there
-	os.Chdir(srcDir)
-
-	// Don't recurse into destination directories.
-	ignDirs = append(ignDirs, "obj")
-	ignDirs = append(ignDirs, "bin")
-
-	// Ignore architecture-specific source files for now.  Use a temporary
-	// string array here so that the "arch" directory is not ignored in the
-	// subsequent architecture-specific compile phase.
-	baseIgnDirs := append(ignDirs, "arch")
-
-	if err = c.RecursiveCompile("*.c", 0, baseIgnDirs); err != nil {
-		return err
-	}
-
-	archDir := srcDir + "/arch/" + t.Arch + "/"
-	StatusMessage(VERBOSITY_VERBOSE,
-		"compiling architecture specific src pkgs in directory: %s\n",
-		archDir)
-
-	if NodeExist(archDir) {
-		if err := os.Chdir(archDir); err != nil {
-			return NewNewtError(err.Error())
-		}
-		if err := c.RecursiveCompile("*.c", 0, ignDirs); err != nil {
-			return err
-		}
-
-		// compile assembly sources in recursive compile as well
-		if err = c.RecursiveCompile("*.s", 1, ignDirs); err != nil {
-			return err
-		}
-	}
-
-	return nil
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/653e2697/newt/cli/builtpkg.go
----------------------------------------------------------------------
diff --git a/newt/cli/builtpkg.go b/newt/cli/builtpkg.go
deleted file mode 100644
index 48f8df2..0000000
--- a/newt/cli/builtpkg.go
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package cli
-
-import (
-	"fmt"
-)
-
-type BuiltPkg struct {
-	Name    string
-	Hash    string
-	Version string
-}
-
-var BuiltPkgs []*BuiltPkg
-
-func NewBuiltPkg(pkg *Pkg) (*BuiltPkg, error) {
-	var verStr string
-	hash, err := pkg.GetHash()
-	if err != nil {
-		return nil, NewNewtError(fmt.Sprintf("Unable to get hash for %s: %s",
-			pkg.FullName, err.Error()))
-	}
-	if pkg.Version != nil {
-		verStr = pkg.Version.String()
-	} else {
-		verStr = ""
-	}
-
-	builtpkg := &BuiltPkg{
-		Name:    pkg.FullName,
-		Hash:    hash,
-		Version: verStr,
-	}
-	return builtpkg, nil
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/653e2697/newt/cli/compiler.go
----------------------------------------------------------------------
diff --git a/newt/cli/compiler.go b/newt/cli/compiler.go
deleted file mode 100644
index 11555d1..0000000
--- a/newt/cli/compiler.go
+++ /dev/null
@@ -1,625 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package cli
-
-import (
-	"io/ioutil"
-	"log"
-	"os"
-	"path"
-	"path/filepath"
-	"sort"
-	"strings"
-	"time"
-)
-
-const (
-	COMPILER_TYPE_C   = 0
-	COMPILER_TYPE_ASM = 1
-)
-
-type Compiler struct {
-	ConfigPath   string
-	TargetName   string
-	BaseIncludes map[string]bool
-	ObjPathList  map[string]bool
-	LinkerScript string
-
-	Cflags string
-	Aflags string
-	Lflags string
-
-	depTracker            DepTracker
-	ccPath                string
-	asPath                string
-	arPath                string
-	odPath                string
-	osPath                string
-	ocPath                string
-	ldFlags               string
-	ldResolveCircularDeps bool
-	ldMapFile             bool
-}
-
-func NewCompiler(ccPath string, cDef string, tName string, includes []string) (
-	*Compiler, error) {
-
-	c := &Compiler{
-		ConfigPath:   ccPath,
-		TargetName:   tName,
-		BaseIncludes: map[string]bool{},
-		ObjPathList:  map[string]bool{},
-	}
-
-	c.depTracker = NewDepTracker(c)
-	for _, incl := range includes {
-		c.BaseIncludes[incl] = true
-	}
-
-	StatusMessage(VERBOSITY_VERBOSE,
-		"Loading compiler %s, target %s, def %s\n", ccPath, tName, cDef)
-
-	err := c.ReadSettings(cDef)
-	if err != nil {
-		return nil, err
-	}
-
-	return c, nil
-}
-
-func (c *Compiler) ReadSettings(cDef string) error {
-	v, err := ReadConfig(c.ConfigPath, "pkg")
-	if err != nil {
-		return err
-	}
-
-	c.ccPath = v.GetString("compiler.path.cc")
-	c.asPath = v.GetString("compiler.path.as")
-	c.arPath = v.GetString("compiler.path.archive")
-	c.odPath = v.GetString("compiler.path.objdump")
-	c.osPath = v.GetString("compiler.path.objsize")
-	c.ocPath = v.GetString("compiler.path.objcopy")
-
-	cflags := v.GetStringSlice("compiler.flags." + cDef)
-	for _, flag := range cflags {
-		if strings.HasPrefix(flag, "compiler.flags") {
-			c.Cflags += " " + strings.Trim(v.GetString(flag), "\n")
-		} else {
-			c.Cflags += " " + strings.Trim(flag, "\n")
-		}
-	}
-
-	c.ldFlags = v.GetString("compiler.ld.flags")
-	c.ldResolveCircularDeps = v.GetBool("compiler.ld.resolve_circular_deps")
-	c.ldMapFile = v.GetBool("compiler.ld.mapfile")
-
-	log.Printf("[INFO] ccPath = %s, arPath = %s, flags = %s", c.ccPath,
-		c.arPath, c.Cflags)
-
-	return nil
-}
-
-// Skips compilation of the specified C or assembly file, but adds the name of
-// the object file that would have been generated to the compiler's list of
-// object files.  This function is used when the object file is already up to
-// date, so no compilation is necessary.  The name of the object file should
-// still be remembered so that it gets linked in to the final library or
-// executable.
-func (c *Compiler) SkipSourceFile(srcFile string) error {
-	wd, _ := os.Getwd()
-	objDir := wd + "/obj/" + c.TargetName + "/"
-	objFile := objDir + strings.TrimSuffix(srcFile, filepath.Ext(srcFile)) +
-		".o"
-	c.ObjPathList[filepath.ToSlash(objFile)] = true
-
-	// Update the dependency tracker with the object file's modification time.
-	// This is necessary later for determining if the library / executable
-	// needs to be rebuilt.
-	err := c.depTracker.ProcessFileTime(objFile)
-	if err != nil {
-		return err
-	}
-
-	return nil
-}
-
-// Generates a string consisting of all the necessary include path (-I)
-// options.  The result is sorted and contains no duplicate paths.
-func (c *Compiler) IncludesString() string {
-	includes := make([]string, 0, len(c.BaseIncludes))
-	for k, _ := range c.BaseIncludes {
-		includes = append(includes, filepath.ToSlash(k))
-	}
-
-	sort.Strings(includes)
-
-	return "-I" + strings.Join(includes, " -I")
-}
-
-// Calculates the command-line invocation necessary to compile the specified C
-// or assembly file.
-//
-// @param file                  The filename of the source file to compile.
-// @param compilerType          One of the COMPILER_TYPE_[...] constants.
-//
-// @return                      (success) The command string.
-func (c *Compiler) CompileFileCmd(file string,
-	compilerType int) (string, error) {
-
-	wd, _ := os.Getwd()
-	objDir := wd + "/obj/" + c.TargetName + "/"
-	objFile := strings.TrimSuffix(file, filepath.Ext(file)) + ".o"
-	objPath := filepath.ToSlash(objDir + objFile)
-
-	var cmd string
-
-	switch compilerType {
-	case COMPILER_TYPE_C:
-		cmd = c.ccPath
-	case COMPILER_TYPE_ASM:
-		cmd = c.asPath
-	default:
-		return "", NewNewtError("Unknown compiler type")
-	}
-
-	cmd += " -c " + "-o " + objPath + " " + file +
-		" " + c.Cflags + " " + c.IncludesString()
-
-	return cmd, nil
-}
-
-// Generates a dependency Makefile (.d) for the specified source C file.
-//
-// @param file                  The name of the source file.
-func (c *Compiler) GenDepsForFile(file string) error {
-	wd, _ := os.Getwd()
-	objDir := wd + "/obj/" + c.TargetName + "/"
-
-	if NodeNotExist(objDir) {
-		os.MkdirAll(objDir, 0755)
-	}
-
-	depFile := objDir + strings.TrimSuffix(file, filepath.Ext(file)) + ".d"
-	depFile = filepath.ToSlash(depFile)
-	cFlags := c.Cflags + " " + c.IncludesString()
-
-	var cmd string
-	var err error
-
-	cmd = c.ccPath + " " + cFlags + " -MM -MG " + file + " > " + depFile
-	_, err = ShellCommand(cmd)
-	if err != nil {
-		return err
-	}
-
-	return nil
-}
-
-// Compile the specified C or assembly file.
-//
-// @param file                  The filename of the source file to compile.
-// @param compilerType          One of the COMPILER_TYPE_[...] constants.
-func (c *Compiler) CompileFile(file string, compilerType int) error {
-	wd, _ := os.Getwd()
-	objDir := wd + "/obj/" + c.TargetName + "/"
-
-	if NodeNotExist(objDir) {
-		os.MkdirAll(objDir, 0755)
-	}
-
-	objFile := strings.TrimSuffix(file, filepath.Ext(file)) + ".o"
-
-	objPath := objDir + objFile
-	c.ObjPathList[filepath.ToSlash(objPath)] = true
-
-	cmd, err := c.CompileFileCmd(file, compilerType)
-	if err != nil {
-		return err
-	}
-
-	switch compilerType {
-	case COMPILER_TYPE_C:
-		StatusMessage(VERBOSITY_DEFAULT, "Compiling %s\n", file)
-	case COMPILER_TYPE_ASM:
-		StatusMessage(VERBOSITY_DEFAULT, "Assembling %s\n", file)
-	default:
-		return NewNewtError("Unknown compiler type")
-	}
-
-	rsp, err := ShellCommand(cmd)
-	if err != nil {
-		StatusMessage(VERBOSITY_QUIET, string(rsp))
-		return err
-	}
-
-	err = WriteCommandFile(objPath, cmd)
-	if err != nil {
-		return err
-	}
-
-	// Tell the dependency tracker that an object file was just rebuilt.
-	c.depTracker.MostRecent = time.Now()
-
-	return nil
-}
-
-// Compiles all C files matching the specified file glob.
-//
-// @param match                 The file glob specifying which C files to
-//                                  compile.
-func (c *Compiler) Compile(match string) error {
-	files, _ := filepath.Glob(match)
-
-	wd, err := os.Getwd()
-	if err != nil {
-		return err
-	}
-
-	log.Printf("[INFO] Compiling C if outdated (%s/%s) %s", wd, match,
-		strings.Join(files, " "))
-	for _, file := range files {
-		file = filepath.ToSlash(file)
-		compileRequired, err := c.depTracker.CompileRequired(file, 0)
-		if err != nil {
-			return err
-		}
-		if compileRequired {
-			err = c.CompileFile(file, COMPILER_TYPE_C)
-		} else {
-			err = c.SkipSourceFile(file)
-		}
-		if err != nil {
-			return err
-		}
-	}
-
-	return nil
-}
-
-// Compiles all assembly files matching the specified file glob.
-//
-// @param match                 The file glob specifying which assembly files
-//                                  to compile.
-func (c *Compiler) CompileAs(match string) error {
-	files, _ := filepath.Glob(match)
-
-	wd, err := os.Getwd()
-	if err != nil {
-		return err
-	}
-
-	log.Printf("[INFO] Compiling assembly if outdated (%s/%s) %s", wd, match,
-		strings.Join(files, " "))
-	for _, file := range files {
-		compileRequired, err := c.depTracker.CompileRequired(file, 1)
-		if err != nil {
-			return err
-		}
-		if compileRequired {
-			err = c.CompileFile(file, COMPILER_TYPE_ASM)
-		} else {
-			err = c.SkipSourceFile(file)
-		}
-		if err != nil {
-			return err
-		}
-	}
-
-	return nil
-}
-
-func (c *Compiler) RecursiveClean(path string, tName string) error {
-	// Find all the subdirectories of path that contain an "obj/" directory,
-	// and remove that directory either altogether, or just the arch specific
-	// directory.
-	dirList, err := ioutil.ReadDir(path)
-	if err != nil {
-		return NewNewtError(err.Error())
-	}
-
-	for _, node := range dirList {
-		if node.IsDir() {
-			if node.Name() == "obj" || node.Name() == "bin" {
-				if tName == "" {
-					os.RemoveAll(path + "/" + node.Name() + "/")
-				} else {
-					os.RemoveAll(path + "/" + node.Name() + "/" + tName + "/")
-				}
-			} else {
-				// recurse into the directory.
-				err = c.RecursiveClean(path+"/"+node.Name(), tName)
-				if err != nil {
-					return err
-				}
-			}
-		}
-	}
-
-	return nil
-}
-
-func (c *Compiler) processEntry(wd string, node os.FileInfo, match string, cType int,
-	ignDirs []string) error {
-	// check to see if we ignore this element
-	for _, entry := range ignDirs {
-		if entry == node.Name() {
-			return nil
-		}
-	}
-
-	// if not, recurse into the directory
-	os.Chdir(wd + "/" + node.Name())
-	return c.RecursiveCompile(match, cType, ignDirs)
-}
-
-func (c *Compiler) RecursiveCompile(match string, cType int, ignDirs []string) error {
-	// Get a list of files in the current directory, and if they are a directory,
-	// and that directory is not in the ignDirs variable, then recurse into that
-	// directory and compile the files in there
-	wd, err := os.Getwd()
-	if err != nil {
-		return NewNewtError(err.Error())
-	}
-	wd = filepath.ToSlash(wd)
-
-	dirList, err := ioutil.ReadDir(wd)
-	if err != nil {
-		return NewNewtError(err.Error())
-	}
-
-	for _, node := range dirList {
-		if node.IsDir() {
-			err = c.processEntry(wd, node, match, cType, ignDirs)
-			if err != nil {
-				return err
-			}
-		}
-	}
-
-	os.Chdir(wd)
-
-	switch cType {
-	case 0:
-		return c.Compile(match)
-	case 1:
-		return c.CompileAs(match)
-	default:
-		return NewNewtError("Wrong compiler type specified to RecursiveCompile")
-	}
-}
-
-func (c *Compiler) getObjFiles(baseObjFiles []string) string {
-	for objName, _ := range c.ObjPathList {
-		baseObjFiles = append(baseObjFiles, objName)
-	}
-
-	sort.Strings(baseObjFiles)
-	objList := strings.Join(baseObjFiles, " ")
-	return objList
-}
-
-// Calculates the command-line invocation necessary to link the specified elf
-// file.
-//
-// @param dstFile               The filename of the destination elf file to
-//                                  link.
-// @param options               Some build options specifying how the elf file
-//                                  gets generated.
-// @param objFiles              An array of the source .o and .a filenames.
-//
-// @return                      (success) The command string.
-func (c *Compiler) CompileBinaryCmd(dstFile string, options map[string]bool,
-	objFiles []string) string {
-
-	objList := c.getObjFiles(UniqueStrings(objFiles))
-
-	cmd := c.ccPath + " -o " + dstFile + " " + " " + c.Cflags
-	if c.ldResolveCircularDeps {
-		cmd += " -Wl,--start-group " + objList + " -Wl,--end-group "
-	} else {
-		cmd += " " + objList
-	}
-
-	cmd += " " + c.ldFlags
-
-	if c.LinkerScript != "" {
-		cmd += " -T " + c.LinkerScript
-	}
-	if checkBoolMap(options, "mapFile") {
-		cmd += " -Wl,-Map=" + dstFile + ".map"
-	}
-
-	return cmd
-}
-
-// Links the specified elf file.
-//
-// @param dstFile               The filename of the destination elf file to
-//                                  link.
-// @param options               Some build options specifying how the elf file
-//                                  gets generated.
-// @param objFiles              An array of the source .o and .a filenames.
-func (c *Compiler) CompileBinary(dstFile string, options map[string]bool,
-	objFiles []string) error {
-
-	objList := c.getObjFiles(UniqueStrings(objFiles))
-
-	StatusMessage(VERBOSITY_DEFAULT, "Linking %s\n", path.Base(dstFile))
-	StatusMessage(VERBOSITY_VERBOSE, "Linking %s with input files %s\n",
-		dstFile, objList)
-
-	cmd := c.CompileBinaryCmd(dstFile, options, objFiles)
-	rsp, err := ShellCommand(cmd)
-	if err != nil {
-		StatusMessage(VERBOSITY_QUIET, string(rsp))
-		return err
-	}
-
-	err = WriteCommandFile(dstFile, cmd)
-	if err != nil {
-		return err
-	}
-
-	return nil
-}
-
-// Generates the following build artifacts:
-//    * lst file
-//    * map file
-//    * bin file
-//
-// @param elfFilename           The filename of the elf file corresponding to
-//                                  the artifacts to be generated.
-// @param options               Some build options specifying which artifacts
-//                                  get generated.
-func (c *Compiler) generateExtras(elfFilename string,
-	options map[string]bool) error {
-
-	var cmd string
-
-	if checkBoolMap(options, "listFile") {
-		listFile := elfFilename + ".lst"
-		// if list file exists, remove it
-		if NodeExist(listFile) {
-			if err := os.RemoveAll(listFile); err != nil {
-				return err
-			}
-		}
-
-		cmd = c.odPath + " -wxdS " + elfFilename + " >> " + listFile
-		_, err := ShellCommand(cmd)
-		if err != nil {
-			// XXX: gobjdump appears to always crash.  Until we get that sorted
-			// out, don't fail the link process if lst generation fails.
-			return nil
-		}
-
-		sects := []string{".text", ".rodata", ".data"}
-		for _, sect := range sects {
-			cmd = c.odPath + " -s -j " + sect + " " + elfFilename + " >> " +
-				listFile
-			ShellCommand(cmd)
-		}
-
-		cmd = c.osPath + " " + elfFilename + " >> " + listFile
-		_, err = ShellCommand(cmd)
-		if err != nil {
-			return err
-		}
-	}
-
-	if checkBoolMap(options, "binFile") {
-		binFile := elfFilename + ".bin"
-		cmd = c.ocPath + " -R .bss -R .bss.core -R .bss.core.nz -O binary " +
-			elfFilename + " " + binFile
-		_, err := ShellCommand(cmd)
-		if err != nil {
-			return err
-		}
-	}
-
-	return nil
-}
-
-// Links the specified elf file and generates some associated artifacts (lst,
-// bin, and map files).
-//
-// @param binFile               The filename of the destination elf file to
-//                                  link.
-// @param options               Some build options specifying how the elf file
-//                                  gets generated.
-// @param objFiles              An array of the source .o and .a filenames.
-func (c *Compiler) CompileElf(binFile string, options map[string]bool,
-	objFiles []string) error {
-
-	binFile += ".elf"
-
-	linkRequired, err := c.depTracker.LinkRequired(binFile, options, objFiles)
-	if err != nil {
-		return err
-	}
-	if linkRequired {
-		err := c.CompileBinary(binFile, options, objFiles)
-		if err != nil {
-			return err
-		}
-	}
-
-	err = c.generateExtras(binFile, options)
-	if err != nil {
-		return err
-	}
-
-	return nil
-}
-
-// Calculates the command-line invocation necessary to archive the specified
-// static library.
-//
-// @param archiveFile           The filename of the library to archive.
-// @param objFiles              An array of the source .o filenames.
-//
-// @return                      The command string.
-func (c *Compiler) CompileArchiveCmd(archiveFile string,
-	objFiles []string) string {
-
-	objList := c.getObjFiles(objFiles)
-	return c.arPath + " rcs " + archiveFile + " " + objList
-}
-
-// Archives the specified static library.
-//
-// @param archiveFile           The filename of the library to archive.
-// @param objFiles              An array of the source .o filenames.
-func (c *Compiler) CompileArchive(archiveFile string, objFiles []string) error {
-	arRequired, err := c.depTracker.ArchiveRequired(archiveFile, objFiles)
-	if err != nil {
-		return err
-	}
-	if !arRequired {
-		return nil
-	}
-
-	objList := c.getObjFiles(objFiles)
-
-	StatusMessage(VERBOSITY_DEFAULT, "Archiving %s\n", path.Base(archiveFile))
-	StatusMessage(VERBOSITY_VERBOSE, "Archiving %s with object files %s",
-		archiveFile, objList)
-
-	// Delete the old archive, if it exists.
-	err = os.Remove(archiveFile)
-	if err != nil && !os.IsNotExist(err) {
-		return NewNewtError(err.Error())
-	}
-
-	cmd := c.CompileArchiveCmd(archiveFile, objFiles)
-	rsp, err := ShellCommand(cmd)
-	if err != nil {
-		StatusMessage(VERBOSITY_QUIET, string(rsp))
-		return err
-	}
-
-	err = WriteCommandFile(archiveFile, cmd)
-	if err != nil {
-		return err
-	}
-
-	return nil
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/653e2697/newt/cli/deps.go
----------------------------------------------------------------------
diff --git a/newt/cli/deps.go b/newt/cli/deps.go
deleted file mode 100644
index a4c7069..0000000
--- a/newt/cli/deps.go
+++ /dev/null
@@ -1,268 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package cli
-
-import (
-	"os"
-	"path/filepath"
-	"strings"
-	"time"
-)
-
-type DepTracker struct {
-	// Most recent .o modification time.
-	MostRecent time.Time
-
-	compiler *Compiler
-}
-
-func NewDepTracker(c *Compiler) DepTracker {
-	tracker := DepTracker{
-		MostRecent: time.Unix(0, 0),
-		compiler:   c,
-	}
-
-	return tracker
-}
-
-// Parses a dependency (.d) file generated by gcc.  On success, the returned
-// string array is populated with the dependency filenames.  This function
-// expects the first line of a dependency file to have the following format:
-//
-// <file>.d: <file>.c a.h b.h c.h \
-//  d.h e.h f.h
-//
-// This function ignores all lines except for the first.
-func ParseDepsFile(filename string) ([]string, error) {
-	lines, err := ReadLines(filename)
-	if err != nil {
-		return nil, err
-	}
-
-	if len(lines) == 0 {
-		return []string{}, nil
-	}
-
-	// Assume only the first line is important.
-	tokens := strings.Fields(lines[0])
-	if len(tokens) == 0 {
-		return nil, NewNewtError("Invalid Makefile dependency file; first " +
-			"line is blank")
-	}
-
-	dFileTok := tokens[0]
-	if dFileTok[len(dFileTok)-1:] != ":" {
-		return nil, NewNewtError("Invalid Makefile dependency file; first " +
-			"line missing ':'")
-	}
-
-	return tokens[1:], nil
-}
-
-// Updates the dependency tracker's most recent timestamp according to the
-// modification time of the specified file.  If the specified file is older
-// than the tracker's currently most-recent time, this function has no effect.
-func (tracker *DepTracker) ProcessFileTime(file string) error {
-	modTime, err := FileModificationTime(file)
-	if err != nil {
-		return err
-	}
-
-	if modTime.After(tracker.MostRecent) {
-		tracker.MostRecent = modTime
-	}
-
-	return nil
-}
-
-// Determines if the specified C or assembly file needs to be built.  A compile
-// is required if any of the following is true:
-//     * The destination object file does not exist.
-//     * The existing object file was built with a different compiler
-//       invocation.
-//     * The source file has a newer modification time than the object file.
-//     * One or more included header files has a newer modification time than
-//       the object file.
-func (tracker *DepTracker) CompileRequired(srcFile string,
-	compilerType int) (bool, error) {
-	wd, _ := os.Getwd()
-	objDir := wd + "/obj/" + tracker.compiler.TargetName + "/"
-
-	objFile := objDir + strings.TrimSuffix(srcFile, filepath.Ext(srcFile)) +
-		".o"
-	depFile := objDir + strings.TrimSuffix(srcFile, filepath.Ext(srcFile)) +
-		".d"
-
-	// If the object was previously built with a different set of options, a
-	// rebuild is necessary.
-	cmd, err := tracker.compiler.CompileFileCmd(srcFile, compilerType)
-	if err != nil {
-		return false, err
-	}
-	if CommandHasChanged(objFile, cmd) {
-		StatusMessage(VERBOSITY_VERBOSE, "%s - rebuild required; different command\n", srcFile)
-		return true, nil
-	}
-
-	srcModTime, err := FileModificationTime(srcFile)
-	if err != nil {
-		return false, err
-	}
-
-	objModTime, err := FileModificationTime(objFile)
-	if err != nil {
-		return false, err
-	}
-
-	// If the object doesn't exist or is older than the source file, a build is
-	// required; no need to check dependencies.
-	if srcModTime.After(objModTime) {
-		StatusMessage(VERBOSITY_VERBOSE, "%s - rebuild required; source newer than obj\n", srcFile)
-		return true, nil
-	}
-
-	// Determine if the dependency (.d) file needs to be generated.  If it
-	// doesn't exist or is older than the source file, it is out of date and
-	// needs to be created.
-	depModTime, err := FileModificationTime(depFile)
-	if err != nil {
-		return false, err
-	}
-
-	if srcModTime.After(depModTime) {
-		err := tracker.compiler.GenDepsForFile(srcFile)
-		if err != nil {
-			return false, err
-		}
-	}
-
-	// Extract the dependency filenames from the dependency file.
-	deps, err := ParseDepsFile(depFile)
-	if err != nil {
-		return false, err
-	}
-
-	// Check if any dependencies are newer than the destination object file.
-	for _, dep := range deps {
-		if NodeNotExist(dep) {
-			// The dependency has been deleted; the .d file is out of date.
-			// Recreate the dependency file and repeat this entire function.
-			err := tracker.compiler.GenDepsForFile(srcFile)
-			if err != nil {
-				return false, err
-			}
-
-			return tracker.CompileRequired(srcFile, compilerType)
-		} else {
-			depModTime, err = FileModificationTime(dep)
-			if err != nil {
-				return false, err
-			}
-		}
-
-		if depModTime.After(objModTime) {
-			StatusMessage(VERBOSITY_VERBOSE, "%s - rebuild required; obj older than dependency (%s)\n", srcFile, dep)
-			return true, nil
-		}
-	}
-
-	return false, nil
-}
-
-// Determines if the specified static library needs to be rearchived.  The
-// library needs to be archived if any of the following is true:
-//     * The destination library file does not exist.
-//     * The existing library file was built with a different compiler
-//       invocation.
-//     * One or more source object files has a newer modification time than the
-//       library file.
-func (tracker *DepTracker) ArchiveRequired(archiveFile string,
-	objFiles []string) (bool, error) {
-
-	// If the archive was previously built with a different set of options, a
-	// rebuild is required.
-	cmd := tracker.compiler.CompileArchiveCmd(archiveFile, objFiles)
-	if CommandHasChanged(archiveFile, cmd) {
-		return true, nil
-	}
-
-	// If the archive doesn't exist or is older than any object file, a rebuild
-	// is required.
-	aModTime, err := FileModificationTime(archiveFile)
-	if err != nil {
-		return false, err
-	}
-	if tracker.MostRecent.After(aModTime) {
-		return true, nil
-	}
-
-	// The library is up to date.
-	return false, nil
-}
-
-// Determines if the specified elf file needs to be linked.  Linking is
-// necessary if the elf file does not exist or has an older modification time
-// than any source object or library file.
-// Determines if the specified static library needs to be rearchived.  The
-// library needs to be archived if any of the following is true:
-//     * The destination library file does not exist.
-//     * The existing library file was built with a different compiler
-//       invocation.
-//     * One or more source object files has a newer modification time than the
-//       library file.
-func (tracker *DepTracker) LinkRequired(dstFile string,
-	options map[string]bool, objFiles []string) (bool, error) {
-
-	// If the elf file was previously built with a different set of options, a
-	// rebuild is required.
-	cmd := tracker.compiler.CompileBinaryCmd(dstFile, options, objFiles)
-	if CommandHasChanged(dstFile, cmd) {
-		return true, nil
-	}
-
-	// If the elf file doesn't exist or is older than any input file, a rebuild
-	// is required.
-	dstModTime, err := FileModificationTime(dstFile)
-	if err != nil {
-		return false, err
-	}
-
-	// Check timestamp of each .o file in the project.
-	if tracker.MostRecent.After(dstModTime) {
-		return true, nil
-	}
-
-	// Check timestamp of the linker script and all input libraries.
-	if tracker.compiler.LinkerScript != "" {
-		objFiles = append(objFiles, tracker.compiler.LinkerScript)
-	}
-	for _, obj := range objFiles {
-		objModTime, err := FileModificationTime(obj)
-		if err != nil {
-			return false, err
-		}
-
-		if objModTime.After(dstModTime) {
-			return true, nil
-		}
-	}
-
-	return false, nil
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/653e2697/newt/cli/image.go
----------------------------------------------------------------------
diff --git a/newt/cli/image.go b/newt/cli/image.go
deleted file mode 100644
index 0f2ad6c..0000000
--- a/newt/cli/image.go
+++ /dev/null
@@ -1,322 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package cli
-
-import (
-	"bytes"
-	"crypto/sha256"
-	"encoding/binary"
-	"encoding/json"
-	"fmt"
-	"io"
-	"log"
-	"os"
-	"path/filepath"
-	"sort"
-	"strconv"
-	"strings"
-	"time"
-)
-
-type ImageVersion struct {
-	Major    uint8
-	Minor    uint8
-	Rev      uint16
-	BuildNum uint32
-}
-
-type Image struct {
-	target       *Target
-
-	SourceBin    string
-	TargetImg    string
-	ManifestFile string
-	version      ImageVersion
-
-	hash         []byte
-}
-
-type ImageHdr struct {
-	Magic uint32
-	TlvSz uint32
-	HdrSz uint32
-	ImgSz uint32
-	Flags uint32
-	Vers  ImageVersion
-	Pad   uint32
-}
-
-type ImageTrailerTlv struct {
-	Type uint8
-	Pad  uint8
-	Len  uint16
-}
-
-const (
-	IMAGE_MAGIC = 0x96f3b83c /* Image header magic */
-)
-
-const (
-	IMAGE_HEADER_SIZE = 32
-)
-
-/*
- * Image header flags.
- */
-const (
-	IMAGE_F_PIC        = 0x00000001
-	IMAGE_F_HAS_SHA256 = 0x00000002 /* Image contains hash TLV */
-)
-
-/*
- * Image trailer TLV types.
- */
-const (
-	IMAGE_TLV_SHA256 = 1
-)
-
-/*
- * Data that's going to go to build manifest file
- */
-type ImageManifest struct {
-	Date    string              `json:"build_time"`
-	Version string              `json:"build_version"`
-	Hash    string              `json:"id"`
-	Image   string              `json:"image"`
-	Pkgs    []*ImageManifestPkg `json:"pkgs"`
-	TgtVars []string            `json:"target"`
-}
-
-type ImageManifestPkg struct {
-	Name    string `json:"name"`
-	Version string `json:"version,omitempty"`
-	Hash    string `json:"hash"`
-}
-
-func NewImage(t *Target) (*Image, error) {
-	image := &Image{
-		target: t,
-	}
-	return image, nil
-}
-
-func (image *Image) SetVersion(versStr string) error {
-	var err error
-	var major uint64
-	var minor uint64
-	var rev uint64
-	var buildNum uint64
-
-	components := strings.Split(versStr, ".")
-	major, err = strconv.ParseUint(components[0], 10, 8)
-	if err != nil {
-		return NewNewtError(fmt.Sprintf("Invalid version string %s", versStr))
-	}
-	if len(components) > 1 {
-		minor, err = strconv.ParseUint(components[1], 10, 8)
-		if err != nil {
-			return NewNewtError(fmt.Sprintf("Invalid version string %s",
-				versStr))
-		}
-	}
-	if len(components) > 2 {
-		rev, err = strconv.ParseUint(components[2], 10, 16)
-		if err != nil {
-			return NewNewtError(fmt.Sprintf("Invalid version string %s",
-				versStr))
-		}
-	}
-	if len(components) > 3 {
-		buildNum, err = strconv.ParseUint(components[3], 10, 32)
-		if err != nil {
-			return NewNewtError(fmt.Sprintf("Invalid version string %s",
-				versStr))
-		}
-	}
-	image.version.Major = uint8(major)
-	image.version.Minor = uint8(minor)
-	image.version.Rev = uint16(rev)
-	image.version.BuildNum = uint32(buildNum)
-	log.Printf("[VERBOSE] Assigning version number %d.%d.%d.%d\n",
-		image.version.Major, image.version.Minor,
-		image.version.Rev, image.version.BuildNum)
-
-	buf := new(bytes.Buffer)
-	err = binary.Write(buf, binary.LittleEndian, image.version)
-	if err != nil {
-		fmt.Printf("Bombing out\n")
-		return nil
-	}
-
-	return nil
-}
-
-func (image *Image) Generate() error {
-	binFile, err := os.Open(image.SourceBin)
-	if err != nil {
-		return NewNewtError(fmt.Sprintf("Can't open target binary: %s",
-			err.Error()))
-	}
-	defer binFile.Close()
-
-	binInfo, err := binFile.Stat()
-	if err != nil {
-		return NewNewtError(fmt.Sprintf("Can't stat target binary: %s",
-			err.Error()))
-	}
-
-	imgFile, err := os.OpenFile(image.TargetImg,
-		os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0777)
-	if err != nil {
-		return NewNewtError(fmt.Sprintf("Can't open target image: %s",
-			err.Error()))
-	}
-	defer imgFile.Close()
-
-	/*
-	 * Compute hash while updating the file.
-	 */
-	hash := sha256.New()
-
-	/*
-	 * First the header
-	 */
-	hdr := &ImageHdr{
-		Magic: IMAGE_MAGIC,
-		TlvSz: 4 + 32,
-		HdrSz: IMAGE_HEADER_SIZE,
-		ImgSz: uint32(binInfo.Size()),
-		Flags: IMAGE_F_HAS_SHA256,
-		Vers:  image.version,
-		Pad:   0,
-	}
-
-	err = binary.Write(imgFile, binary.LittleEndian, hdr)
-	if err != nil {
-		return NewNewtError(fmt.Sprintf("Failed to serialize image hdr: %s",
-			err.Error()))
-	}
-	err = binary.Write(hash, binary.LittleEndian, hdr)
-	if err != nil {
-		return NewNewtError(fmt.Sprintf("Failed to hash data: %s",
-			err.Error()))
-	}
-
-	/*
-	 * Followed by data.
-	 */
-	dataBuf := make([]byte, 1024)
-	for {
-		cnt, err := binFile.Read(dataBuf)
-		if err != nil && err != io.EOF {
-			return NewNewtError(fmt.Sprintf("Failed to read from %s: %s",
-				image.SourceBin, err.Error()))
-		}
-		if cnt == 0 {
-			break
-		}
-		_, err = imgFile.Write(dataBuf[0:cnt])
-		if err != nil {
-			return NewNewtError(fmt.Sprintf("Failed to write to %s: %s",
-				image.TargetImg, err.Error()))
-		}
-		_, err = hash.Write(dataBuf[0:cnt])
-		if err != nil {
-			return NewNewtError(fmt.Sprintf("Failed to hash data: %s",
-				err.Error()))
-		}
-	}
-
-	image.hash = hash.Sum(nil)
-
-	/*
-	 * Trailer with hash of the data
-	 */
-	tlv := &ImageTrailerTlv{
-		Type: IMAGE_TLV_SHA256,
-		Pad:  0,
-		Len:  uint16(len(image.hash)),
-	}
-	err = binary.Write(imgFile, binary.LittleEndian, tlv)
-	if err != nil {
-		return NewNewtError(fmt.Sprintf("Failed to serialize image trailer: %s",
-			err.Error()))
-	}
-	_, err = imgFile.Write(image.hash)
-	if err != nil {
-		return NewNewtError(fmt.Sprintf("Failed to append hash: %s",
-			err.Error()))
-	}
-
-	return nil
-}
-
-func (image *Image) CreateManifest() error {
-	versionStr := fmt.Sprintf("%d.%d.%d.%d",
-		image.version.Major, image.version.Minor,
-		image.version.Rev, image.version.BuildNum)
-	hashStr := fmt.Sprintf("%x", image.hash)
-	timeStr := time.Now().Format(time.RFC3339)
-
-	manifest := &ImageManifest{
-		Version: versionStr,
-		Hash:    hashStr,
-		Image:   filepath.Base(image.TargetImg),
-		Date:    timeStr,
-	}
-
-	for _, builtPkg := range BuiltPkgs {
-		imgPkg := &ImageManifestPkg{
-			Name:    builtPkg.Name,
-			Version: builtPkg.Version,
-			Hash:    builtPkg.Hash,
-		}
-		manifest.Pkgs = append(manifest.Pkgs, imgPkg)
-	}
-
-	vars := image.target.GetVars()
-	var keys []string
-	for k := range vars {
-		keys = append(keys, k)
-	}
-	sort.Strings(keys)
-	for _, k := range keys {
-		manifest.TgtVars = append(manifest.TgtVars, k+"="+vars[k])
-	}
-	file, err := os.Create(image.ManifestFile)
-	if err != nil {
-		return NewNewtError(fmt.Sprintf("Cannot create manifest file %s: %s",
-			image.ManifestFile, err.Error()))
-	}
-	defer file.Close()
-
-	buffer, err := json.MarshalIndent(manifest, "", "  ")
-	if err != nil {
-		return NewNewtError(fmt.Sprintf("Cannot encode manifest: %s",
-			err.Error()))
-	}
-	_, err = file.Write(buffer)
-	if err != nil {
-		return NewNewtError(fmt.Sprintf("Cannot write manifest file: %s",
-			err.Error()))
-	}
-
-	return nil
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/653e2697/newt/cli/legacy.go
----------------------------------------------------------------------
diff --git a/newt/cli/legacy.go b/newt/cli/legacy.go
deleted file mode 100644
index bdb7303..0000000
--- a/newt/cli/legacy.go
+++ /dev/null
@@ -1,109 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package cli
-
-import (
-	"database/sql"
-	_ "github.com/mattn/go-sqlite3"
-	"log"
-	"os"
-	"strings"
-)
-
-// Migrates target definitions from the legacy sqlite database to
-// "targets/<target-name>/pkg.yml".  If a target is already in the new format,
-// it is not modified.  On success, the legacy database is renamed to prevent
-// subsequent migrations.  The database file is renamed as follows:
-//     .app/app.db --> .app/legacy-app.db
-//
-// @return                      true if any targets were migrated.
-func LegacyMigrateTargets(repo *Repo) bool {
-	const TARGET_SECT_PREFIX = "_target_"
-
-	dbName := repo.StorePath + "/app.db"
-	db, err := sql.Open("sqlite3", dbName)
-	if err != nil {
-		return false
-	}
-
-	// Populate repo configuration
-	log.Printf("[DEBUG] Reading legacy repo configuration from %s", dbName)
-	rows, err := db.Query("SELECT cfg_name,key,value FROM newt_cfg")
-	if err != nil {
-		return false
-	}
-	defer rows.Close()
-
-	// Copy all target settings from the database into the contents map.
-	contents := map[string]map[string]string{}
-	for rows.Next() {
-		var cfgName sql.NullString
-		var cfgKey sql.NullString
-		var cfgVal sql.NullString
-
-		err := rows.Scan(&cfgName, &cfgKey, &cfgVal)
-		if err != nil {
-			return false
-		}
-
-		if strings.HasPrefix(cfgName.String, TARGET_SECT_PREFIX) {
-			mapping, ok := contents[cfgName.String]
-			if !ok {
-				mapping = make(map[string]string)
-				contents[cfgName.String] = mapping
-			}
-
-			mapping[cfgKey.String] = cfgVal.String
-		}
-	}
-
-	// Iterate through the contents map, populating the target store with each
-	// target that doesn't already exist.
-	anyMigrated := false
-	for prefixedName, mapping := range contents {
-		name := prefixedName[len(TARGET_SECT_PREFIX):len(prefixedName)]
-
-		if !TargetExists(repo, name) {
-			target := NewTarget(repo, name)
-			for k, v := range mapping {
-				log.Printf("[DEBUG] Migrating legacy target %s, key=%s val=%s",
-					name, k, v)
-				target.Vars[k] = v
-			}
-
-			err := target.Save()
-			if err != nil {
-				return anyMigrated
-			}
-
-			anyMigrated = true
-		}
-	}
-
-	newName := repo.StorePath + "/legacy-app.db"
-	log.Printf("[DEBUG] Renaming legacy database: %s --> %s", dbName, newName)
-	err = os.Rename(dbName, newName)
-	if err != nil {
-		StatusMessage(VERBOSITY_QUIET, "Warning: Failed to rename legacy "+
-			"database (%s --> %s); %s\n", dbName, newName, err.Error())
-	}
-
-	return anyMigrated
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/653e2697/newt/cli/pkg.go
----------------------------------------------------------------------
diff --git a/newt/cli/pkg.go b/newt/cli/pkg.go
deleted file mode 100644
index dea653f..0000000
--- a/newt/cli/pkg.go
+++ /dev/null
@@ -1,796 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package cli
-
-import (
-	"crypto/sha1"
-	"fmt"
-	"io/ioutil"
-	"log"
-	"os"
-	"path/filepath"
-	"regexp"
-	"strconv"
-	"strings"
-)
-
-type VersMatch struct {
-	CompareType string
-	Vers        *Version
-}
-
-type Version struct {
-	Major    int64
-	Minor    int64
-	Revision int64
-}
-
-type DependencyRequirement struct {
-	Name        string
-	Stability   string
-	VersMatches []*VersMatch
-}
-
-type Pkg struct {
-	// Base directory of the pkg
-	BasePath string
-
-	// Name of the pkg
-	Name string
-
-	// Full Name of the pkg include prefix dir
-	FullName string
-
-	// Repo this pkg belongs to
-	Repo *Repo
-
-	// Pkg version
-	Version *Version
-
-	// Type of pkg
-	LinkerScript string
-
-	// For BSP pkg, how to download
-	DownloadScript string
-
-	// For BSP pkg, how to start debugger and attach it to target board
-	DebugScript string
-
-	// Has the dependencies been loaded for this pkg
-	DepLoaded bool
-
-	// Has the configuration been loaded for this pkg
-	CfgLoaded bool
-
-	// Pkg include directories
-	Includes []string
-
-	// Pkg compiler flags
-	Cflags string
-
-	// Pkg linker flags
-	Lflags string
-
-	// Pkg assembler flags
-	Aflags string
-
-	// Whether or not this pkg is a BSP
-	IsBsp bool
-
-	// Capabilities that this pkg exports
-	Capabilities []*DependencyRequirement
-
-	// Capabilities that this pkg requires
-	ReqCapabilities []*DependencyRequirement
-
-	// Whether or not we've already compiled this pkg
-	Built bool
-
-	// Whether or not we've already cleaned this pkg
-	Clean bool
-
-	// Pkgs that this pkg depends on
-	Deps []*DependencyRequirement
-}
-
-type PkgDesc struct {
-	FullName string
-	Version  *Version
-	/* PkgList this pkgshell belongs to */
-	PkgList *PkgList
-	Hash    string
-	Deps    []*DependencyRequirement
-	Caps    []*DependencyRequirement
-	ReqCaps []*DependencyRequirement
-}
-
-func NewPkgDesc(pkgList *PkgList) (*PkgDesc, error) {
-	eShell := &PkgDesc{
-		PkgList: pkgList,
-	}
-
-	return eShell, nil
-}
-
-func (es *PkgDesc) serializeDepReq(name string,
-	drList []*DependencyRequirement, indent string) string {
-	drStr := ""
-	if len(drList) > 0 {
-		drStr += fmt.Sprintf("%s%s:\n", indent, name)
-		for _, dr := range drList {
-			drStr += fmt.Sprintf("%s    - %s\n", indent, dr)
-		}
-	}
-
-	return drStr
-}
-
-func (es *PkgDesc) Serialize(indent string) string {
-	esStr := fmt.Sprintf("%s%s:\n", indent, es.FullName)
-	indent += "    "
-	if es.Version == nil {
-		es.Version = &Version{0, 0, 0}
-	}
-	esStr += fmt.Sprintf("%svers: %s\n", indent, es.Version)
-	esStr += fmt.Sprintf("%shash: %s\n", indent, es.Hash)
-	esStr += es.serializeDepReq("deps", es.Deps, indent)
-	esStr += es.serializeDepReq("caps", es.Caps, indent)
-	esStr += es.serializeDepReq("req_caps", es.ReqCaps, indent)
-
-	return esStr
-}
-
-func (v *Version) compareVersions(vers1 *Version, vers2 *Version) int64 {
-	log.Printf("[DEBUG] Comparing %s to %s (%d %d %d)", vers1, vers2,
-		vers1.Major-vers2.Major, vers1.Minor-vers2.Minor,
-		vers1.Revision-vers2.Revision)
-
-	if r := vers1.Major - vers2.Major; r != 0 {
-		return r
-	}
-
-	if r := vers1.Minor - vers2.Minor; r != 0 {
-		return r
-	}
-
-	if r := vers1.Revision - vers2.Revision; r != 0 {
-		return r
-	}
-
-	return 0
-}
-
-func (v *Version) SatisfiesVersion(versMatches []*VersMatch) bool {
-	if versMatches == nil {
-		return true
-	}
-
-	for _, match := range versMatches {
-		r := v.compareVersions(match.Vers, v)
-		switch match.CompareType {
-		case "<":
-			if r <= 0 {
-				return false
-			}
-		case "<=":
-			if r < 0 {
-				return false
-			}
-		case ">":
-			if r >= 0 {
-				return false
-			}
-		case ">=":
-			if r > 0 {
-				return false
-			}
-		case "==":
-			if r != 0 {
-				return false
-			}
-		}
-	}
-
-	return true
-}
-
-func (vers *Version) String() string {
-	return fmt.Sprintf("%d.%d.%d", vers.Major, vers.Minor, vers.Revision)
-}
-
-func NewVersParseString(versStr string) (*Version, error) {
-	var err error
-
-	parts := strings.Split(versStr, ".")
-	if len(parts) > 3 {
-		return nil, NewNewtError(fmt.Sprintf("Invalid version string: %s", versStr))
-	}
-
-	if strings.Trim(parts[0], " ") == "" || strings.Trim(parts[0], " ") == "none" {
-		return nil, nil
-	}
-
-	v := &Version{}
-
-	// convert first string to an int
-	if v.Major, err = strconv.ParseInt(parts[0], 0, 64); err != nil {
-		return nil, NewNewtError(err.Error())
-	}
-	if len(parts) >= 2 {
-		if v.Minor, err = strconv.ParseInt(parts[1], 0, 64); err != nil {
-			return nil, NewNewtError(err.Error())
-		}
-	}
-	if len(parts) == 3 {
-		if v.Revision, err = strconv.ParseInt(parts[2], 0, 64); err != nil {
-			return nil, NewNewtError(err.Error())
-		}
-	}
-
-	return v, nil
-}
-
-//
-// Set the version comparison constraints on a dependency requirement.
-// The version string contains a list of version constraints in the following format:
-//    - <comparison><version>
-// Where <comparison> can be any one of the following comparison
-//   operators: <=, <, >, >=, ==
-// And <version> is specified in the form: X.Y.Z where X, Y and Z are all
-// int64 types in decimal form
-func (dr *DependencyRequirement) SetVersStr(versStr string) error {
-	var err error
-
-	re, err := regexp.Compile(`(<=|>=|==|>|<)([\d\.]+)`)
-	if err != nil {
-		return err
-	}
-
-	matches := re.FindAllStringSubmatch(versStr, -1)
-	if matches != nil {
-		dr.VersMatches = make([]*VersMatch, 0, len(matches))
-		for _, match := range matches {
-			vm := &VersMatch{}
-			vm.CompareType = match[1]
-			if vm.Vers, err = NewVersParseString(match[2]); err != nil {
-				return err
-			}
-
-			if vm.Vers != nil {
-				dr.VersMatches = append(dr.VersMatches, vm)
-			}
-		}
-	} else {
-		dr.VersMatches = make([]*VersMatch, 0)
-		vm := &VersMatch{}
-		vm.CompareType = "=="
-		if vm.Vers, err = NewVersParseString(versStr); err != nil {
-			return err
-		}
-		if vm.Vers != nil {
-			dr.VersMatches = append(dr.VersMatches, vm)
-		}
-	}
-
-	if len(dr.VersMatches) == 0 {
-		dr.VersMatches = nil
-	}
-
-	return nil
-}
-
-// Convert the array of version matches into a string for display
-func (dr *DependencyRequirement) VersMatchesString() string {
-	if dr.VersMatches != nil {
-		str := ""
-		for _, match := range dr.VersMatches {
-			str += fmt.Sprintf("%s%s", match.CompareType, match.Vers)
-		}
-		return str
-	} else {
-		return "none"
-	}
-}
-
-// Convert the dependency requirement to a string for display
-func (dr *DependencyRequirement) String() string {
-	return fmt.Sprintf("%s@%s#%s", dr.Name, dr.VersMatchesString(), dr.Stability)
-}
-
-func (dr *DependencyRequirement) SatisfiesCapability(
-	capability *DependencyRequirement) error {
-	if dr.Name != capability.Name {
-		return NewNewtError(fmt.Sprintf("Required capability name %s doesn't match "+
-			"specified capability name %s", dr.Name, capability.Name))
-	}
-
-	for _, versMatch := range dr.VersMatches {
-		if !versMatch.Vers.SatisfiesVersion(capability.VersMatches) {
-			return NewNewtError(fmt.Sprintf("Capability %s doesn't satisfy version "+
-				"requirement %s", capability, versMatch.Vers))
-		}
-	}
-
-	return nil
-}
-
-// Check whether the passed in pkg satisfies the current dependency requirement
-func (dr *DependencyRequirement) SatisfiesDependency(pkg *Pkg) bool {
-	if pkg.FullName != dr.Name {
-		return false
-	}
-
-	if pkg.Version.SatisfiesVersion(dr.VersMatches) {
-		return true
-	}
-
-	return false
-}
-
-// Convert the dependency requirement to branch name to look for
-func (dr *DependencyRequirement) BranchName() string {
-	if dr.Stability != "stable" {
-		// XXX should compare to latest
-		return dr.Stability
-	}
-	for _, versMatch := range dr.VersMatches {
-		if versMatch.CompareType == "==" || versMatch.CompareType == "<=" {
-			if versMatch.Vers.Minor == 0 && versMatch.Vers.Revision == 0 {
-				return fmt.Sprintf("%d", versMatch.Vers.Major)
-			} else if versMatch.Vers.Revision == 0 {
-				return fmt.Sprintf("%d.%d", versMatch.Vers.Major,
-					versMatch.Vers.Minor)
-			} else {
-				return fmt.Sprintf("%d.%d.%d", versMatch.Vers.Major,
-					versMatch.Vers.Minor, versMatch.Vers.Revision)
-			}
-		}
-		// XXX What to do with other version comparisons?
-	}
-	return "master"
-}
-
-// Create a New DependencyRequirement structure from the contents of the depReq
-// string that has been passed in as an argument.
-func NewDependencyRequirementParseString(depReq string) (*DependencyRequirement,
-	error) {
-	// Allocate dependency requirement
-	dr := &DependencyRequirement{}
-	// Split string into multiple parts, @#
-	// first, get dependency name
-	parts := strings.Split(depReq, "@")
-	if len(parts) == 1 {
-		parts = strings.Split(depReq, "#")
-		dr.Name = parts[0]
-		if len(parts) > 1 {
-			dr.Stability = parts[1]
-		} else {
-			dr.Stability = "stable"
-		}
-	} else if len(parts) == 2 {
-		dr.Name = parts[0]
-		verParts := strings.Split(parts[1], "#")
-
-		if err := dr.SetVersStr(verParts[0]); err != nil {
-			return nil, err
-		}
-		if len(verParts) == 2 {
-			dr.Stability = verParts[1]
-		} else {
-			dr.Stability = "stable"
-		}
-	}
-
-	return dr, nil
-}
-
-// Get a map of pkg capabilities.  The returned map contains the name of the
-// capability, and its version as the key, and a pointer to the
-// Capability structure associated with that name.
-func (pkg *Pkg) GetCapabilities() ([]*DependencyRequirement, error) {
-	return pkg.Capabilities, nil
-}
-
-// Return the pkg dependencies for this pkg.
-func (pkg *Pkg) GetDependencies() ([]*DependencyRequirement, error) {
-	return pkg.Deps, nil
-}
-
-func (pkg *Pkg) GetReqCapabilities() ([]*DependencyRequirement, error) {
-	return pkg.ReqCapabilities, nil
-}
-
-func (pkgDesc *PkgDesc) GetCapabilities() ([]*DependencyRequirement, error) {
-	return pkgDesc.Caps, nil
-}
-
-// Return the pkg dependencies for this pkgDesc.
-func (pkgDesc *PkgDesc) GetDependencies() ([]*DependencyRequirement, error) {
-	return pkgDesc.Deps, nil
-}
-
-func (pkgDesc *PkgDesc) GetReqCapabilities() ([]*DependencyRequirement, error) {
-	return pkgDesc.ReqCaps, nil
-}
-
-// Load a pkg's configuration information from the pkg config
-// file.
-func (pkg *Pkg) GetIncludes(t *Target) ([]string, error) {
-	// Return the include directories for just this pkg
-	incls := []string{
-		pkg.BasePath + "/include/",
-		pkg.BasePath + "/include/" + pkg.Name + "/arch/" + t.Arch + "/",
-	}
-
-	return incls, nil
-}
-
-// Load capabilities from a string containing a list of capabilities.
-// The capability format is expected to be one of:
-//   name@version
-//   name
-// @param capList An array of capability strings
-// @return On success error is nil, and a list of capabilities is returned,
-// on failure error is non-nil
-func (pkg *Pkg) loadCaps(capList []string) ([]*DependencyRequirement, error) {
-	if len(capList) == 0 {
-		return nil, nil
-	}
-
-	// Allocate an array of capabilities
-	caps := make([]*DependencyRequirement, 0)
-
-	StatusMessage(VERBOSITY_VERBOSE, "Loading capabilities %s\n",
-		strings.Join(capList, " "))
-	for _, capItem := range capList {
-		dr, err := NewDependencyRequirementParseString(capItem)
-		if err != nil {
-			return nil, err
-		}
-
-		caps = append(caps, dr)
-		log.Printf("[DEBUG] Appending new capability pkg: %s, cap:%s",
-			pkg.Name, dr)
-	}
-
-	return caps, nil
-}
-
-// Create a dependency requirement out of an pkg
-//
-func (pkg *Pkg) MakeDependency() (*DependencyRequirement, error) {
-	return NewDependencyRequirementParseString(pkg.FullName)
-}
-
-// Generate a hash of the contents of an pkg.  This function recursively
-// processes the contents of a directory, ignoring hidden files and the
-// bin and obj directories.  It returns a hash of all the files, their
-// contents.
-func (pkg *Pkg) GetHash() (string, error) {
-	hash := sha1.New()
-
-	err := filepath.Walk(pkg.BasePath,
-		func(path string, info os.FileInfo, err error) error {
-			name := info.Name()
-			if name == "bin" || name == "obj" || name[0] == '.' {
-				return filepath.SkipDir
-			}
-
-			if info.IsDir() {
-				// SHA the directory name into the hash
-				hash.Write([]byte(name))
-			} else {
-				// SHA the file name & contents into the hash
-				contents, err := ioutil.ReadFile(path)
-				if err != nil {
-					return err
-				}
-				hash.Write(contents)
-			}
-			return nil
-		})
-	if err != nil && err != filepath.SkipDir {
-		return "", NewNewtError(err.Error())
-	}
-
-	hashStr := fmt.Sprintf("%x", hash.Sum(nil))
-
-	return hashStr, nil
-}
-
-// Load pkg's configuration, and collect required capabilities, dependencies, and
-// identities it provides, so we'll have this available when target is being built.
-func (pkg *Pkg) LoadDependencies(identities map[string]string,
-	capabilities map[string]string) error {
-
-	if pkg.DepLoaded {
-		return nil
-	}
-
-	log.Printf("[DEBUG] Loading dependencies for pkg %s", pkg.BasePath)
-
-	v, err := ReadConfig(pkg.BasePath, "pkg")
-	if err != nil {
-		return err
-	}
-
-	// Append all identities that this pkg exposes.
-	idents := GetStringSliceIdentities(v, identities, "pkg.identities")
-
-	// Add these to project identities
-	for _, item := range idents {
-		StatusMessage(VERBOSITY_VERBOSE, "    Adding identity %s - %s\n", item,
-			pkg.FullName)
-		identities[item] = pkg.FullName
-	}
-
-	// Load the list of capabilities that this pkg exposes
-	pkg.Capabilities, err = pkg.loadCaps(GetStringSliceIdentities(v, identities,
-		"pkg.caps"))
-	if err != nil {
-		return err
-	}
-
-	// Add these to project capabilities
-	for _, cap := range pkg.Capabilities {
-		if capabilities[cap.String()] != "" &&
-			capabilities[cap.String()] != pkg.FullName {
-
-			return NewNewtError(fmt.Sprintf("Multiple pkgs with "+
-				"capability %s (%s and %s)",
-				cap.String(), capabilities[cap.String()], pkg.FullName))
-		}
-		capabilities[cap.String()] = pkg.FullName
-		StatusMessage(VERBOSITY_VERBOSE, "    Adding capability %s - %s\n",
-			cap.String(), pkg.FullName)
-	}
-
-	// Load the list of capabilities that this pkg requires
-	pkg.ReqCapabilities, err = pkg.loadCaps(GetStringSliceIdentities(v, identities,
-		"pkg.req_caps"))
-	if err != nil {
-		return err
-	}
-
-	// Load pkg dependencies
-	depList := GetStringSliceIdentities(v, identities, "pkg.deps")
-	if len(depList) > 0 {
-		pkg.Deps = make([]*DependencyRequirement, 0, len(depList))
-		for _, depStr := range depList {
-			log.Printf("[DEBUG] Loading dependency %s from pkg %s", depStr,
-				pkg.FullName)
-			dr, err := NewDependencyRequirementParseString(depStr)
-			if err != nil {
-				return err
-			}
-
-			pkg.Deps = append(pkg.Deps, dr)
-		}
-	}
-	for _, cap := range pkg.ReqCapabilities {
-		pkgName := capabilities[cap.String()]
-		if pkgName == "" {
-			continue
-		}
-		dr, err := NewDependencyRequirementParseString(pkgName)
-		if err != nil {
-			return err
-		}
-		pkg.Deps = append(pkg.Deps, dr)
-	}
-
-	pkgName := identities["LIBC"]
-	if pkgName != "" {
-		dr, err := NewDependencyRequirementParseString(pkgName)
-		if err != nil {
-			return err
-		}
-		pkg.Deps = append(pkg.Deps, dr)
-	}
-
-	// Check these as well
-	pkg.LinkerScript = GetStringIdentities(v, identities, "pkg.linkerscript")
-	pkg.DownloadScript = GetStringIdentities(v, identities, "pkg.downloadscript")
-	pkg.DebugScript = GetStringIdentities(v, identities, "pkg.debugscript")
-
-	pkg.Cflags = ""
-	cflags := GetStringSliceIdentities(v, identities, "pkg.cflags")
-	for _, name := range cflags {
-		pkg.Cflags += " " + name
-	}
-	pkg.Lflags = GetStringIdentities(v, identities, "pkg.lflags")
-	pkg.Aflags = GetStringIdentities(v, identities, "pkg.aflags")
-
-	pkg.DepLoaded = true
-
-	return nil
-}
-
-// Collect identities and capabilities that pkg and it's dependencies provide
-func (pkg *Pkg) collectDependencies(pkgList *PkgList,
-	identities map[string]string,
-	capabilities map[string]string) error {
-
-	if pkg.DepLoaded {
-		return nil
-	}
-
-	StatusMessage(VERBOSITY_VERBOSE, "  Collecting pkg %s dependencies\n", pkg.Name)
-
-	err := pkg.LoadDependencies(identities, capabilities)
-	if err != nil {
-		return err
-	}
-
-	for _, dep := range pkg.Deps {
-		pkg, err := pkgList.ResolvePkgName(dep.Name)
-		if err != nil {
-			return err
-		}
-		err = pkg.collectDependencies(pkgList, identities, capabilities)
-		if err != nil {
-			return err
-		}
-	}
-	return nil
-}
-
-// Clear the var which says that dependencies have been checked for this pkg and
-// it's dependencies
-func (pkg *Pkg) clearDependencyMarker(pkgList *PkgList) {
-
-	if pkg.DepLoaded == false {
-		return
-	}
-	pkg.DepLoaded = false
-
-	for _, dep := range pkg.Deps {
-		pkg, err := pkgList.ResolvePkgName(dep.Name)
-		if err == nil {
-			pkg.clearDependencyMarker(pkgList)
-		}
-	}
-}
-
-// Load a pkg's configuration.  This allocates & initializes a fair number of
-// the main data structures within the pkg.
-func (pkg *Pkg) LoadConfig(t *Target, force bool) error {
-	if pkg.CfgLoaded && !force {
-		return nil
-	}
-
-	log.Printf("[DEBUG] Loading configuration for pkg %s", pkg.BasePath)
-
-	v, err := ReadConfig(pkg.BasePath, "pkg")
-	if err != nil {
-		return err
-	}
-
-	pkg.FullName = v.GetString("pkg.name")
-	pkg.Name = filepath.Base(pkg.FullName)
-
-	pkg.Version, err = NewVersParseString(v.GetString("pkg.vers"))
-	if err != nil {
-		return err
-	}
-
-	// Append all the identities that this pkg exposes to sub-pkgs.  This must
-	// be done before the remainder of the settings, as some settings depend on
-	// identity.
-	identities := map[string]string{}
-	if t != nil {
-		identities = t.Identities
-		idents := GetStringSliceIdentities(v, identities, "pkg.identities")
-		for _, item := range idents {
-			identities[item] = pkg.FullName
-		}
-	}
-
-	pkg.LinkerScript = GetStringIdentities(v, identities, "pkg.linkerscript")
-	pkg.DownloadScript = GetStringIdentities(v, identities, "pkg.downloadscript")
-	pkg.DebugScript = GetStringIdentities(v, identities, "pkg.debugscript")
-
-	pkg.Cflags += GetStringIdentities(v, identities, "pkg.cflags")
-	pkg.Lflags += GetStringIdentities(v, identities, "pkg.lflags")
-	pkg.Aflags += GetStringIdentities(v, identities, "pkg.aflags")
-
-	// Load pkg dependencies
-	depList := GetStringSliceIdentities(v, identities, "pkg.deps")
-	if len(depList) > 0 {
-		pkg.Deps = make([]*DependencyRequirement, 0, len(depList))
-		for _, depStr := range depList {
-			log.Printf("[DEBUG] Loading dependency %s from pkg %s", depStr,
-				pkg.FullName)
-			dr, err := NewDependencyRequirementParseString(depStr)
-			if err != nil {
-				return err
-			}
-
-			pkg.Deps = append(pkg.Deps, dr)
-		}
-	}
-
-	// Load the list of capabilities that this pkg exposes
-	pkg.Capabilities, err = pkg.loadCaps(GetStringSliceIdentities(v, identities,
-		"pkg.caps"))
-	if err != nil {
-		return err
-	}
-
-	// Load the list of capabilities that this pkg requires
-	pkg.ReqCapabilities, err = pkg.loadCaps(GetStringSliceIdentities(v, identities,
-		"pkg.req_caps"))
-	if err != nil {
-		return err
-	}
-	if len(pkg.ReqCapabilities) > 0 {
-		for _, reqStr := range pkg.ReqCapabilities {
-			log.Printf("[DEBUG] Loading reqCap %s from pkg %s", reqStr,
-				pkg.FullName)
-		}
-	}
-	pkg.CfgLoaded = true
-
-	return nil
-}
-
-// Initialize a pkg: loads the pkg configuration, and sets up pkg data
-// structures.  Should only be called from NewPkg
-func (pkg *Pkg) Init() error {
-	return nil
-}
-
-// Allocate and initialize a new pkg, and return a fully initialized Pkg
-//     structure.
-// @param repo The Repo this pkg is located in
-// @param basePath The path to this pkg, within the specified repo
-// @return On success, error is nil, and a Pkg is returned.  on failure,
-//         error is not nil.
-func NewPkg(repo *Repo, basePath string) (*Pkg, error) {
-	pkg := &Pkg{
-		BasePath: basePath,
-		Repo:     repo,
-	}
-
-	if err := pkg.Init(); err != nil {
-		return nil, err
-	}
-
-	return pkg, nil
-}
-
-func (pkg *Pkg) TestBinName() string {
-	return "test_" + pkg.Name
-}
-
-/*
- * Download pkg from a pkgList and stick it to repo.
- */
-func (pkgDesc *PkgDesc) Install(pkgMgr *PkgList, branch string) error {
-	downloaded, err := pkgMgr.InstallPkg(pkgDesc.FullName, branch, nil)
-	for _, remoteRepo := range downloaded {
-		remoteRepo.Remove()
-	}
-	return err
-}
-
-func (pkg *Pkg) Remove() error {
-	return os.RemoveAll(pkg.BasePath)
-}