Commit 4cffe44e authored by Alex Brainman's avatar Alex Brainman

syscall: separate stdlib imports from others in mksyscall_windows.go

Change-Id: I6610b872578d161e535565258039d9f064f01456
Reviewed-on: https://go-review.googlesource.com/23070Reviewed-by: 's avatarNigel Tao <nigeltao@golang.org>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent eb69476c
...@@ -599,12 +599,18 @@ func (f *Fn) HelperName() string { ...@@ -599,12 +599,18 @@ func (f *Fn) HelperName() string {
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) { ...@@ -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 { ...@@ -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 = ` ...@@ -809,7 +816,10 @@ const srcTemplate = `
package {{packagename}} package {{packagename}}
import ( import (
{{range .Imports}}"{{.}}" {{range .StdLibImports}}"{{.}}"
{{end}}
{{range .ExternalImports}}"{{.}}"
{{end}} {{end}}
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment