From 55a7110af2b1bb1d729ee40a3b8c9ba2244538ed Mon Sep 17 00:00:00 2001 From: Jianping Wu Date: Sat, 9 Mar 2019 00:24:32 -0800 Subject: [PATCH] Fixed cmake build. --- .gitignore | 1 + .vscode/launch.json | 17 +++++++++++++++++ CMakeLists.txt | 9 ++------- build/env.sh | 32 -------------------------------- cnutil/cnutil.go | 2 +- main.go | 4 ++-- rpc/rpc.go | 2 +- stratum/api.go | 4 ++-- stratum/blocks.go | 2 +- stratum/handlers.go | 2 +- stratum/miner.go | 4 ++-- stratum/stratum.go | 16 ++++++++-------- util/util.go | 2 +- 13 files changed, 39 insertions(+), 58 deletions(-) create mode 100644 .vscode/launch.json delete mode 100755 build/env.sh diff --git a/.gitignore b/.gitignore index 515cf56..44198b5 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ Makefile *.a *.so *.dylib +keva-stratum # Configs config.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..59c6cb5 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,17 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Launch", + "type": "go", + "request": "launch", + "mode": "exec", + "program": "${workspaceFolder}/build/bin/keva-stratum", + "env": {}, + "args": [] + } + ] +} \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b7ab60..86ef60e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,11 +1,6 @@ cmake_minimum_required (VERSION 2.8.11) -project(pool) -add_subdirectory(cnutil) +project(keva-stratum) -add_custom_command( - OUTPUT build/bin - COMMAND build/env.sh go get -v ./... -) +add_subdirectory(cnutil) -add_custom_target(build ALL DEPENDS cnutil ${CMAKE_CURRENT_BINARY_DIR}/build/bin) diff --git a/build/env.sh b/build/env.sh deleted file mode 100755 index cc1ef1e..0000000 --- a/build/env.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh - -set -e - -if [ ! -f "build/env.sh" ]; then - echo "$0 must be run from the root of the repository." - exit 2 -fi - -# Create fake Go workspace if it doesn't exist yet. -workspace="$PWD/build/_workspace" -root="$PWD" -ethdir="$workspace/src/github.com/kevacoin-project" -if [ ! -L "$ethdir/keva-stratum" ]; then - mkdir -p "$ethdir" - cd "$ethdir" - ln -s ../../../../../. keva-stratum - cd "$root" -fi - -# Set up the environment to use the workspace. -# Also add Godeps workspace so we build using canned dependencies. -GOPATH="$workspace" -GOBIN="$PWD/build/bin" -export GOPATH GOBIN - -# Run the command inside the workspace. -cd "$ethdir/keva-stratum" -PWD="$ethdir/keva-stratum" - -# Launch the arguments with the configured environment. -exec "$@" diff --git a/cnutil/cnutil.go b/cnutil/cnutil.go index 5830690..6326954 100644 --- a/cnutil/cnutil.go +++ b/cnutil/cnutil.go @@ -1,7 +1,7 @@ package cnutil // #cgo CFLAGS: -std=c11 -D_GNU_SOURCE -// #cgo LDFLAGS: -L${SRCDIR} -lcnutil -Wl,-rpath ${SRCDIR} -lstdc++ +// #cgo LDFLAGS: -L${SRCDIR} -Wl,-rpath=\$ORIGIN/cnutil -lcnutil -Wl,-rpath ${SRCDIR} -lstdc++ // #include // #include "src/cnutil.h" import "C" diff --git a/main.go b/main.go index 3628b38..d552f99 100644 --- a/main.go +++ b/main.go @@ -10,8 +10,8 @@ import ( "runtime" "time" - "github.com/kevacoin-project/keva-stratum/pool" - "github.com/kevacoin-project/keva-stratum/stratum" + "./pool" + "./stratum" "github.com/goji/httpauth" "github.com/gorilla/mux" diff --git a/rpc/rpc.go b/rpc/rpc.go index 53caa40..4c5ec46 100644 --- a/rpc/rpc.go +++ b/rpc/rpc.go @@ -11,7 +11,7 @@ import ( "sync/atomic" "time" - "github.com/kevacoin-project/keva-stratum/pool" + "../pool" ) type RPCClient struct { diff --git a/stratum/api.go b/stratum/api.go index e976913..ad67456 100644 --- a/stratum/api.go +++ b/stratum/api.go @@ -6,8 +6,8 @@ import ( "sync/atomic" "time" - "github.com/kevacoin-project/keva-stratum/rpc" - "github.com/kevacoin-project/keva-stratum/util" + "../rpc" + "../util" ) func (s *StratumServer) StatsIndex(w http.ResponseWriter, r *http.Request) { diff --git a/stratum/blocks.go b/stratum/blocks.go index 7dd00f0..c6dde64 100644 --- a/stratum/blocks.go +++ b/stratum/blocks.go @@ -7,7 +7,7 @@ import ( "log" "math/big" - "github.com/kevacoin-project/keva-stratum/cnutil" + "../cnutil" ) type BlockTemplate struct { diff --git a/stratum/handlers.go b/stratum/handlers.go index 4b907e9..7632fc5 100644 --- a/stratum/handlers.go +++ b/stratum/handlers.go @@ -6,7 +6,7 @@ import ( "strings" "sync/atomic" - "github.com/kevacoin-project/keva-stratum/util" + "../util" ) var noncePattern *regexp.Regexp diff --git a/stratum/miner.go b/stratum/miner.go index c10cfab..ee188a7 100644 --- a/stratum/miner.go +++ b/stratum/miner.go @@ -10,8 +10,8 @@ import ( "sync/atomic" "time" - "github.com/kevacoin-project/keva-stratum/cnutil" - "github.com/kevacoin-project/keva-stratum/util" + "../cnutil" + "../util" ) type Job struct { diff --git a/stratum/stratum.go b/stratum/stratum.go index c934b7e..9e49de0 100644 --- a/stratum/stratum.go +++ b/stratum/stratum.go @@ -13,9 +13,9 @@ import ( "sync/atomic" "time" - "github.com/kevacoin-project/keva-stratum/pool" - "github.com/kevacoin-project/keva-stratum/rpc" - "github.com/kevacoin-project/keva-stratum/util" + "../pool" + "../rpc" + "../util" ) type StratumServer struct { @@ -53,11 +53,11 @@ type Endpoint struct { type Session struct { lastBlockHeight int64 sync.Mutex - conn *net.TCPConn - enc *json.Encoder - ip string - endpoint *Endpoint - validJobs []*Job + conn *net.TCPConn + enc *json.Encoder + ip string + endpoint *Endpoint + validJobs []*Job } const ( diff --git a/util/util.go b/util/util.go index b490f86..fc28939 100644 --- a/util/util.go +++ b/util/util.go @@ -6,7 +6,7 @@ import ( "time" "unicode/utf8" - "github.com/kevacoin-project/keva-stratum/cnutil" + "../cnutil" ) var Diff1 = StringToBig("0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF")