Ejemplo n.º 1
0
// 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
}
Ejemplo n.º 2
0
func (ld *LocalDownloader) FetchFile(name string, dest string) error {
	srcPath := ld.Path + "/" + name

	log.Debugf("Fetching file %s to %s", srcPath, dest)
	if err := util.CopyFile(srcPath, dest); err != nil {
		return err
	}

	return nil
}
Ejemplo n.º 3
0
func (mi *MfgImage) copyBinFile(srcPath string, dstDir string) error {
	dstPath := dstDir + "/" + filepath.Base(srcPath)

	util.StatusMessage(util.VERBOSITY_VERBOSE, "copying file %s --> %s\n",
		srcPath, dstPath)

	if err := util.CopyFile(srcPath, dstPath); err != nil {
		return err
	}

	return nil
}
Ejemplo n.º 4
0
func targetCopyCmd(cmd *cobra.Command, args []string) {
	if len(args) != 2 {
		NewtUsage(cmd, util.NewNewtError("Must specify exactly one "+
			"source target and one destination target"))
	}

	proj := InitProject()

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

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

	// Copy the source target's base package and adjust the fields which need
	// to change.
	dstTarget := srcTarget.Clone(proj.LocalRepo(), dstName)

	// Save the new target.
	err = dstTarget.Save()
	if err != nil {
		NewtUsage(nil, err)
	}

	// Copy syscfg.yml file.
	srcSyscfgPath := fmt.Sprintf("%s/%s",
		srcTarget.Package().BasePath(),
		pkg.SYSCFG_YAML_FILENAME)
	dstSyscfgPath := fmt.Sprintf("%s/%s",
		dstTarget.Package().BasePath(),
		pkg.SYSCFG_YAML_FILENAME)

	if err := util.CopyFile(srcSyscfgPath, dstSyscfgPath); err != nil {
		// If there is just no source syscfg.yml file, that is not an error.
		if !util.IsNotExist(err) {
			NewtUsage(nil, err)
		}
	}

	util.StatusMessage(util.VERBOSITY_DEFAULT,
		"Target successfully copied; %s --> %s\n",
		srcTarget.FullName(), dstTarget.FullName())
}