当前位置: 首页>>代码示例>>Golang>>正文


Golang util.StatusMessage函数代码示例

本文整理汇总了Golang中mynewt/apache/org/newt/util.StatusMessage函数的典型用法代码示例。如果您正苦于以下问题:Golang StatusMessage函数的具体用法?Golang StatusMessage怎么用?Golang StatusMessage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了StatusMessage函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: syncRunCmd

func syncRunCmd(cmd *cobra.Command, args []string) {
	proj := InitProject()
	repos := proj.Repos()

	ps, err := project.LoadProjectState()
	if err != nil {
		NewtUsage(nil, err)
	}

	for rName, repo := range repos {
		var exists bool
		if rName == "local" {
			continue
		}
		vers := ps.GetInstalledVersion(repo.Name())
		if vers == nil {
			util.StatusMessage(util.VERBOSITY_DEFAULT,
				"No installed version of %s found, skipping\n",
				repo.Name())
		}
		if err, exists = repo.Sync(vers, syncForce); err != nil {
			NewtUsage(nil, err)
		}

		if exists && !syncForce {
			util.StatusMessage(util.VERBOSITY_DEFAULT,
				"Skipping resync of %s because directory exists.  To "+
					"force resync, add the -f (force) option.\n", repo.Name())
		}
	}
}
开发者ID:apache,项目名称:incubator-mynewt-newt,代码行数:31,代码来源:project_cmds.go

示例2: WritePackage

func (pw *PackageWriter) WritePackage() error {
	dl := pw.downloader

	dl.User = PACKAGEWRITER_GITHUB_DOWNLOAD_USER
	dl.Repo = pw.repo

	util.StatusMessage(util.VERBOSITY_DEFAULT,
		"Download package template for package type %s.\n",
		strings.ToLower(pw.template))

	tmpdir, err := dl.DownloadRepo(PACKAGEWRITER_GITHUB_DOWNLOAD_BRANCH)
	if err != nil {
		return err
	}

	if err := os.RemoveAll(tmpdir + "/.git/"); err != nil {
		return util.NewNewtError(err.Error())
	}

	if err := util.CopyDir(tmpdir, pw.targetPath); err != nil {
		return err
	}

	switch pw.template {
	case "PKG":
		if err := pw.fixupPKG(); err != nil {
			return err
		}
	}

	util.StatusMessage(util.VERBOSITY_DEFAULT,
		"Package successfuly installed into %s.\n", pw.targetPath)

	return nil
}
开发者ID:apache,项目名称:incubator-mynewt-newt,代码行数:35,代码来源:pkgwriter.go

示例3: CompileBinary

// 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, keepSymbols []string, elfLib string) error {

	// Make sure the compiler package info is added to the global set.
	c.ensureLclInfoAdded()

	objList := c.getObjFiles(util.UniqueStrings(objFiles))

	util.StatusMessage(util.VERBOSITY_DEFAULT, "Linking %s\n", dstFile)
	util.StatusMessage(util.VERBOSITY_VERBOSE, "Linking %s with input files %s\n",
		dstFile, objList)

	if elfLib != "" {
		util.StatusMessage(util.VERBOSITY_VERBOSE, "Linking %s with rom image %s\n",
			dstFile, elfLib)
	}

	cmd := c.CompileBinaryCmd(dstFile, options, objFiles, keepSymbols, elfLib)
	_, err := util.ShellCommand(cmd)
	if err != nil {
		return err
	}

	err = writeCommandFile(dstFile, cmd)
	if err != nil {
		return err
	}

	return nil
}
开发者ID:apache,项目名称:incubator-mynewt-newt,代码行数:37,代码来源:compiler.go

示例4: Merge

