mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 10:25:37 +00:00
cmd/gio: change runCmd to return a trimmed string
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+8
-16
@@ -58,15 +58,12 @@ func main() {
|
|||||||
errorf("invalid -buildmode %s\n", *buildMode)
|
errorf("invalid -buildmode %s\n", *buildMode)
|
||||||
}
|
}
|
||||||
// Expand relative package paths.
|
// Expand relative package paths.
|
||||||
out, err := exec.Command("go", "list", pkg).Output()
|
pkg, err := runCmd(exec.Command("go", "list", pkg))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err, ok := err.(*exec.ExitError); ok {
|
errorf("gio: %v", err)
|
||||||
errorf("gio: %s", bytes.TrimSpace(err.Stderr))
|
|
||||||
}
|
|
||||||
errorf("gio: failed to run the go tool: %v", err)
|
|
||||||
}
|
}
|
||||||
bi := &buildInfo{
|
bi := &buildInfo{
|
||||||
pkg: string(bytes.TrimSpace(out)),
|
pkg: pkg,
|
||||||
}
|
}
|
||||||
switch *target {
|
switch *target {
|
||||||
case "ios", "tvos":
|
case "ios", "tvos":
|
||||||
@@ -225,18 +222,18 @@ func errorf(format string, args ...interface{}) {
|
|||||||
os.Exit(2)
|
os.Exit(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
func runCmd(cmd *exec.Cmd) ([]byte, error) {
|
func runCmd(cmd *exec.Cmd) (string, error) {
|
||||||
if *verbose {
|
if *verbose {
|
||||||
fmt.Printf("%s\n", strings.Join(cmd.Args, " "))
|
fmt.Printf("%s\n", strings.Join(cmd.Args, " "))
|
||||||
}
|
}
|
||||||
out, err := cmd.Output()
|
out, err := cmd.Output()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return out, nil
|
return string(bytes.TrimSpace(out)), nil
|
||||||
}
|
}
|
||||||
if err, ok := err.(*exec.ExitError); ok {
|
if err, ok := err.(*exec.ExitError); ok {
|
||||||
return nil, fmt.Errorf("%s failed: %s%s", strings.Join(cmd.Args, " "), out, err.Stderr)
|
return "", fmt.Errorf("%s failed: %s%s", strings.Join(cmd.Args, " "), out, err.Stderr)
|
||||||
}
|
}
|
||||||
return nil, err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
func copyFile(dst, src string) (err error) {
|
func copyFile(dst, src string) (err error) {
|
||||||
@@ -260,12 +257,7 @@ func copyFile(dst, src string) (err error) {
|
|||||||
|
|
||||||
func appDir() (string, error) {
|
func appDir() (string, error) {
|
||||||
cmd := exec.Command("go", "list", "-f", "{{.Dir}}", "gioui.org/ui/app")
|
cmd := exec.Command("go", "list", "-f", "{{.Dir}}", "gioui.org/ui/app")
|
||||||
out, err := runCmd(cmd)
|
return runCmd(cmd)
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
appDir := string(bytes.TrimSpace(out))
|
|
||||||
return appDir, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type arch struct {
|
type arch struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user