Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows build #779

Merged
merged 67 commits into from
Nov 30, 2021
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
7ba4a95
wip windows build
alexadhy May 27, 2021
6733324
fixes *nix build
alexadhy May 27, 2021
895d4a8
fix linters windows
alexadhy May 27, 2021
7f1d35d
uses cmdutil from https://github.com/skycoin/dmsg/pull/83
alexadhy May 29, 2021
5dd3f81
fixes goimports
alexadhy May 29, 2021
cb0ca00
Merge remote-tracking branch 'upstream/develop' into windows-build
alexadhy May 29, 2021
2b34341
fixes windows closing file error, fixes data race in logstore
alexadhy May 31, 2021
234013a
update travis golangci-lint version
alexadhy May 31, 2021
fd9df42
goimports
alexadhy May 31, 2021
0a2b000
Merge remote-tracking branch 'upstream/develop' into windows-build
alexadhy Jun 13, 2021
83b2de6
Merge remote-tracking branch 'upstream/develop' into windows-build
alexadhy Jun 21, 2021
8c0ff8c
build with dmsgpty PR
alexadhy Jun 22, 2021
f7eb368
makefile fixes
alexadhy Jun 22, 2021
49ab591
Windows build
alexadhy Jun 22, 2021
30dbf40
added hypervisor dmsgpty for windows
alexadhy Jun 22, 2021
8e00ff3
fixes makefile build on *nix
alexadhy Jun 22, 2021
6365ab1
Merge remote-tracking branch 'upstream/develop' into windows-build
alexadhy Aug 26, 2021
0283e59
Merge remote-tracking branch 'upstream/develop' into windows-build
alexadhy Sep 7, 2021
5257972
Fixes windows start visor
alexadhy Sep 7, 2021
9bf21a9
fixes config loading for windows
alexadhy Sep 7, 2021
761f2b1
adjust default config for cli address in windows
alexadhy Sep 7, 2021
48d6bdc
fixes formatting, config, and socket unlink
alexadhy Sep 7, 2021
1a2ca5c
Merge remote-tracking branch 'upstream/develop' into windows-build
alexadhy Sep 7, 2021
b91455d
fixes formatting in windows
alexadhy Sep 7, 2021
db8d9de
fixes restart test and hypervisor test windows
alexadhy Sep 7, 2021
b8d4cf8
fixes hypervisor test
alexadhy Sep 7, 2021
752e488
lint
alexadhy Sep 7, 2021
5ef1d23
formatting and appveyor fixes
alexadhy Sep 8, 2021
da18891
formatting fixes
alexadhy Sep 8, 2021
5360164
Makefile: appveyor specific
alexadhy Sep 8, 2021
d3a1055
TODO:fixes non deterministic dmsgtracker on windows
alexadhy Sep 8, 2021
23d671d
Merge remote-tracking branch 'upstream/develop' into windows-build
alexadhy Sep 9, 2021
a03438a
some more fixes for windows
alexadhy Sep 10, 2021
bd7acc9
forced: requested changes
alexadhy Oct 2, 2021
215bbd0
Merge remote-tracking branch 'upstream/develop' into windows-build
alexadhy Oct 2, 2021
12dd99e
fixes formatting and vendoring
alexadhy Oct 2, 2021
852a7a9
merge upstream, fixes conflicts
alexadhy Oct 12, 2021
1b1b417
formatting fixes
alexadhy Oct 12, 2021
f30408e
make vpn-client works with windows
alexadhy Oct 12, 2021
080acfb
Merge remote-tracking branch 'upstream/develop' into windows-build
alexadhy Oct 13, 2021
514fa4e
signals aren't sendable on windows
alexadhy Oct 13, 2021
fd1068d
signals aren't sendable on windows
alexadhy Oct 13, 2021
4095a69
update vendor
alexadhy Oct 13, 2021
9d1ae67
wintun 0.14 API
alexadhy Oct 13, 2021
74d9e93
update docs
alexadhy Oct 13, 2021
2243e39
merge with develop, fixes merge conflict
alexadhy Oct 22, 2021
3cb9998
frontend stuff
alexadhy Oct 22, 2021
5541ce4
fixes merge conflicts, sync to develop
alexadhy Oct 22, 2021
67b16a3
fixes makefile
alexadhy Oct 22, 2021
5e9843c
Merge branch 'windows-build' of https://github.com/alexadhy/skywire i…
alexadhy Oct 22, 2021
62a261b
fixes windows build
alexadhy Oct 22, 2021
b74d4d0
enable dmsgpty route on windows
alexadhy Oct 25, 2021
c2f146f
merge with develop fixes conflict
alexadhy Nov 4, 2021
12d0138
update wintun dependency
alexadhy Nov 10, 2021
549c296
merge develop changes
alexadhy Nov 13, 2021
d2d5f5d
vpn-client added named pipes for shutting down in windows
alexadhy Nov 13, 2021
5eac2fd
fixes ipc shutdown windows
alexadhy Nov 13, 2021
c598093
fixes panic in shutdown vpn
alexadhy Nov 13, 2021
07ba357
ipc socket for all apps
alexadhy Nov 13, 2021
ea0b8e0
fixes panic on vpn-client
alexadhy Nov 17, 2021
a27ae50
Merge remote-tracking branch 'upstream/develop' into windows-build
alexadhy Nov 22, 2021
0fb18e5
fixes appveyor lint issues
alexadhy Nov 22, 2021
2fd4638
update cobra to latest version
alexadhy Nov 22, 2021
7c1471c
fixes makefile for windows, remove redirection to dev/null
alexadhy Nov 23, 2021
ba2678c
makefile changes
alexadhy Nov 23, 2021
3aaa550
merge with develop, fixes merge conflict
alexadhy Nov 29, 2021
a21c0c8
merge with develop, fixes merge conflict
alexadhy Nov 29, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 47 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ BRANCH := latest