// Merge - merges given maps into 1 map
// values will be overridden by last matching key - value
func (s1 *SymbolMap) Merge(s2 *SymbolMap) (*SymbolMap, error) {

	for k, v := range *s2 {

		if val, ok := (*s1)[k]; ok {
			/* We already have this in the MAP */
			if val.IsWeak() && !v.IsWeak() {
				(*s1)[k] = v
			} else if v.IsWeak() && !val.IsWeak() {
				/* nothing to do here as this is OK not to replace */
			} else if v.IsLocal() && val.IsLocal() {
				/* two locals that must conflict with name */
				/* have to have separate instances of these */
				util.StatusMessage(util.VERBOSITY_VERBOSE,
					"Local Symbol Conflict: %s from packages %s and %s \n",
					v.Name, v.Bpkg, val.Bpkg)
				(*s2).Remove(k)
			} else {
				util.StatusMessage(util.VERBOSITY_QUIET,
					"Global Symbol Conflict: %s from packages %s and %s \n",
					v.Name, v.Bpkg, val.Bpkg)
				return nil, util.NewNewtError("Global Symbol Conflict")
			}
		} else {
			(*s1)[k] = v
		}

	}
	return s1, nil
}
开发者ID:apache,项目名称:incubator-mynewt-newt,代码行数:32,代码来源:symbol.go

示例5: LinkRequired

// 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,
	keepSymbols []string, elfLib 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, keepSymbols, elfLib)
	if commandHasChanged(dstFile, cmd) {
		util.StatusMessage(util.VERBOSITY_VERBOSE, "%s - link required; "+
			"different command\n", dstFile)
		return true, nil
	}

	// If the elf file doesn't exist or is older than any input file, a rebuild
	// is required.
	dstModTime, err := util.FileModificationTime(dstFile)
	if err != nil {
		return false, err
	}

	// If the elf file doesn't exist or is older than any input file, a rebuild
	// is required.
	if elfLib != "" {
		elfDstModTime, err := util.FileModificationTime(elfLib)
		if err != nil {
			return false, err
		}
		if elfDstModTime.After(dstModTime) {
			util.StatusMessage(util.VERBOSITY_VERBOSE, "%s - link required; "+
				"old elf file\n", elfLib)
			return true, nil
		}
	}

	// Check timestamp of each .o file in the project.
	if tracker.MostRecent.After(dstModTime) {
		util.StatusMessage(util.VERBOSITY_VERBOSE, "%s - link required; "+
			"source newer than elf\n", dstFile)
		return true, nil
	}

	// Check timestamp of the linker script and all input libraries.
	for _, ls := range tracker.compiler.LinkerScripts {
		objFiles = append(objFiles, ls)
	}
	for _, obj := range objFiles {
		objModTime, err := util.FileModificationTime(obj)
		if err != nil {
			return false, err
		}

		if objModTime.After(dstModTime) {
			util.StatusMessage(util.VERBOSITY_VERBOSE, "%s - rebuild "+
				"required; obj older than dependency (%s)\n", dstFile, obj)
			return true, nil
		}
	}

	return false, nil
}
开发者ID:apache,项目名称:incubator-mynewt-newt,代码行数:70,代码来源:deps.go

示例6: DownloadDesc

// Download the repository description.
func (r *Repo) DownloadDesc() error {
	dl := r.downloader

	util.StatusMessage(util.VERBOSITY_VERBOSE, "Downloading "+
		"repository description for %s...\n", r.Name())

	// Configuration path
	cpath := r.repoFilePath()
	if util.NodeNotExist(cpath) {
		if err := os.MkdirAll(cpath, REPO_DEFAULT_PERMS); err != nil {
			return util.NewNewtError(err.Error())
		}
	}

	dl.SetBranch("master")
	if err := dl.FetchFile("repository.yml",
		cpath+"/"+"repository.yml"); err != nil {
		util.StatusMessage(util.VERBOSITY_VERBOSE, " failed\n")
		return err
	}

	util.StatusMessage(util.VERBOSITY_VERBOSE, " success!\n")

	return nil
}
开发者ID:apache,项目名称:incubator-mynewt-newt,代码行数:26,代码来源:repo.go

示例7: valsRunCmd

func valsRunCmd(cmd *cobra.Command, args []string) {
	if len(args) == 0 {
		NewtUsage(cmd, nil)
	}

	allVals := [][]string{}
	for _, elemType := range args {
		vals, err := VarValues(elemType)
		if err != nil {
			NewtUsage(cmd, err)
		}

		allVals = append(allVals, vals)
	}

	for i, vals := range allVals {
		if i != 0 {
			util.StatusMessage(util.VERBOSITY_DEFAULT, "\n")
		}

		util.StatusMessage(util.VERBOSITY_DEFAULT, "%s names:\n", args[i])
		for _, val := range vals {
			util.StatusMessage(util.VERBOSITY_DEFAULT, "    %s\n", val)
		}
	}
}
开发者ID:apache,项目名称:incubator-mynewt-newt,代码行数:26,代码来源:vals_cmds.go

