mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2024-12-24 00:37:49 +00:00
Update CI to use Go 1.17, produce Apple Silicon builds (closes #844)
This commit is contained in:
parent
f92d812f3c
commit
99227b60ce
@ -5,7 +5,7 @@ version: 2.1
|
||||
jobs:
|
||||
lint:
|
||||
docker:
|
||||
- image: circleci/golang:1.16
|
||||
- image: circleci/golang:1.17
|
||||
|
||||
steps:
|
||||
- checkout
|
||||
@ -23,7 +23,7 @@ jobs:
|
||||
|
||||
build-linux:
|
||||
docker:
|
||||
- image: circleci/golang:1.16
|
||||
- image: circleci/golang:1.17
|
||||
|
||||
steps:
|
||||
- checkout
|
||||
@ -124,11 +124,11 @@ jobs:
|
||||
echo -e "Host *\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
|
||||
|
||||
- run:
|
||||
name: Install Go 1.16
|
||||
name: Install Go 1.17
|
||||
command: |
|
||||
cd /tmp
|
||||
curl -LO https://dl.google.com/go/go1.16.darwin-amd64.pkg
|
||||
sudo installer -pkg /tmp/go1.16.darwin-amd64.pkg -target /
|
||||
curl -LO https://dl.google.com/go/go1.17.darwin-amd64.pkg
|
||||
sudo installer -pkg /tmp/go1.17.darwin-amd64.pkg -target /
|
||||
|
||||
#- run:
|
||||
# name: Install Gomobile
|
||||
@ -142,11 +142,15 @@ jobs:
|
||||
GO111MODULE=on GOOS=darwin GOARCH=amd64 ./build
|
||||
cp yggdrasil /tmp/upload/$CINAME-$CIVERSION-darwin-amd64
|
||||
cp yggdrasilctl /tmp/upload/$CINAME-$CIVERSION-yggdrasilctl-darwin-amd64;
|
||||
GO111MODULE=on GOOS=darwin GOARCH=arm64 ./build
|
||||
cp yggdrasil /tmp/upload/$CINAME-$CIVERSION-darwin-arm64
|
||||
cp yggdrasilctl /tmp/upload/$CINAME-$CIVERSION-yggdrasilctl-darwin-arm64;
|
||||
|
||||
- run:
|
||||
name: Build for macOS (.pkg format)
|
||||
command: |
|
||||
PKGARCH=amd64 sh contrib/macos/create-pkg.sh
|
||||
PKGARCH=arm64 sh contrib/macos/create-pkg.sh
|
||||
mv *.pkg /tmp/upload/
|
||||
|
||||
#- run:
|
||||
@ -164,7 +168,7 @@ jobs:
|
||||
|
||||
build-other:
|
||||
docker:
|
||||
- image: circleci/golang:1.16
|
||||
- image: circleci/golang:1.17
|
||||
|
||||
steps:
|
||||
- checkout
|
||||
|
@ -15,6 +15,10 @@ command -v mkbom >/dev/null 2>&1 || (
|
||||
sudo make install || (echo "Failed to build mkbom"; exit 1)
|
||||
)
|
||||
|
||||
# Build Yggdrasil
|
||||
echo "running GO111MODULE=on GOOS=darwin GOARCH=${PKGARCH-amd64} ./build"
|
||||
GO111MODULE=on GOOS=darwin GOARCH=${PKGARCH-amd64} ./build
|
||||
|
||||
# Check if we can find the files we need - they should
|
||||
# exist if you are running this script from the root of
|
||||
# the yggdrasil-go repo and you have ran ./build
|
||||
|
@ -1,49 +1,17 @@
|
||||
//go:build darwin
|
||||
// +build darwin
|
||||
//go:build !cgo && (darwin || ios)
|
||||
// +build !cgo
|
||||
// +build darwin ios
|
||||
|
||||
package multicast
|
||||
|
||||
/*
|
||||
#cgo CFLAGS: -x objective-c
|
||||
#cgo LDFLAGS: -framework Foundation
|
||||
#import <Foundation/Foundation.h>
|
||||
NSNetServiceBrowser *serviceBrowser;
|
||||
void StartAWDLBrowsing() {
|
||||
if (serviceBrowser == nil) {
|
||||
serviceBrowser = [[NSNetServiceBrowser alloc] init];
|
||||
serviceBrowser.includesPeerToPeer = YES;
|
||||
}
|
||||
[serviceBrowser searchForServicesOfType:@"_yggdrasil._tcp" inDomain:@""];
|
||||
}
|
||||
void StopAWDLBrowsing() {
|
||||
if (serviceBrowser == nil) {
|
||||
return;
|
||||
}
|
||||
[serviceBrowser stop];
|
||||
}
|
||||
*/
|
||||
import "C"
|
||||
import (
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func (m *Multicast) _multicastStarted() {
|
||||
if !m.isOpen {
|
||||
return
|
||||
}
|
||||
C.StopAWDLBrowsing()
|
||||
for intf := range m._interfaces {
|
||||
if intf == "awdl0" {
|
||||
C.StartAWDLBrowsing()
|
||||
break
|
||||
}
|
||||
}
|
||||
time.AfterFunc(time.Minute, func() {
|
||||
m.Act(nil, m._multicastStarted)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
func (m *Multicast) multicastReuse(network string, address string, c syscall.RawConn) error {
|
||||
|
69
src/multicast/multicast_darwin_cgo.go
Normal file
69
src/multicast/multicast_darwin_cgo.go
Normal file
@ -0,0 +1,69 @@
|
||||
//go:build (darwin && cgo) || (ios && cgo)
|
||||
// +build darwin,cgo ios,cgo
|
||||
|
||||
package multicast
|
||||
|
||||
/*
|
||||
#cgo CFLAGS: -x objective-c
|
||||
#cgo LDFLAGS: -framework Foundation
|
||||
#import <Foundation/Foundation.h>
|
||||
NSNetServiceBrowser *serviceBrowser;
|
||||
void StartAWDLBrowsing() {
|
||||
if (serviceBrowser == nil) {
|
||||
serviceBrowser = [[NSNetServiceBrowser alloc] init];
|
||||
serviceBrowser.includesPeerToPeer = YES;
|
||||
}
|
||||
[serviceBrowser searchForServicesOfType:@"_yggdrasil._tcp" inDomain:@""];
|
||||
}
|
||||
void StopAWDLBrowsing() {
|
||||
if (serviceBrowser == nil) {
|
||||
return;
|
||||
}
|
||||
[serviceBrowser stop];
|
||||
}
|
||||
*/
|
||||
import "C"
|
||||
import (
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func (m *Multicast) _multicastStarted() {
|
||||
if !m.isOpen {
|
||||
return
|
||||
}
|
||||
C.StopAWDLBrowsing()
|
||||
for intf := range m._interfaces {
|
||||
if intf == "awdl0" {
|
||||
C.StartAWDLBrowsing()
|
||||
break
|
||||
}
|
||||
}
|
||||
time.AfterFunc(time.Minute, func() {
|
||||
m.Act(nil, m._multicastStarted)
|
||||
})
|
||||
}
|
||||
|
||||
func (m *Multicast) multicastReuse(network string, address string, c syscall.RawConn) error {
|
||||
var control error
|
||||
var reuseport error
|
||||
var recvanyif error
|
||||
|
||||
control = c.Control(func(fd uintptr) {
|
||||
reuseport = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_REUSEPORT, 1)
|
||||
|
||||
// sys/socket.h: #define SO_RECV_ANYIF 0x1104
|
||||
recvanyif = unix.SetsockoptInt(int(fd), syscall.SOL_SOCKET, 0x1104, 1)
|
||||
})
|
||||
|
||||
switch {
|
||||
case reuseport != nil:
|
||||
return reuseport
|
||||
case recvanyif != nil:
|
||||
return recvanyif
|
||||
default:
|
||||
return control
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
//go:build !linux && !darwin && !netbsd && !freebsd && !openbsd && !dragonflybsd && !windows
|
||||
// +build !linux,!darwin,!netbsd,!freebsd,!openbsd,!dragonflybsd,!windows
|
||||
//go:build !linux && !darwin && !ios && !netbsd && !freebsd && !openbsd && !dragonflybsd && !windows
|
||||
// +build !linux,!darwin,!ios,!netbsd,!freebsd,!openbsd,!dragonflybsd,!windows
|
||||
|
||||
package multicast
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user