PROJECT_BASE := github.com/skycoin/skywire
DMSG_BASE := github.com/skycoin/dmsg
OPTS?=GO111MODULE=on
ifeq ($(OS),Windows_NT)
OPTS?=powershell -Command setx GO111MODULE on;
DATE := $(shell powershell -Command date -u ${RFC_3339})
else
OPTS?=GO111MODULE=on
Copy link
Contributor

@ersonp ersonp Sep 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to use DATE := $(shell date -u $(RFC_3339)) inside the else.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's already a DATE variable defined above, so no need to define it twice

Copy link
Contributor

@ersonp ersonp Sep 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, what I meant was that DATE := $(shell date -u $(RFC_3339)) should be inside the else statement as make isn't working in windows if it is outside.

endif

STATIC_OPTS?= $(OPTS) CC=musl-gcc
MANAGER_UI_DIR = static/skywire-manager-src
MANAGER_UI_BUILT_DIR=cmd/skywire-visor/static
Expand Down Expand Up @@ -45,6 +51,8 @@ check: lint test ## Run linters and tests

build: host-apps bin ## Install dependencies, build apps and binaries. `go build` with ${OPTS}

build-windows: host-apps-windows bin-windows ## Install dependencies, build apps and binaries. `go build` with ${OPTS}

build-static: host-apps-static bin-static ## Build apps and binaries. `go build` with ${OPTS}

install-generate: ## Installs required execs for go generate.
Expand All @@ -63,9 +71,16 @@ clean: ## Clean project: remove created binaries and apps
-rm -rf ./apps
-rm -f ./skywire-visor ./skywire-cli ./setup-node

clean-windows:
powershell -Command Remove-Item -Path ./apps -Force -Recurse
powershell -Command Remove-Item -Path .\skywire-visor.exe,.\skywire-cli.exe,.\setup-node.exe -Force

install: ## Install `skywire-visor`, `skywire-cli`, `setup-node`
${OPTS} go install ${BUILD_OPTS} ./cmd/skywire-visor ./cmd/skywire-cli ./cmd/setup-node

install-windows:
powershell 'Get-ChildItem .\cmd | % { ${OPTS} go install ${BUILD_OPTS} ./ $$_.FullName }'