示例8: targetShowCmd

func targetShowCmd(cmd *cobra.Command, args []string) {
	InitProject()
	targetNames := []string{}
	if len(args) == 0 {
		for name, _ := range target.GetTargets() {
			// Don't display the special unittest target; this is used
			// internally by newt, so the user doesn't need to know about it.
			// XXX: This is a hack; come up with a better solution for unit
			// testing.
			if !strings.HasSuffix(name, "/unittest") {
				targetNames = append(targetNames, name)
			}
		}
	} else {
		targetSlice, err := ResolveTargets(args...)
		if err != nil {
			NewtUsage(cmd, err)
		}

		for _, t := range targetSlice {
			targetNames = append(targetNames, t.FullName())
		}
	}

	sort.Strings(targetNames)

	for _, name := range targetNames {
		kvPairs := map[string]string{}

		util.StatusMessage(util.VERBOSITY_DEFAULT, name+"\n")

		target := target.GetTargets()[name]
		for k, v := range target.Vars {
			kvPairs[strings.TrimPrefix(k, "target.")] = v
		}

		// A few variables come from the base package rather than the target.
		kvPairs["syscfg"] = targetSyscfgKVToStr(
			target.Package().SyscfgV.GetStringMapString("syscfg.vals"))
		kvPairs["cflags"] = pkgVarSliceString(target.Package(), "pkg.cflags")
		kvPairs["lflags"] = pkgVarSliceString(target.Package(), "pkg.lflags")
		kvPairs["aflags"] = pkgVarSliceString(target.Package(), "pkg.aflags")

		keys := []string{}
		for k, _ := range kvPairs {
			keys = append(keys, k)
		}
		sort.Strings(keys)
		for _, k := range keys {
			val := kvPairs[k]
			if len(val) > 0 {
				util.StatusMessage(util.VERBOSITY_DEFAULT, "    %s=%s\n",
					k, kvPairs[k])
			}
		}
	}
}
开发者ID:apache,项目名称:incubator-mynewt-newt,代码行数:57,代码来源:target_cmds.go

示例9: buildRunCmd

func buildRunCmd(cmd *cobra.Command, args []string) {
	if len(args) < 1 {
		NewtUsage(cmd, nil)
	}

	InitProject()

	// Verify and resolve each specified package.
	targets, all, err := ResolveTargetsOrAll(args...)
	if err != nil {
		NewtUsage(cmd, err)
	}

	if all {
		// Collect all targets that specify an app package.
		targets = []*target.Target{}
		for _, name := range targetList() {
			t := ResolveTarget(name)
			if t != nil && t.AppName != "" {
				targets = append(targets, t)
			}
		}
	}

	for i, _ := range targets {
		// Reset the global state for the next build.
		// XXX: It is not good that this is necessary.  This is certainly going
		// to bite us...
		if err := ResetGlobalState(); err != nil {
			NewtUsage(nil, err)
		}

		// Look up the target by name.  This has to be done a second time here
		// now that the project has been reset.
		t := ResolveTarget(targets[i].Name())
		if t == nil {
			NewtUsage(nil, util.NewNewtError("Failed to resolve target: "+
				targets[i].Name()))
		}

		util.StatusMessage(util.VERBOSITY_DEFAULT, "Building target %s\n",
			t.FullName())

		b, err := builder.NewTargetBuilder(t)
		if err != nil {
			NewtUsage(nil, err)
		}

		if err := b.Build(); err != nil {
			NewtUsage(nil, err)
		}

		util.StatusMessage(util.VERBOSITY_DEFAULT,
			"Target successfully built: %s\n", t.Name())
	}
}
开发者ID:apache,项目名称:incubator-mynewt-newt,代码行数:56,代码来源:build_cmds.go

示例10: Load

