2021-07-07 19:01:57 +00:00
|
|
|
// Copyright (c) 2021 Tailscale Inc & AUTHORS All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
// +build ignore
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
|
|
|
"io/ioutil"
|
|
|
|
"log"
|
2021-07-14 00:02:48 +00:00
|
|
|
"os"
|
2021-07-07 19:01:57 +00:00
|
|
|
"os/exec"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2021-07-14 00:02:48 +00:00
|
|
|
for _, goos := range []string{"windows", "linux", "darwin", "freebsd", "openbsd"} {
|
|
|
|
generate(goos)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func generate(goos string) {
|
2021-07-07 19:01:57 +00:00
|
|
|
var x struct {
|
|
|
|
Imports []string
|
|
|
|
}
|
2021-07-14 00:02:48 +00:00
|
|
|
cmd := exec.Command("go", "list", "-json", "tailscale.com/cmd/tailscaled")
|
|
|
|
cmd.Env = append(os.Environ(), "GOOS="+goos, "GOARCH=amd64")
|
|
|
|
j, err := cmd.Output()
|
2021-07-07 19:01:57 +00:00
|
|
|
if err != nil {
|
2021-07-14 00:02:48 +00:00
|
|
|
log.Fatalf("GOOS=%s GOARCH=amd64 %s: %v", goos, cmd, err)
|
2021-07-07 19:01:57 +00:00
|
|
|
}
|
|
|
|
if err := json.Unmarshal(j, &x); err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
var out bytes.Buffer
|
|
|
|
out.WriteString(`// Copyright (c) 2021 Tailscale Inc & AUTHORS All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
// Code generated by gen_deps.go; DO NOT EDIT.
|
|
|
|
|
|
|
|
package integration
|
|
|
|
|
|
|
|
import (
|
|
|
|
// And depend on a bunch of tailscaled innards, for Go's test caching.
|
|
|
|
// Otherwise cmd/go never sees that we depend on these packages'
|
|
|
|
// transitive deps when we run "go install tailscaled" in a child
|
|
|
|
// process and can cache a prior success when a dependency changes.
|
|
|
|
`)
|
|
|
|
for _, dep := range x.Imports {
|
|
|
|
fmt.Fprintf(&out, "\t_ %q\n", dep)
|
|
|
|
}
|
|
|
|
fmt.Fprintf(&out, ")\n")
|
|
|
|
|
2021-07-14 00:02:48 +00:00
|
|
|
filename := fmt.Sprintf("tailscaled_deps_test_%s.go", goos)
|
|
|
|
err = ioutil.WriteFile(filename, out.Bytes(), 0644)
|
2021-07-07 19:01:57 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|