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:
2026-07-19 11:40:14 +08:00
parent 7c8ac5559a
commit 36f03b16bd
7 changed files with 310 additions and 31 deletions

View File

@ -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
}

View 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
)

View 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
}

View 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")
}