Ejemplo n.º 1
0
func (s *Settings) GetTaskSettingStringSlice(taskName, settingName string) []string {
	retUntyped := s.GetTaskSetting(taskName, settingName)
	if retUntyped == nil {
		return []string{}
	}
	strSlice, err := typeutils.ToStringSlice(retUntyped, taskName+"."+settingName)
	if err != nil {
		//already logged
	}
	return strSlice
}
Ejemplo n.º 2
0
func buildSettingsFromMap(m map[string]interface{}) (*BuildSettings, error) {
	var err error
	bs := BuildSettings{}
	FillBuildSettingsDefaults(&bs)
	for k, v := range m {
		switch k {
		//case "GoRoot":
		//	bs.GoRoot, err = typeutils.ToString(v, k)
		case "Processors":
			var fp float64
			fp, err = typeutils.ToFloat64(v, k)
			if err == nil {
				processors := int(fp)
				bs.Processors = &processors
			}
		case "Race":
			var race bool
			race, err = typeutils.ToBool(v, k)
			if err == nil {
				bs.Race = &race
			}
		case "Verbose":
			var verbose bool
			verbose, err = typeutils.ToBool(v, k)
			if err == nil {
				bs.Verbose = &verbose
			}
		case "PrintCommands":
			var printCommands bool
			printCommands, err = typeutils.ToBool(v, k)
			if err == nil {
				bs.PrintCommands = &printCommands
			}
		case "CcFlags":
			var ccFlags string
			ccFlags, err = typeutils.ToString(v, k)
			if err == nil {
				bs.CcFlags = &ccFlags
			}
		case "Compiler":
			var s string
			s, err = typeutils.ToString(v, k)
			if err == nil {
				bs.Compiler = &s
			}
		case "GccGoFlags":
			var s string
			s, err = typeutils.ToString(v, k)
			if err == nil {
				bs.GccGoFlags = &s
			}
		case "GcFlags":
			var s string
			s, err = typeutils.ToString(v, k)
			if err == nil {
				bs.GcFlags = &s
			}
		case "InstallSuffix":
			var s string
			s, err = typeutils.ToString(v, k)
			if err == nil {
				bs.InstallSuffix = &s
			}
		case "LdFlags":
			var s string
			s, err = typeutils.ToString(v, k)
			if err == nil {
				bs.LdFlags = &s
			}
		case "Tags":
			var s string
			s, err = typeutils.ToString(v, k)
			if err == nil {
				bs.Tags = &s
			}
		case "LdFlagsXVars":
			var xVars map[string]interface{}
			xVars, err = typeutils.ToMap(v, k)
			if err == nil {
				bs.LdFlagsXVars = &xVars
			}
		case "ExtraArgs":
			bs.ExtraArgs, err = typeutils.ToStringSlice(v, k)
		default:
			log.Printf("Warning!! Unrecognised Setting '%s' (value %v)", k, v)
		}
		if err != nil {
			return &bs, err
		}

	}
	return &bs, err
}
Ejemplo n.º 3
0
func loadSettingsSection(settingsSection map[string]interface{}) (settings Settings, err error) {
	settings = Settings{}
	for k, v := range settingsSection {
		//try to match key
		switch k {
		case "Tasks":
			settings.Tasks, err = typeutils.ToStringSlice(v, k)
		case "TasksExclude":
			settings.TasksExclude, err = typeutils.ToStringSlice(v, k)
		case "TasksAppend":
			settings.TasksAppend, err = typeutils.ToStringSlice(v, k)
		case "TasksPrepend":
			settings.TasksPrepend, err = typeutils.ToStringSlice(v, k)
		case "AppName":
			settings.AppName, err = typeutils.ToString(v, k)
		case "ArtifactsDest":
			settings.ArtifactsDest, err = typeutils.ToString(v, k)
		case "OutPath":
			settings.OutPath, err = typeutils.ToString(v, k)
		case "Arch":
			settings.Arch, err = typeutils.ToString(v, k)
		case "Os":
			settings.Os, err = typeutils.ToString(v, k)
		case "BuildConstraints":
			settings.BuildConstraints, err = typeutils.ToString(v, k)
		case "ResourcesInclude":
			settings.ResourcesInclude, err = typeutils.ToString(v, k)
		case "ResourcesExclude":
			settings.ResourcesExclude, err = typeutils.ToString(v, k)
		case "MainDirsExclude":
			settings.MainDirsExclude, err = typeutils.ToString(v, k)
		//deprecated
		case "Resources":
			for k2, v2 := range v.(map[string]interface{}) {
				switch k2 {
				case "Include":
					settings.ResourcesInclude, err = typeutils.ToString(v2, k+":"+k2)
				case "Exclude":
					settings.ResourcesExclude, err = typeutils.ToString(v2, k+":"+k2)
				}
			}
		case "PackageVersion":
			settings.PackageVersion, err = typeutils.ToString(v, k)
		case "BranchName":
			settings.BranchName, err = typeutils.ToString(v, k)
		case "PrereleaseInfo":
			settings.PrereleaseInfo, err = typeutils.ToString(v, k)
		case "BuildName":
			settings.BuildName, err = typeutils.ToString(v, k)
		case "Verbosity":
			settings.Verbosity, err = typeutils.ToString(v, k)
		case "TaskSettings":
			settings.TaskSettings, err = typeutils.ToMapStringMapStringInterface(v, k)
		case "FormatVersion":
			settings.GoxcConfigVersion, err = typeutils.ToString(v, k)
		case "ConfigVersion":
			settings.GoxcConfigVersion, err = typeutils.ToString(v, k)
		case "BuildSettings":
			m, err := typeutils.ToMap(v, k)
			if err == nil {
				settings.BuildSettings, err = buildSettingsFromMap(m)
				if err == nil {
					//log.Printf("Parsed build settings OK (%+v)", settings.BuildSettings)
				}
			}
		case "Env":
			settings.Env, err = typeutils.ToStringSlice(v, k)
		default:
			log.Printf("Warning!! Unrecognised Setting '%s' (value %v)", k, v)
		}
		if err != nil {
			return settings, err
		}
	}
	return settings, err
}