install-static: ## Install `skywire-visor`, `skywire-cli`, `setup-node`
${STATIC_OPTS} go install -trimpath --ldflags '-linkmode external -extldflags "-static" -buildid=' ./cmd/skywire-visor ./cmd/skywire-cli ./cmd/setup-node

Expand All @@ -88,6 +103,10 @@ install-linters: ## Install linters
${OPTS} go get -u golang.org/x/tools/cmd/goimports
${OPTS} go get -u github.com/incu6us/goimports-reviser/v2

install-linters-windows:
${OPTS} go get -u github.com/golangci/golangci-lint/cmd/[email protected]
${OPTS} go get -u golang.org/x/tools/cmd/goimports

tidy: ## Tidies and vendors dependencies.
${OPTS} go mod tidy -v

Expand All @@ -97,29 +116,43 @@ format: tidy ## Formats the code. Must have goimports and goimports-reviser inst
${OPTS} goimports -w -local ${PROJECT_BASE} ./internal
find . -type f -name '*.go' -not -path "./vendor/*" -exec goimports-reviser -project-name ${PROJECT_BASE} -file-path {} \;

format-windows: tidy ## Formats the code. Must have goimports and goimports-reviser installed (use make install-linters).
${OPTS} goimports -w -local ${PROJECT_BASE} ./pkg
${OPTS} goimports -w -local ${PROJECT_BASE} ./cmd
${OPTS} goimports -w -local ${PROJECT_BASE} ./internal

dep: tidy ## Sorts dependencies
${OPTS} go mod vendor -v

host-apps: ## Build app
${OPTS} go build ${BUILD_OPTS} -o ./apps/skychat ./cmd/apps/skychat
${OPTS} go build ${BUILD_OPTS} -o ./apps/skysocks ./cmd/apps/skysocks
${OPTS} go build ${BUILD_OPTS} -o ./apps/skysocks-client ./cmd/apps/skysocks-client
${OPTS} go build ${BUILD_OPTS} -o ./apps/vpn-server ./cmd/apps/vpn-server
${OPTS} go build ${BUILD_OPTS} -o ./apps/vpn-client ./cmd/apps/vpn-client
mkdir -p ./apps
${OPTS} go build ${BUILD_OPTS} -o ./apps/ ./cmd/apps/skychat
${OPTS} go build ${BUILD_OPTS} -o ./apps/ ./cmd/apps/skysocks
${OPTS} go build ${BUILD_OPTS} -o ./apps/ ./cmd/apps/skysocks-client
${OPTS} go build ${BUILD_OPTS} -o ./apps/ ./cmd/apps/vpn-server
${OPTS} go build ${BUILD_OPTS} -o ./apps/ ./cmd/apps/vpn-client

host-apps-windows:
powershell -Command new-item .\apps -itemtype directory -force
powershell 'Get-ChildItem .\cmd\apps | % { ${OPTS} go build ${BUILD_OPTS} -o ./apps $$_.FullName }'

# Static Apps
host-apps-static: ## Build app
${STATIC_OPTS} go build -trimpath --ldflags '-linkmode external -extldflags "-static" -buildid=' -o ./apps/skychat ./cmd/apps/skychat
${STATIC_OPTS} go build -trimpath --ldflags '-linkmode external -extldflags "-static" -buildid=' -o ./apps/skysocks ./cmd/apps/skysocks
${STATIC_OPTS} go build -trimpath --ldflags '-linkmode external -extldflags "-static" -buildid=' -o ./apps/skysocks-client ./cmd/apps/skysocks-client
${STATIC_OPTS} go build -trimpath --ldflags '-linkmode external -extldflags "-static" -buildid=' -o ./apps/vpn-server ./cmd/apps/vpn-server
${STATIC_OPTS} go build -trimpath --ldflags '-linkmode external -extldflags "-static" -buildid=' -o ./apps/vpn-client ./cmd/apps/vpn-client
mkdir -p ./apps
${STATIC_OPTS} go build -trimpath --ldflags '-linkmode external -extldflags "-static" -buildid=' -o ./apps/ ./cmd/apps/skychat
${STATIC_OPTS} go build -trimpath --ldflags '-linkmode external -extldflags "-static" -buildid=' -o ./apps/ ./cmd/apps/skysocks
${STATIC_OPTS} go build -trimpath --ldflags '-linkmode external -extldflags "-static" -buildid=' -o ./apps/ ./cmd/apps/skysocks-client
${STATIC_OPTS} go build -trimpath --ldflags '-linkmode external -extldflags "-static" -buildid=' -o ./apps/ ./cmd/apps/vpn-server
${STATIC_OPTS} go build -trimpath --ldflags '-linkmode external -extldflags "-static" -buildid=' -o ./apps/ ./cmd/apps/vpn-client

