fix: allow to build miniooni for windows (#520)
I need to run test on Windows and I just discovered that: 1. the `errno_unix.go` filename does not mean anything because `unix` is not a valid platform, so we need a filename for each platform that we care about; 2. on Windows we need to use WSA prefixed names; 3. `i/e/session_psiphon.go` was not building because of the migration from `netxlite/iox` to `netxlite`. This diff attempts to fix all three issues. The reference issue is https://github.com/ooni/probe/issues/1733, because I was working on such an issue.
This commit is contained in:
parent
9ef4d9df7d
commit
9523753b87
11 changed files with 188 additions and 53 deletions
|
|
@ -59,7 +59,6 @@ func (es *ErrorSpec) IsSystemError() bool {
|
|||
|
||||
// Specs contains all the error specs.
|
||||
var Specs = []*ErrorSpec{
|
||||
NewSystemError("ECANCELED", "operation_canceled"),
|
||||
NewSystemError("ECONNREFUSED", "connection_refused"),
|
||||
NewSystemError("ECONNRESET", "connection_reset"),
|
||||
NewSystemError("EHOSTUNREACH", "host_unreachable"),
|
||||
|
|
@ -138,20 +137,20 @@ func gofmt(filename string) {
|
|||
}
|
||||
}
|
||||
|
||||
func writeSystemSpecificFile(kind string) {
|
||||
func writeSystemSpecificFile(kind, library, prefix string) {
|
||||
filename := "errno_" + kind + ".go"
|
||||
filep := fileCreate(filename)
|
||||
fileWrite(filep, "// Code generated by go generate; DO NOT EDIT.\n")
|
||||
filePrintf(filep, "// Generated: %+v\n\n", time.Now())
|
||||
fileWrite(filep, "package netxlite\n\n")
|
||||
filePrintf(filep, "import \"golang.org/x/sys/%s\"\n\n", kind)
|
||||
filePrintf(filep, "import \"golang.org/x/sys/%s\"\n\n", library)
|
||||
fileWrite(filep, "const (\n")
|
||||
for _, spec := range Specs {
|
||||
if !spec.IsSystemError() {
|
||||
continue
|
||||
}
|
||||
filePrintf(filep, "\t%s = %s.%s\n",
|
||||
spec.AsErrnoName(), kind, spec.AsErrnoName())
|
||||
filePrintf(filep, "\t%s = %s.%s%s\n",
|
||||
spec.AsErrnoName(), library, prefix, spec.AsErrnoName())
|
||||
}
|
||||
fileWrite(filep, ")\n\n")
|
||||
fileClose(filep)
|
||||
|
|
@ -277,8 +276,12 @@ func writeGenericTestFile() {
|
|||
}
|
||||
|
||||
func main() {
|
||||
writeSystemSpecificFile("unix")
|
||||
writeSystemSpecificFile("windows")
|
||||
writeSystemSpecificFile("android", "unix", "")
|
||||
writeSystemSpecificFile("darwin", "unix", "")
|
||||
writeSystemSpecificFile("freebsd", "unix", "")
|
||||
writeSystemSpecificFile("ios", "unix", "")
|
||||
writeSystemSpecificFile("linux", "unix", "")
|
||||
writeSystemSpecificFile("windows", "windows", "WSA")
|
||||
writeGenericFile()
|
||||
writeGenericTestFile()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue