func targetCreateCmd(cmd *cobra.Command, args []string) {
	if len(args) != 1 {
		NewtUsage(cmd, util.NewNewtError("Missing target name"))
	}

	proj := InitProject()

	pkgName, err := ResolveNewTargetName(args[0])
	if err != nil {
		NewtUsage(cmd, err)
	}

	repo := proj.LocalRepo()
	pack := pkg.NewLocalPackage(repo, repo.Path()+"/"+pkgName)
	pack.SetName(pkgName)
	pack.SetType(pkg.PACKAGE_TYPE_TARGET)

	t := target.NewTarget(pack)
	err = t.Save()
	if err != nil {
		NewtUsage(nil, err)
	} else {
		util.StatusMessage(util.VERBOSITY_DEFAULT,
			"Target %s successfully created\n", pkgName)
	}
}
示例#2
0
func (b *Builder) addSysinitBpkg() (*BuildPackage, error) {
	lpkg := pkg.NewLocalPackage(b.targetPkg.Repo().(*repo.Repo),
		GeneratedBaseDir(b.targetPkg.Name()))
	lpkg.SetName(pkg.ShortName(b.targetPkg) + "-sysinit-" + b.buildName)
	lpkg.SetType(pkg.PACKAGE_TYPE_GENERATED)

	return b.addPackage(lpkg)
}