func (bpkg *BuildPackage) publicIncludeDirs(bspPkg *pkg.BspPackage) []string {
	pkgBase := filepath.Base(bpkg.Name())
	bp := bpkg.BasePath()

	incls := []string{
		bp + "/include",
		bp + "/include/" + pkgBase + "/arch/" + bspPkg.Arch,
	}

	if bpkg.Type() == pkg.PACKAGE_TYPE_SDK {
		incls = append(incls, bspPkg.BasePath()+"/include/bsp/")

		sdkIncls := bpkg.findSdkIncludes()
		incls = append(incls, sdkIncls...)
	}

	return incls
}
Example #2
0
func Load(binBaseName string, bspPkg *pkg.BspPackage,
	extraEnvSettings map[string]string) error {

	if bspPkg.DownloadScript == "" {
		return nil
	}

	bspPath := bspPkg.BasePath()

	sortedKeys := make([]string, 0, len(extraEnvSettings))
	for k, _ := range extraEnvSettings {
		sortedKeys = append(sortedKeys, k)
	}
	sort.Strings(sortedKeys)

	envSettings := ""
	for _, key := range sortedKeys {
		envSettings += fmt.Sprintf("%s=\"%s\" ", key, extraEnvSettings[key])
	}

	coreRepo := project.GetProject().FindRepo("apache-mynewt-core")
	envSettings += fmt.Sprintf("CORE_PATH=\"%s\" ", coreRepo.Path())
	envSettings += fmt.Sprintf("BSP_PATH=\"%s\" ", bspPath)
	envSettings += fmt.Sprintf("BIN_BASENAME=\"%s\" ", binBaseName)

	// bspPath, binBaseName are passed in command line for backwards
	// compatibility
	downloadCmd := fmt.Sprintf("%s %s %s %s", envSettings,
		bspPkg.DownloadScript, bspPath, binBaseName)

	util.StatusMessage(util.VERBOSITY_VERBOSE, "Load command: %s\n",
		downloadCmd)
	_, err := util.ShellCommand(downloadCmd)
	if err != nil {
		return err
	}
	util.StatusMessage(util.VERBOSITY_VERBOSE, "Successfully loaded image.\n")

	return nil
}