Fixed windows build.
authorSebastien Douheret <sebastien.douheret@iot.bzh>
Tue, 17 Oct 2017 11:52:29 +0000 (13:52 +0200)
committerSebastien Douheret <sebastien.douheret@iot.bzh>
Tue, 17 Oct 2017 11:52:29 +0000 (13:52 +0200)
Makefile
gdb-common_darwin.go
gdb-common_linux.go
gdb-common_windows.go
gdb-native.go
main.go

index 017cb29..ed58a29 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@
 
 # Application Version
 VERSION := 0.1.0
-
+TARGET=xds-gdb
 
 # Retrieve git tag/commit to set sub-version string
 ifeq ($(origin SUB_VERSION), undefined)
@@ -22,7 +22,7 @@ endif
 HOST_GOOS=$(shell go env GOOS)
 HOST_GOARCH=$(shell go env GOARCH)
 ARCH=$(HOST_GOOS)-$(HOST_GOARCH)
-REPOPATH=github.com/iotbzh/xds-gdb
+REPOPATH=github.com/iotbzh/$(TARGET)
 
 EXT=
 ifeq ($(HOST_GOOS), windows)
@@ -44,22 +44,31 @@ VERBOSE_2 := -v -x
 
 # Release or Debug mode
 ifeq ($(filter 1,$(RELEASE) $(REL)),)
-       GORELEASE=
+       GO_LDFLAGS=
+       # disable compiler optimizations and inlining
+       GO_GCFLAGS=-N -l
        BUILD_MODE="Debug mode"
 else
        # optimized code without debug info
-       GORELEASE= -s -w
+       GO_LDFLAGS=-s -w
+       GO_GCFLAGS=
        BUILD_MODE="Release mode"
 endif
 
 
+ifeq ($(SUB_VERSION), )
+       PACKAGE_ZIPFILE := $(TARGET)_$(ARCH)-v$(VERSION).zip
+else
+       PACKAGE_ZIPFILE := $(TARGET)_$(ARCH)-v$(VERSION)_$(SUB_VERSION).zip
+endif
+
 .PHONY: all
-all: build
+all: vendor build
 
 .PHONY: build
-build: vendor
-       @echo "### Build xds-gdb (version $(VERSION), subversion $(SUB_VERSION)) - $(BUILD_MODE)";
-       @cd $(ROOT_SRCDIR); $(BUILD_ENV_FLAGS) go build $(VERBOSE_$(V)) -i -o $(BINDIR)/xds-gdb$(EXT) -ldflags "$(GORELEASE) -X main.AppVersion=$(VERSION) -X main.AppSubVersion=$(SUB_VERSION)" .
+build:
+       @echo "### Build $(TARGET) (version $(VERSION), subversion $(SUB_VERSION)) - $(BUILD_MODE)";
+       @cd $(ROOT_SRCDIR); $(BUILD_ENV_FLAGS) go build $(VERBOSE_$(V)) -i -o $(BINDIR)/$(TARGET)$(EXT) -ldflags "$(GO_LDFLAGS) -X main.AppVersion=$(VERSION) -X main.AppSubVersion=$(SUB_VERSION)" -gcflags "$(GO_GCFLAGS)" .
 
 test: tools/glide
        go test --race $(shell ./tools/glide novendor)
@@ -81,18 +90,18 @@ distclean: clean
 release:
        RELEASE=1 make -f $(ROOT_SRCDIR)/Makefile clean build
 
-package: clean build
-       @mkdir -p $(PACKAGE_DIR)/xds-gdb
-       @cp -a $(BINDIR)/*gdb$(EXT) $(PACKAGE_DIR)/xds-gdb
-       @cd $(PACKAGE_DIR) && zip  --symlinks -r $(ROOT_SRCDIR)/xds-gdb_$(ARCH)-v$(VERSION)_$(SUB_VERSION).zip ./xds-gdb
+package: clean vendor build
+       @mkdir -p $(PACKAGE_DIR)/$(TARGET)
+       @cp -a $(BINDIR)/*gdb$(EXT) $(PACKAGE_DIR)/$(TARGET)
+       @cp -r $(ROOT_SRCDIR)/conf.d $(ROOT_SRCDIR)/scripts $(PACKAGE_DIR)/$(TARGET)
+       cd $(PACKAGE_DIR) && zip -r $(ROOT_SRCDIR)/$(PACKAGE_ZIPFILE) ./$(TARGET)
 
 .PHONY: package-all
 package-all:
        @echo "# Build linux amd64..."
        GOOS=linux GOARCH=amd64 RELEASE=1 make -f $(ROOT_SRCDIR)/Makefile package
        @echo "# Build windows amd64..."
-#      GOOS=windows GOARCH=amd64 RELEASE=1 make -f $(ROOT_SRCDIR)/Makefile package
-       @echo " WARNING: build on Windows not supported for now."
+       GOOS=windows GOARCH=amd64 RELEASE=1 make -f $(ROOT_SRCDIR)/Makefile package
        @echo "# Build darwin amd64..."
        GOOS=darwin GOARCH=amd64 RELEASE=1 make -f $(ROOT_SRCDIR)/Makefile package
        make -f $(ROOT_SRCDIR)/Makefile clean
index d167c5d..dff1c2b 100644 (file)
@@ -40,3 +40,7 @@ func tcgetattr(fd uintptr, termios *syscall.Termios) error {
        }
        return nil
 }
+
+func isIgnoredSignal(sig os.Signal) bool {
+       return (sig == syscall.SIGWINCH)
+}
index a2f4bf6..ad64f96 100644 (file)
@@ -35,3 +35,7 @@ func tcgetattr(fd uintptr, termios *syscall.Termios) error {
        }
        return nil
 }
+
+func isIgnoredSignal(sig os.Signal) bool {
+       return (sig == syscall.SIGWINCH)
+}
index b233943..b2ceb73 100644 (file)
@@ -1,7 +1,24 @@
 package main
 
-import "syscall"
+import (
+       "fmt"
+       "os"
+       "syscall"
+
+       "github.com/Sirupsen/logrus"
+)
 
 const (
        syscallEBADE = syscall.EBADE
 )
+
+func NewGdbNative(log *logrus.Logger, args []string, env []string) *GdbXds {
+       fmt.Printf("Native gdb debug mode not supported on Windows !")
+       os.Exit(int(syscall.ENOSYS))
+
+       return nil
+}
+
+func isIgnoredSignal(sig os.Signal) bool {
+       return false
+}
index 4bae3d3..e83f9ef 100644 (file)
@@ -1,3 +1,5 @@
+// +build !windows
+
 package main
 
 import (
diff --git a/main.go b/main.go
index 87de43c..e7f14d6 100644 (file)
--- a/main.go
+++ b/main.go
@@ -461,9 +461,7 @@ endloop:
                        for {
                                sig := <-sigs
 
-                               // FIXME: skip Window Changed signal for now
-                               if sig == syscall.SIGWINCH {
-                                       log.Debugf("SKIP signal Window Changed")
+                               if isIgnoredSignal(sig) {
                                        return
                                }