Bladeren bron

Improved build

Luis Figueiredo 8 jaren geleden
bovenliggende
commit
52d2ec1d1c

BIN
DIST/bin/server


+ 2 - 0
backend/.gitignore

@@ -0,0 +1,2 @@
+vendor
+pkg

BIN
backend/bin/server


BIN
backend/pkg/linux_amd64/simple-web/core.a


+ 11 - 0
backend/src/hexasoftware/lib/prettylog/global/register.go

@@ -0,0 +1,11 @@
+package global
+
+import (
+	"hexasoftware/lib/prettylog"
+	"log"
+)
+
+func init() {
+	log.SetFlags(0)
+	log.SetOutput(prettylog.New())
+}

+ 55 - 0
backend/src/hexasoftware/lib/prettylog/prettylog.go

@@ -0,0 +1,55 @@
+package prettylog
+
+import (
+	"fmt"
+	"log"
+	"runtime"
+	"strings"
+	"time"
+)
+
+type PrettyLogWritter struct {
+	lastTime time.Time
+	counter  int64
+}
+
+func New() *PrettyLogWritter {
+	return &PrettyLogWritter{time.Now(), 0}
+}
+
+func (this *PrettyLogWritter) Write(b []byte) (int, error) {
+
+	/*{
+		for i := 0; i < 6; i++ {
+			ptr, _, _, _ := runtime.Caller(i)
+			fname := runtime.FuncForPC(ptr).Name()
+			fmt.Println("Stack:", fname)
+		}
+	}*/
+
+	ptr, _, line, _ := runtime.Caller(3)
+	tname := runtime.FuncForPC(ptr).Name()
+	li := strings.LastIndex(tname, "/")
+	fname := tname[li+1:]
+
+	timeDiff := time.Since(this.lastTime)
+
+	var fduration float64 = float64(timeDiff.Nanoseconds()) / 1000000.0
+
+	msg := fmt.Sprintf("[%d:\033[34m%s\033[0m (\033[33m%s:%d\033[0m) \033[90m+%.2f/ms\033[0m]: %s",
+		this.counter,
+		time.Now().Format("2006-01-02 15:04:05"),
+		fname,
+		line,
+		fduration,
+		string(b),
+	)
+	this.lastTime = time.Now()
+	this.counter++
+
+	return fmt.Print(msg)
+}
+
+func CreateLogger() *log.Logger {
+	return log.New(New(), "", 0)
+}

+ 1 - 0
backend/src/hexasoftware/x/hqi

@@ -0,0 +1 @@
+Subproject commit 02040cb96ee6e0d582770e600d77fdecb8e7c142

+ 11 - 7
build.sh

@@ -5,20 +5,24 @@ if [ "x$1" == "xdocker" ] ; then
 	exit
 fi
 
+
 mkdir -p DIST/bin
 mkdir -p DIST/public
 
-echo "Building backend..."
-# Backend
-pushd DIST/bin
-CGO_ENABLED=0 go build  ../../backend/src/cmd/simple-cli
-CGO_ENABLED=0 go build ../../backend/src/cmd/server
+GOPATH=$(pwd)/backend/vendor:$(pwd)/backend
+
+echo "GOPATH is:" $GOPATH
+
+echo "Fetching go dependencies:" $GOPATH
+pushd backend/src/simple-web/cmd/server
+go get -v
 popd
 
+# Backend
+echo "Building backend..."
+CGO_ENABLED=0 go build -o DIST/bin/server backend/src/simple-web/cmd/server/server.go
 echo "Building frontend..."
-# Frontend
 pushd frontend/web
 node build/build.js
 popd
 
-