GoPLS Viewer

Home|gopls/go/internal/cgo/cgo_pkgconfig.go
1// Copyright 2013 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5package cgo
6
7import (
8    "errors"
9    "fmt"
10    "go/build"
11    exec "golang.org/x/sys/execabs"
12    "strings"
13)
14
15// pkgConfig runs pkg-config with the specified arguments and returns the flags it prints.
16func pkgConfig(mode stringpkgs []string) (flags []stringerr error) {
17    cmd := exec.Command("pkg-config"append([]string{mode}, pkgs...)...)
18    outerr := cmd.CombinedOutput()
19    if err != nil {
20        s := fmt.Sprintf("%s failed: %v"strings.Join(cmd.Args" "), err)
21        if len(out) > 0 {
22            s = fmt.Sprintf("%s: %s"sout)
23        }
24        return nilerrors.New(s)
25    }
26    if len(out) > 0 {
27        flags = strings.Fields(string(out))
28    }
29    return
30}
31
32// pkgConfigFlags calls pkg-config if needed and returns the cflags
33// needed to build the package.
34func pkgConfigFlags(p *build.Package) (cflags []stringerr error) {
35    if len(p.CgoPkgConfig) == 0 {
36        return nilnil
37    }
38    return pkgConfig("--cflags"p.CgoPkgConfig)
39}
40
MembersX
pkgConfig.flags
pkgConfig.err
pkgConfig.cmd
pkgConfigFlags
pkgConfigFlags.p
pkgConfig
pkgConfig.mode
pkgConfig.pkgs
pkgConfigFlags.err
pkgConfigFlags.cflags
errors
pkgConfig.out
pkgConfig.BlockStmt.s
Members
X