# Bin
bin: ## Build `skywire-visor`, `skywire-cli`
${OPTS} go build ${BUILD_OPTS} -o ./skywire-visor ./cmd/skywire-visor
${OPTS} go build ${BUILD_OPTS} -o ./skywire-cli ./cmd/skywire-cli
${OPTS} go build ${BUILD_OPTS} -o ./setup-node ./cmd/setup-node
${OPTS} go build ${BUILD_OPTS} -o ./ ./cmd/skywire-visor
${OPTS} go build ${BUILD_OPTS} -o ./ ./cmd/skywire-cli
${OPTS} go build ${BUILD_OPTS} -o ./ ./cmd/setup-node

bin-windows:
powershell 'Get-ChildItem .\cmd | % { ${OPTS} go build ${BUILD_OPTS} -o ./ $$_.FullName }'

# Static Bin
bin-static: ## Build `skywire-visor`, `skywire-cli`
Expand Down
31 changes: 1 addition & 30 deletions cmd/skywire-visor/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ import (
"net/http"
_ "net/http/pprof" // nolint:gosec // https://golang.org/doc/diagnostics.html#profiling
"os"
"os/exec"
"strings"
"syscall"
"time"

"github.com/pkg/profile"
Expand Down Expand Up @@ -77,34 +75,7 @@ var rootCmd = &cobra.Command{
WithField("parent_systemd", restartCtx.ParentSystemd()).
Debugf("Process info")

// Versions v0.2.3 and below return 0 exit-code after update and do not trigger systemd to restart a process
// and therefore do not support restart via systemd.
// If --delay flag is passed, version is v0.2.3 or below.
// Systemd has PID 1. If PPID is not 1 and PPID of parent process is 1, then
// this process is a child process that is run after updating by a skywire-visor that is run by systemd.
if delayDuration != 0 && !restartCtx.Systemd() && restartCtx.ParentSystemd() {
// As skywire-visor checks if new process is run successfully in `restart.DefaultCheckDelay` after update,
// new process should be alive after `restart.DefaultCheckDelay`.
time.Sleep(restart.DefaultCheckDelay)

// When a parent process exits, systemd kills child processes as well,
// so a child process can ask systemd to restart service between after restart.DefaultCheckDelay
// but before (restart.DefaultCheckDelay + restart.extraWaitingTime),
// because after that time a parent process would exit and then systemd would kill its children.
// In this case, systemd would kill both parent and child processes,
// then restart service using an updated binary.
cmd := exec.Command("systemctl", "restart", "skywire-visor") // nolint:gosec
if err := cmd.Run(); err != nil {
log.WithError(err).Errorf("Failed to restart skywire-visor service")
} else {
log.WithError(err).Infof("Restarted skywire-visor service")
}

// Detach child from parent.
if _, err := syscall.Setsid(); err != nil {
log.WithError(err).Errorf("Failed to call setsid()")
}
}
detachProcess(delayDuration, log)

time.Sleep(delayDuration)

Expand Down
45 changes: 45 additions & 0 deletions cmd/skywire-visor/commands/subprocess_unix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// +build !windows

package commands

import (
"os/exec"
"syscall"
"time"

"github.com/sirupsen/logrus"

"github.com/skycoin/skywire/pkg/restart"
)

func detachProcess(delayDuration time.Duration, log logrus.FieldLogger) {
// Versions v0.2.3 and below return 0 exit-code after update and do not trigger systemd to restart a process
// and therefore do not support restart via systemd.
// If --delay flag is passed, version is v0.2.3 or below.
// Systemd has PID 1. If PPID is not 1 and PPID of parent process is 1, then
// this process is a child process that is run after updating by a skywire-visor that is run by systemd.
if delayDuration != 0 && !restartCtx.Systemd() && restartCtx.ParentSystemd() {
// As skywire-visor checks if new process is run successfully in `restart.DefaultCheckDelay` after update,
// new process should be alive after `restart.DefaultCheckDelay`.
time.Sleep(restart.DefaultCheckDelay)

// When a parent process exits, systemd kills child processes as well,
// so a child process can ask systemd to restart service between after restart.DefaultCheckDelay
// but before (restart.DefaultCheckDelay + restart.extraWaitingTime),
// because after that time a parent process would exit and then systemd would kill its children.
// In this case, systemd would kill both parent and child processes,
// then restart service using an updated binary.
cmd := exec.Command("systemctl", "restart", "skywire-visor") // nolint:gosec
if err := cmd.Run(); err != nil {
log.WithError(err).Errorf("Failed to restart skywire-visor service")
} else {
log.WithError(err).Infof("Restarted skywire-visor service")
}

// Detach child from parent.
if _, err := syscall.Setsid(); err != nil {
log.WithError(err).Errorf("Failed to call setsid()")
}
}

}
12 changes: 12 additions & 0 deletions cmd/skywire-visor/commands/subprocess_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// +build windows

package commands

import (
"time"

"github.com/sirupsen/logrus"
)

func detachProcess(_ time.Duration, _ logrus.FieldLogger) {
}
21 changes: 11 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,37 @@ require (
github.com/gorilla/securecookie v1.1.1
github.com/json-iterator/go v1.1.11 // indirect
github.com/klauspost/reedsolomon v1.9.9 // indirect
github.com/mattn/go-isatty v0.0.13 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.2
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/mholt/archiver/v3 v3.3.0
github.com/mmcloughlin/avo v0.0.0-20200523190732-4439b6b2c061 // indirect
github.com/pkg/profile v1.5.0
github.com/schollz/progressbar/v2 v2.15.0
github.com/shirou/gopsutil v2.20.5+incompatible
github.com/sirupsen/logrus v1.8.1
github.com/skycoin/dmsg v0.0.0-20210607131549-0c02e58ac5ee
github.com/skycoin/dmsg v0.0.0-20201216183836-dae8a7acfc14
github.com/skycoin/skycoin v0.27.1
github.com/skycoin/yamux v0.0.0-20200803175205-571ceb89da9f
github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8
github.com/spf13/cobra v1.0.0
github.com/stretchr/testify v1.6.1
github.com/spf13/cobra v0.0.5
github.com/stretchr/testify v1.4.0
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635
github.com/templexxx/cpufeat v0.0.0-20180724012125-cef66df7f161 // indirect
github.com/templexxx/xor v0.0.0-20191217153810-f85b25db303b // indirect
github.com/tjfoc/gmsm v1.3.2 // indirect
github.com/tjfoc/gmsm v1.4.0 // indirect
github.com/toqueteos/webbrowser v1.2.0
github.com/xtaci/kcp-go v5.4.20+incompatible
github.com/xtaci/lossyconn v0.0.0-20200209145036-adba10fffc37 // indirect
go.etcd.io/bbolt v1.3.5
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a // indirect
go.etcd.io/bbolt v1.3.6
golang.org/x/crypto v0.0.0-20201208171446-5f87f3452ae9 // indirect
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4
golang.org/x/sys v0.0.0-20210608053332-aa57babbf139
golang.org/x/term v0.0.0-20210503060354-a79de5458b56 // indirect
golang.org/x/tools v0.1.2 // indirect
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22
golang.org/x/tools v0.1.3 // indirect
golang.zx2c4.com/wireguard v0.0.20200320
nhooyr.io/websocket v1.8.2
)

// Uncomment for tests with alternate branches of 'dmsg'
//replace github.com/skycoin/dmsg => ../dmsg

replace github.com/skycoin/dmsg => github.com/alexadhy/dmsg v0.0.0-20210622015552-8649ac936224
Loading