Commit 0efc1628 authored by Alex Brainman's avatar Alex Brainman

syscall: remove mksyscall_windows.go -xsys flag

Also run "go generate" in
internal/syscall/windows and internal/syscall/windows/registry

Updates #15167

Change-Id: I0109226962f81857fe11d308b869d561ea8ed9f9
Reviewed-on: https://go-review.googlesource.com/23021Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent d958dab0
...@@ -2,9 +2,11 @@ ...@@ -2,9 +2,11 @@
package registry package registry
import "unsafe" import (
import "syscall" "internal/syscall/windows/sysdll"
import "internal/syscall/windows/sysdll" "syscall"
"unsafe"
)
var _ unsafe.Pointer var _ unsafe.Pointer
......
...@@ -2,9 +2,11 @@ ...@@ -2,9 +2,11 @@
package windows package windows
import "unsafe" import (
import "syscall" "internal/syscall/windows/sysdll"
import "internal/syscall/windows/sysdll" "syscall"
"unsafe"
)
var _ unsafe.Pointer var _ unsafe.Pointer
......
...@@ -57,6 +57,8 @@ import ( ...@@ -57,6 +57,8 @@ import (
"io/ioutil" "io/ioutil"
"log" "log"
"os" "os"
"path/filepath"
"runtime"
"sort" "sort"
"strconv" "strconv"
"strings" "strings"
...@@ -67,7 +69,6 @@ var ( ...@@ -67,7 +69,6 @@ var (
filename = flag.String("output", "", "output file name (standard output if omitted)") filename = flag.String("output", "", "output file name (standard output if omitted)")
printTraceFlag = flag.Bool("trace", false, "generate print statement after every syscall") printTraceFlag = flag.Bool("trace", false, "generate print statement after every syscall")
systemDLL = flag.Bool("systemdll", false, "whether all DLLs should be loaded from the Windows system directory") systemDLL = flag.Bool("systemdll", false, "whether all DLLs should be loaded from the Windows system directory")
sysRepo = flag.Bool("xsys", false, "whether this code is for the x/sys subrepo")
) )
func trim(s string) string { func trim(s string) string {
...@@ -686,6 +687,23 @@ func (src *Source) ParseFile(path string) error { ...@@ -686,6 +687,23 @@ func (src *Source) ParseFile(path string) error {
return nil return nil
} }
// IsStdRepo returns true if src is part of standard library.
func (src *Source) IsStdRepo() (bool, error) {
if len(src.Files) == 0 {
return false, errors.New("no input files provided")
}
abspath, err := filepath.Abs(src.Files[0])
if err != nil {
return false, err
}
goroot := runtime.GOROOT()
if runtime.GOOS == "windows" {
abspath = strings.ToLower(abspath)
goroot = strings.ToLower(goroot)
}
return strings.HasPrefix(abspath, goroot), nil
}
// Generate output source file from a source set src. // Generate output source file from a source set src.
func (src *Source) Generate(w io.Writer) error { func (src *Source) Generate(w io.Writer) error {
const ( const (
...@@ -693,9 +711,13 @@ func (src *Source) Generate(w io.Writer) error { ...@@ -693,9 +711,13 @@ func (src *Source) Generate(w io.Writer) error {
pkgXSysWindows // x/sys/windows package pkgXSysWindows // x/sys/windows package
pkgOther pkgOther
) )
isStdRepo, err := src.IsStdRepo()
if err != nil {
return err
}
var pkgtype int var pkgtype int
switch { switch {
case !*sysRepo: case isStdRepo:
pkgtype = pkgStd pkgtype = pkgStd
case packageName == "windows": case packageName == "windows":
// TODO: this needs better logic than just using package name // TODO: this needs better logic than just using package name
...@@ -734,7 +756,7 @@ func (src *Source) Generate(w io.Writer) error { ...@@ -734,7 +756,7 @@ func (src *Source) Generate(w io.Writer) error {
}, },
} }
t := template.Must(template.New("main").Funcs(funcMap).Parse(srcTemplate)) t := template.Must(template.New("main").Funcs(funcMap).Parse(srcTemplate))
err := t.Execute(w, src) err = t.Execute(w, src)
if err != nil { if err != nil {
return errors.New("Failed to execute template: " + err.Error()) return errors.New("Failed to execute template: " + err.Error())
} }
......
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