Esempio n. 1
0
File: xc.go Progetto: boldfield/goxc
// xcPlat: Cross compile for a particular platform
// 0.3.0 - breaking change - changed 'call []string' to 'workingDirectory string'.
func xcPlat(dest platforms.Platform, tp TaskParams, exeName string, packagePath string) (string, error) {
	if tp.Settings.IsVerbose() {
		log.Printf("building %s for platform %v.", exeName, dest)
	}
	args := []string{}
	absoluteBin, err := core.GetAbsoluteBin(dest.Os, dest.Arch, tp.Settings.AppName, exeName, tp.WorkingDirectory, tp.Settings.GetFullVersionName(), tp.Settings.OutPath, tp.Settings.ArtifactsDest)
	if err != nil {
		return "", err
	}
	outDir := filepath.Dir(absoluteBin)
	err = os.MkdirAll(outDir, 0755)
	if err != nil {
		return "", err
	}
	args = append(args, "-o", absoluteBin, ".")
	//log.Printf("building %s", exeName)
	//v0.8.5 no longer using CGO_ENABLED
	envExtra := []string{"GOOS=" + dest.Os, "GOARCH=" + dest.Arch}
	if dest.Os == platforms.LINUX && dest.Arch == platforms.ARM {
		// see http://dave.cheney.net/2012/09/08/an-introduction-to-cross-compilation-with-go
		goarm := tp.Settings.GetTaskSettingString(TASK_XC, "GOARM")
		if goarm != "" {
			envExtra = append(envExtra, "GOARM="+goarm)
		}
	}
	err = executils.InvokeGo(packagePath, "build", args, envExtra, tp.Settings)
	return absoluteBin, err
}
Esempio n. 2
0
func runTaskGoInstall(tp TaskParams) error {
	for _, mainDir := range tp.MainDirs {
		err := executils.InvokeGo(mainDir, "install", []string{}, []string{}, tp.Settings)
		if err != nil {
			return err
		}
	}
	return nil
}
Esempio n. 3
0
func runTaskGoVet(tp TaskParams) error {
	dir := tp.Settings.GetTaskSettingString(TASK_GO_VET, "dir")
	args := []string{dir}
	err := executils.InvokeGo(tp.WorkingDirectory, "vet", args, []string{}, tp.Settings)
	//v0.8.3 treat this as a warning only.
	if err != nil {
		log.Print("Go-vet failed (goxc just treats this as a warning for now)")
	}
	return nil
}
Esempio n. 4
0
func runTaskGoTest(tp TaskParams) error {
	dir := tp.Settings.GetTaskSettingString(TASK_GO_TEST, "dir")
	i := tp.Settings.GetTaskSettingBool(TASK_GO_TEST, "i") //this should be false by default! leaving it exposed for invocation as a flag
	short := tp.Settings.GetTaskSettingBool(TASK_GO_TEST, "short")
	args := []string{}
	if i {
		args = append(args, "-i")
	}
	if short {
		args = append(args, "-short")
	}
	args = append(args, dir)
	if tp.Settings.IsVerbose() {
		log.Printf("Running `go test` with args: %v", args)
	}
	err := executils.InvokeGo(tp.WorkingDirectory, "test", args, []string{}, tp.Settings)
	return err
}
Esempio n. 5
0
func runTaskGoFmt(tp TaskParams) error {
	dir := tp.Settings.GetTaskSettingString(TASK_GO_FMT, "dir")
	err := executils.InvokeGo(tp.WorkingDirectory, "fmt", []string{dir}, []string{}, tp.Settings)
	return err
}
Esempio n. 6
0
func runTaskGoClean(tp TaskParams) error {
	err := executils.InvokeGo(tp.WorkingDirectory, "clean", []string{}, []string{}, tp.Settings)
	return err
}