Exemple #1
0
// goXC is the goxc startpoint
// In theory you could call this with a slice of flags
func goXC(call []string) error {
	interpretFlags(call)
	workingDirectory := getWorkingDir()
	mergeConfigIntoSettings(workingDirectory)
	if isWriteConfig || isWriteLocalConfig {
		err := config.WriteJsonConfig(workingDirectory, settings, configName, isWriteLocalConfig)
		if err != nil {
			log.Printf("Could not write config file: %v", err)
		}
		//0.2.5 writeConfig now just exits after writing config
		return err
	} else {
		//0.2.3 fillDefaults should only happen after writing config
		config.FillSettingsDefaults(&settings, workingDirectory)
		tasks.FillTaskSettingsDefaults(&settings)

		if settings.IsVerbose() {
			log.Printf("Final settings %+v", settings)
		}
		destPlatforms := platforms.GetDestPlatforms(settings.Os, settings.Arch)
		destPlatforms = platforms.ApplyBuildConstraints(settings.BuildConstraints, destPlatforms)
		err := tasks.RunTasks(workingDirectory, destPlatforms, &settings, maxProcessors)
		if err != nil {
			log.Printf("RunTasks error: %+v", err)
		}
		return err
	}
}
Exemple #2
0
func bump(tp TaskParams) error {
	c, err := config.LoadJsonConfigs(tp.WorkingDirectory, []string{core.GOXC_CONFIGNAME_BASE + core.GOXC_FILE_EXT}, !tp.Settings.IsQuiet())
	if err != nil {
		return nil
	}
	pv := c.PackageVersion
	if pv == core.PACKAGE_VERSION_DEFAULT || pv == "" {
		//go from 'default' version to 0.0.1 (or 0.1.0 or 1.0.0)
		pv = "0.0.0"
	}
	pvparts := strings.Split(pv, ".")
	partToBumpStr := tp.Settings.GetTaskSettingString(TASK_BUMP, "dot")
	partToBump, err := strconv.Atoi(partToBumpStr)
	if err != nil {
		return err
	}
	if partToBump < 0 {
		return errors.New("Could not determine which part of the version number to bump")
	}
	if len(pvparts) > partToBump {
		thisPart := pvparts[partToBump]
		thisPartNum, err := strconv.Atoi(thisPart)
		if err != nil {
			return err
		}
		thisPartNum += 1
		pvparts[partToBump] = strconv.Itoa(thisPartNum)
		for i, p := range pvparts[partToBump+1:] {
			_, err := strconv.Atoi(p)
			if err != nil {
				break
			} else {
				//reset smaller parts to 0
				pvparts[i+partToBump+1] = "0"
			}

		}
		pvNew := strings.Join(pvparts, ".")
		c.PackageVersion = pvNew
		if !tp.Settings.IsQuiet() {
			log.Printf("Bumping from %s to %s", pv, c.PackageVersion)
		}
		tp.Settings.PackageVersion = pvNew
		return config.WriteJsonConfig(tp.WorkingDirectory, c, "", false)
	} else {
		return errors.New("PackageVersion does not contain enough dots to bump this part of the version number")
	}
}