func (b *Builder) Load(imageSlot int, extraJtagCmd string) error {
	if b.appPkg == nil {
		return util.NewNewtError("app package not specified")
	}

	/* Populate the package list and feature sets. */
	err := b.targetBuilder.PrepBuild()
	if err != nil {
		return err
	}

	envSettings := map[string]string{
		"IMAGE_SLOT": strconv.Itoa(imageSlot),
		"FEATURES":   b.FeatureString(),
	}
	if extraJtagCmd != "" {
		envSettings["EXTRA_JTAG_CMD"] = extraJtagCmd
	}
	features := b.cfg.Features()

	var flashTargetArea string
	if _, ok := features["BOOT_LOADER"]; ok {
		envSettings["BOOT_LOADER"] = "1"

		flashTargetArea = "FLASH_AREA_BOOTLOADER"
		util.StatusMessage(util.VERBOSITY_DEFAULT,
			"Loading bootloader\n")
	} else {
		if imageSlot == 0 {
			flashTargetArea = "FLASH_AREA_IMAGE_0"
		} else if imageSlot == 1 {
			flashTargetArea = "FLASH_AREA_IMAGE_1"
		}
		util.StatusMessage(util.VERBOSITY_DEFAULT,
			"Loading %s image into slot %d\n", b.buildName, imageSlot+1)
	}

	bspPkg := b.targetBuilder.bspPkg
	tgtArea := bspPkg.FlashMap.Areas[flashTargetArea]
	if tgtArea.Name == "" {
		return util.NewNewtError(fmt.Sprintf("No flash target area %s\n",
			flashTargetArea))
	}
	envSettings["FLASH_OFFSET"] = "0x" + strconv.FormatInt(int64(tgtArea.Offset), 16)

	if err := Load(b.AppBinBasePath(), b.targetBuilder.bspPkg,
		envSettings); err != nil {

		return err
	}

	util.StatusMessage(util.VERBOSITY_VERBOSE, "Successfully loaded image.\n")

	return nil
}
开发者ID:apache,项目名称:incubator-mynewt-newt,代码行数:55,代码来源:load.go

示例11: upgradeCheck

func (proj *Project) upgradeCheck(r *repo.Repo, vers *repo.Version,
	force bool) (bool, error) {
	rdesc, err := r.GetRepoDesc()
	if err != nil {
		return false, err
	}

	branch, newVers, _ := rdesc.Match(r)
	if newVers == nil {
		util.StatusMessage(util.VERBOSITY_DEFAULT,
			"No matching version to upgrade to "+
				"found for %s.  Please check your project requirements.",
			r.Name())
		return false, util.NewNewtError(fmt.Sprintf("Cannot find a "+
			"version of repository %s that matches project requirements.",
			r.Name()))
	}

	// If the change between the old repository and the new repository would cause
	// and upgrade.  Then prompt for an upgrade response, unless the force option
	// is present.
	if vers.CompareVersions(newVers, vers) != 0 ||
		vers.Stability() != newVers.Stability() {
		if !force {
			str := ""
			if newVers.Stability() != repo.VERSION_STABILITY_NONE {
				str += "(" + branch + ")"
			}

			fmt.Printf("Would you like to upgrade repository %s from %s to %s %s? [Yn] ",
				r.Name(), vers.String(), newVers.String(), str)
			line, more, err := bufio.NewReader(os.Stdin).ReadLine()
			if more || err != nil {
				return false, util.NewNewtError(fmt.Sprintf(
					"Couldn't read upgrade response: %s\n", err.Error()))
			}

			// Anything but no means yes.
			answer := strings.ToUpper(strings.Trim(string(line), " "))
			if answer == "N" || answer == "NO" {
				fmt.Printf("User says don't upgrade, skipping upgrade of %s\n",
					r.Name())
				return true, nil
			}
		}
	} else {
		util.StatusMessage(util.VERBOSITY_VERBOSE,
			"Repository %s doesn't need to be upgraded, latest "+
				"version installed.\n", r.Name())
		return true, nil
	}

	return false, nil
}
开发者ID:apache,项目名称:incubator-mynewt-newt,代码行数:54,代码来源:project.go

示例12: parseObjectLine

