mirror of https://github.com/tinygo-org/tinygo.git
wasmstm32webassemblymicrocontrollerarmavrspiwasiadafruitarduinocircuitplayground-expressgpioi2cllvmmicrobitnrf51nrf52nrf52840samd21tinygo
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
817 B
30 lines
817 B
package loader
|
|
|
|
import (
|
|
"os"
|
|
"os/exec"
|
|
"strings"
|
|
|
|
"github.com/tinygo-org/tinygo/compileopts"
|
|
)
|
|
|
|
// List returns a ready-to-run *exec.Cmd for running the `go list` command with
|
|
// the configuration used for TinyGo.
|
|
func List(config *compileopts.Config, extraArgs, pkgs []string) (*exec.Cmd, error) {
|
|
goroot, err := GetCachedGoroot(config)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
args := append([]string{"list"}, extraArgs...)
|
|
if len(config.BuildTags()) != 0 {
|
|
args = append(args, "-tags", strings.Join(config.BuildTags(), " "))
|
|
}
|
|
args = append(args, pkgs...)
|
|
cgoEnabled := "0"
|
|
if config.CgoEnabled() {
|
|
cgoEnabled = "1"
|
|
}
|
|
cmd := exec.Command("go", args...)
|
|
cmd.Env = append(os.Environ(), "GOROOT="+goroot, "GOOS="+config.GOOS(), "GOARCH="+config.GOARCH(), "CGO_ENABLED="+cgoEnabled)
|
|
return cmd, nil
|
|
}
|
|
|