mirror of
https://github.com/golang/go
synced 2024-09-25 03:10:12 -06:00
syscall: separate stdlib imports from others in mksyscall_windows.go
Change-Id: I6610b872578d161e535565258039d9f064f01456 Reviewed-on: https://go-review.googlesource.com/23070 Reviewed-by: Nigel Tao <nigeltao@golang.org> Run-TryBot: Alex Brainman <alex.brainman@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
eb69476c66
commit
4cffe44e36
@ -597,14 +597,20 @@ func (f *Fn) HelperName() string {
|
|||||||
|
|
||||||
// Source files and functions.
|
// Source files and functions.
|
||||||
type Source struct {
|
type Source struct {
|
||||||
Funcs []*Fn
|
Funcs []*Fn
|
||||||
Files []string
|
Files []string
|
||||||
Imports []string
|
StdLibImports []string
|
||||||
|
ExternalImports []string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (src *Source) Import(pkg string) {
|
func (src *Source) Import(pkg string) {
|
||||||
src.Imports = append(src.Imports, pkg)
|
src.StdLibImports = append(src.StdLibImports, pkg)
|
||||||
sort.Strings(src.Imports)
|
sort.Strings(src.StdLibImports)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (src *Source) ExternalImport(pkg string) {
|
||||||
|
src.ExternalImports = append(src.ExternalImports, pkg)
|
||||||
|
sort.Strings(src.ExternalImports)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParseFiles parses files listed in fs and extracts all syscall
|
// ParseFiles parses files listed in fs and extracts all syscall
|
||||||
@ -614,9 +620,10 @@ func ParseFiles(fs []string) (*Source, error) {
|
|||||||
src := &Source{
|
src := &Source{
|
||||||
Funcs: make([]*Fn, 0),
|
Funcs: make([]*Fn, 0),
|
||||||
Files: make([]string, 0),
|
Files: make([]string, 0),
|
||||||
Imports: []string{
|
StdLibImports: []string{
|
||||||
"unsafe",
|
"unsafe",
|
||||||
},
|
},
|
||||||
|
ExternalImports: make([]string, 0),
|
||||||
}
|
}
|
||||||
for _, file := range fs {
|
for _, file := range fs {
|
||||||
if err := src.ParseFile(file); err != nil {
|
if err := src.ParseFile(file); err != nil {
|
||||||
@ -731,7 +738,7 @@ func (src *Source) Generate(w io.Writer) error {
|
|||||||
src.Import("internal/syscall/windows/sysdll")
|
src.Import("internal/syscall/windows/sysdll")
|
||||||
case pkgXSysWindows:
|
case pkgXSysWindows:
|
||||||
default:
|
default:
|
||||||
src.Import("golang.org/x/sys/windows")
|
src.ExternalImport("golang.org/x/sys/windows")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if packageName != "syscall" {
|
if packageName != "syscall" {
|
||||||
@ -809,7 +816,10 @@ const srcTemplate = `
|
|||||||
package {{packagename}}
|
package {{packagename}}
|
||||||
|
|
||||||
import (
|
import (
|
||||||
{{range .Imports}}"{{.}}"
|
{{range .StdLibImports}}"{{.}}"
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{range .ExternalImports}}"{{.}}"
|
||||||
{{end}}
|
{{end}}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user