func (t *target) commandFormatOutput(formatter string, outputFile string,
	name string, args ...string) (err error) {
	mainCmd := makeCommand(name, args...)
	if name == "mksyscall" {
		args = append([]string{"run", "mksyscall.go"}, args...)
		mainCmd = makeCommand("go", args...)
		t.setTargetBuildArch(mainCmd)
	} else if name == "mksysnum" {
		args = append([]string{"run", "linux/mksysnum.go"}, args...)
		mainCmd = makeCommand("go", args...)
		t.setTargetBuildArch(mainCmd)
	}

	fmtCmd := makeCommand(formatter)
	if formatter == "mkpost" {
		fmtCmd = makeCommand("go", "run", "mkpost.go")
		t.setTargetBuildArch(fmtCmd)
	}

	// mainCmd | fmtCmd > outputFile
	if fmtCmd.Stdin, err = mainCmd.StdoutPipe(); err != nil {
		return
	}
	if fmtCmd.Stdout, err = os.Create(outputFile); err != nil {
		return
	}

	// Make sure the formatter eventually closes
	if err = fmtCmd.Start(); err != nil {
		return
	}
	defer func() {
		fmtErr := fmtCmd.Wait()
		if err == nil {
			err = fmtErr
		}
	}()

	return mainCmd.Run()
}
// Runs the command, pipes output to a formatter, pipes that to an output file.
Runs the command, pipes output to a formatter, pipes that to an output file.
// Runs the command pipes output to a formatter pipes that to an output file .
func (t *target) commandFormatOutput(formatter string, outputFile string,
	name string, args ...string) (err error) {
	mainCmd := makeCommand(name, args...)
	if name == "mksyscall" {
		args = append([]string{"run", "mksyscall.go"}, args...)
		mainCmd = makeCommand("go", args...)
		t.setTargetBuildArch(mainCmd)
	} else if name == "mksysnum" {
		args = append([]string{"run", "linux/mksysnum.go"}, args...)
		mainCmd = makeCommand("go", args...)
		t.setTargetBuildArch(mainCmd)
	}
	fmtCmd := makeCommand(formatter)
	if formatter == "mkpost" {
		fmtCmd = makeCommand("go", "run", "mkpost.go")
		t.setTargetBuildArch(fmtCmd)
	}
	if fmtCmd.Stdin, err = mainCmd.StdoutPipe(); err != nil {
		return
	}
	if fmtCmd.Stdout, err = os.Create(outputFile); err != nil {
		return
	}
	if err = fmtCmd.Start(); err != nil {
		return
	}
	defer func() {
		fmtErr := fmtCmd.Wait()
		if err == nil {
			err = fmtErr
		}
	}()
	return mainCmd.Run()
}
func ( t * target ) commandFormatOutput ( formatter string , outputFile string , name string , args ... string ) ( err error ) { mainCmd := makeCommand ( name , args ... ) if name == " " { args = append ( [ ] string { " " , " " } , args ... ) mainCmd = makeCommand ( " " , args ... ) t . setTargetBuildArch ( mainCmd ) } else if name == " " { args = append ( [ ] string { " " , " " } , args ... ) mainCmd = makeCommand ( " " , args ... ) t . setTargetBuildArch ( mainCmd ) } fmtCmd := makeCommand ( formatter ) if formatter == " " { fmtCmd = makeCommand ( " " , " " , " " ) t . setTargetBuildArch ( fmtCmd ) } if fmtCmd . Stdin , err = mainCmd . StdoutPipe ( ) ; err != nil { return } if fmtCmd . Stdout , err = os . Create ( outputFile ) ; err != nil { return } if err = fmtCmd . Start ( ) ; err != nil { return } defer func ( ) { fmtErr := fmtCmd . Wait ( ) if err == nil { err = fmtErr } } ( ) return mainCmd . Run ( ) }
Runs the command, pipes output to a formatter, pipes that to an output file.
Runs the command pipes output to a formatter pipes that to an output file .
// mainCmd | fmtCmd > outputFile // Make sure the formatter eventually closes