mirror of
https://gitcode.com/JianFeeeee/HomeAgent.git
synced 2026-09-29 22:12:52 +00:00
feat: add package/build.sh cross-platform build script
- build.sh supports linux/amd64, linux/arm64, darwin/amd64, darwin/arm64, windows/amd64, and 'all' for matrix build - Components: homed (CGO, Linux/macOS-only), waiter (all platforms), gui - Platform matrix documented in script header - waiter: extract setRawMode into rawmode_linux.go + rawmode_other.go for cross-platform support - Add cmd/gui/node_modules/ and dist/ to .gitignore - Fix .gitignore waiter pattern to not ignore cmd/waiter/ directory
This commit is contained in:
@ -11,7 +11,6 @@ import (
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -238,34 +237,5 @@ func printServerOutput(content string) {
|
||||
}
|
||||
}
|
||||
|
||||
func setRawMode(fd int) (func(), error) {
|
||||
type termios struct {
|
||||
Iflag uint32
|
||||
Oflag uint32
|
||||
Cflag uint32
|
||||
Lflag uint32
|
||||
Cc [20]byte
|
||||
Ispeed uint32
|
||||
Ospeed uint32
|
||||
}
|
||||
const (
|
||||
TCGETS = 0x5401
|
||||
TCSETS = 0x5402
|
||||
ICANON = 0x2
|
||||
ECHO = 0x8
|
||||
)
|
||||
var old termios
|
||||
if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), TCGETS, uintptr(unsafe.Pointer(&old))); err != 0 {
|
||||
return func() {}, fmt.Errorf("ioctl TCGETS: %v", err)
|
||||
}
|
||||
new := old
|
||||
new.Lflag &^= ICANON | ECHO
|
||||
if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), TCSETS, uintptr(unsafe.Pointer(&new))); err != 0 {
|
||||
return func() {}, fmt.Errorf("ioctl TCSETS: %v", err)
|
||||
}
|
||||
return func() {
|
||||
syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), TCSETS, uintptr(unsafe.Pointer(&old)))
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
|
||||
18
cmd/waiter/rawmode_defs.go
Normal file
18
cmd/waiter/rawmode_defs.go
Normal file
@ -0,0 +1,18 @@
|
||||
package main
|
||||
|
||||
type termios struct {
|
||||
Iflag uint32
|
||||
Oflag uint32
|
||||
Cflag uint32
|
||||
Lflag uint32
|
||||
Cc [20]byte
|
||||
Ispeed uint32
|
||||
Ospeed uint32
|
||||
}
|
||||
|
||||
const (
|
||||
TCGETS = 0x5401
|
||||
TCSETS = 0x5402
|
||||
ICANON = 0x2
|
||||
ECHO = 0x8
|
||||
)
|
||||
23
cmd/waiter/rawmode_linux.go
Normal file
23
cmd/waiter/rawmode_linux.go
Normal file
@ -0,0 +1,23 @@
|
||||
//go:build linux
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func setRawMode(fd int) (func(), error) {
|
||||
var old termios
|
||||
if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), TCGETS, uintptr(unsafe.Pointer(&old))); err != 0 {
|
||||
return func() {}, err
|
||||
}
|
||||
new := old
|
||||
new.Lflag &^= ICANON | ECHO
|
||||
if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), TCSETS, uintptr(unsafe.Pointer(&new))); err != 0 {
|
||||
return func() {}, err
|
||||
}
|
||||
return func() {
|
||||
syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), TCSETS, uintptr(unsafe.Pointer(&old)))
|
||||
}, nil
|
||||
}
|
||||
9
cmd/waiter/rawmode_other.go
Normal file
9
cmd/waiter/rawmode_other.go
Normal file
@ -0,0 +1,9 @@
|
||||
//go:build !linux
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func setRawMode(fd int) (func(), error) {
|
||||
return func() {}, fmt.Errorf("raw terminal mode not supported on this platform")
|
||||
}
|
||||
Reference in New Issue
Block a user