/* This is a tricky thing to parse. Right now, I keep all the
 * flags together and just store the offset, size, name and flags.
* 00012970 l       .bss	00000000 _end
* 00011c60 l       .init_array	00000000 __init_array_start
* 00011c60 l       .init_array	00000000 __preinit_array_start
* 000084b0 g     F .text	00000034 os_arch_start
* 00000000 g       .debug_aranges	00000000 __HeapBase
* 00011c88 g     O .data	00000008 g_os_task_list
* 000082cc g     F .text	0000004c os_idle_task
* 000094e0 g     F .text	0000002e .hidden __gnu_uldivmod_helper
* 00000000 g       .svc_table	00000000 SVC_Count
* 000125e4 g     O .bss	00000004 g_console_is_init
* 00009514 g     F .text	0000029c .hidden __divdi3
* 000085a8 g     F .text	00000054 os_eventq_put
* 00000100       O *COM*	00000004 g_idle_task_stack

*/
func parseObjectLine(line string, r *regexp.Regexp) (error, *symbol.SymbolInfo) {

	answer := r.FindAllStringSubmatch(line, 11)

	if len(answer) == 0 {
		return nil, nil
	}

	data := answer[0]

	if len(data) != 6 {
		util.StatusMessage(util.VERBOSITY_DEFAULT,
			"Not enough content in object file line --- %s", line)
		return nil, nil
	}

	si := symbol.NewSymbolInfo()

	si.Name = data[5]

	v, err := strconv.ParseUint(data[1], 16, 32)

	if err != nil {
		util.StatusMessage(util.VERBOSITY_DEFAULT,
			"Could not convert location from object file line --- %s", line)
		return nil, nil
	}

	si.Loc = int(v)

	v, err = strconv.ParseUint(data[4], 16, 32)

	if err != nil {
		util.StatusMessage(util.VERBOSITY_DEFAULT,
			"Could not convert size form object file line --- %s", line)
		return nil, nil
	}

	si.Size = int(v)
	si.Code = data[2]
	si.Section = data[3]

	/*  Common section has length in a different spot. Also, these
	 * are really global variables so mark them as such */
	if si.IsSection("*COM*") {
		si.Size = (*si).Loc
		si.Code = "g" + si.Code[1:]
	}

	return nil, si
}
开发者ID:apache,项目名称:incubator-mynewt-newt,代码行数:68,代码来源:library.go

示例13: targetCreateCmd

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)
	}
}
开发者ID:apache,项目名称:incubator-mynewt-newt,代码行数:26,代码来源:target_cmds.go

示例14: CopyArchive

// Copies all archive files matching the specified file glob.
//
// @param match                 The file glob specifying which assembly files
//                                  to compile.
func (c *Compiler) CopyArchive() error {
	files, _ := filepath.Glob("*.a")

	wd, err := os.Getwd()
	if err != nil {
		return err
	}

	log.Infof("Copying archive if outdated (%s/*.a) %s", wd,
		strings.Join(files, " "))
	for _, file := range files {
		if shouldIgnore := c.shouldIgnoreFile(file); shouldIgnore {
			log.Infof("Ignoring %s because package dictates it.", file)
			continue
		}

		tgtFile := c.DstDir() + "/" +
			strings.TrimSuffix(file, filepath.Ext(file)) + ".a"
		copyRequired, err := c.depTracker.CopyRequired(file)
		if err != nil {
			return err
		}
		if copyRequired {
			err = util.CopyFile(file, tgtFile)
			util.StatusMessage(util.VERBOSITY_DEFAULT, "copying %s\n",
				filepath.ToSlash(tgtFile))
		}

		if err != nil {
			return err
		}
	}

	return nil
}
开发者ID:apache,项目名称:incubator-mynewt-newt,代码行数:39,代码来源:compiler.go

示例15: Test

func (b *Builder) Test(p *pkg.LocalPackage) error {
	// Build the packages alphabetically to ensure a consistent order.
	bpkgs := b.sortedBuildPackages()
	for _, bpkg := range bpkgs {
		if err := b.buildPackage(bpkg); err != nil {
			return err
		}
	}

	testBpkg := b.PkgMap[p]
	testFilename := b.TestExePath(testBpkg)
	if err := b.link(testFilename, nil, nil); err != nil {
		return err
	}

	// Run the tests.
	if err := os.Chdir(filepath.Dir(testFilename)); err != nil {
		return err
	}

	util.StatusMessage(util.VERBOSITY_DEFAULT, "Executing test: %s\n",
		testFilename)
	if _, err := util.ShellCommand(testFilename); err != nil {
		newtError := err.(*util.NewtError)
		newtError.Text = fmt.Sprintf("Test failure (%s):\n%s", p.Name(),
			newtError.Text)
		return newtError
	}

	return nil
}
开发者ID:apache,项目名称:incubator-mynewt-newt,代码行数:31,代码来源:build.go


注:本文中的mynewt/apache/org/newt/util.StatusMessage函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。