Add new build system

This commit is contained in:
Sammy Libre 2017-09-09 22:24:42 +05:00
parent 0c71aab407
commit 36364a5e1e
16 changed files with 59 additions and 28 deletions

4
.gitignore vendored
View File

@ -17,4 +17,6 @@ Makefile
config.json config.json
testnet.json testnet.json
mainnet.json mainnet.json
pool
/build/_workspace/
/build/bin/

View File

@ -1,5 +1,5 @@
cmake_minimum_required (VERSION 2.8.11) cmake_minimum_required (VERSION 2.8.11)
project (pool) project(pool)
if (DEFINED ENV{MONERO_DIR}) if (DEFINED ENV{MONERO_DIR})
get_filename_component(MONERO_DIR $ENV{MONERO_DIR} ABSOLUTE) get_filename_component(MONERO_DIR $ENV{MONERO_DIR} ABSOLUTE)
@ -11,3 +11,10 @@ endif()
add_subdirectory(hashing) add_subdirectory(hashing)
add_subdirectory(cnutil) add_subdirectory(cnutil)
add_custom_command(
OUTPUT build/bin
COMMAND build/env.sh go get -v ./...
)
add_custom_target(build ALL DEPENDS hashing cnutil ${CMAKE_CURRENT_BINARY_DIR}/build/bin)

View File

@ -38,10 +38,6 @@ Compile Monero source (with shared libraries option):
Install Golang and required packages: Install Golang and required packages:
sudo apt-get install golang sudo apt-get install golang
export GOPATH=~/go
go get github.com/goji/httpauth
go get github.com/yvasiyarov/gorelic
go get github.com/gorilla/mux
Clone stratum: Clone stratum:
@ -52,7 +48,6 @@ Build stratum:
MONERO_DIR=/path/to/monero cmake . MONERO_DIR=/path/to/monero cmake .
make make
go build -o pool main.go
`MONERO_DIR=/path/to/monero` is optional, not needed if both `monero` and `monero-stratum` is in the same directory like `/opt/src/`. By default make will search for monero libraries in `../monero`. You can just run `cmake .`. `MONERO_DIR=/path/to/monero` is optional, not needed if both `monero` and `monero-stratum` is in the same directory like `/opt/src/`. By default make will search for monero libraries in `../monero`. You can just run `cmake .`.
@ -69,10 +64,6 @@ Compile Monero source:
Install Golang and required packages: Install Golang and required packages:
brew update && brew install go brew update && brew install go
export GOPATH=~/go
go get github.com/goji/httpauth
go get github.com/yvasiyarov/gorelic
go get github.com/gorilla/mux
Clone stratum: Clone stratum:
@ -83,16 +74,15 @@ Build stratum:
MONERO_DIR=/path/to/monero cmake . MONERO_DIR=/path/to/monero cmake .
make make
go build -o pool main.go
### Running Stratum ### Running Stratum
./pool config.json ./build/bin/monero-stratum config.json
If you need to bind to privileged ports and don't want to run from `root`: If you need to bind to privileged ports and don't want to run from `root`:
sudo apt-get install libcap2-bin sudo apt-get install libcap2-bin
sudo setcap 'cap_net_bind_service=+ep' pool sudo setcap 'cap_net_bind_service=+ep' /path/to/monero-stratum
## Configuration ## Configuration

32
build/env.sh Executable file
View File

@ -0,0 +1,32 @@
#!/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/sammy007"
if [ ! -L "$ethdir/monero-stratum" ]; then
mkdir -p "$ethdir"
cd "$ethdir"
ln -s ../../../../../. monero-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/monero-stratum"
PWD="$ethdir/monero-stratum"
# Launch the arguments with the configured environment.
exec "$@"

View File

@ -10,8 +10,8 @@ import (
"runtime" "runtime"
"time" "time"
"./go-pool/pool" "github.com/sammy007/monero-stratum/pool"
"./go-pool/stratum" "github.com/sammy007/monero-stratum/stratum"
"github.com/goji/httpauth" "github.com/goji/httpauth"
"github.com/gorilla/mux" "github.com/gorilla/mux"

View File

@ -11,7 +11,7 @@ import (
"sync/atomic" "sync/atomic"
"time" "time"
"../pool" "github.com/sammy007/monero-stratum/pool"
) )
type RPCClient struct { type RPCClient struct {

View File

@ -6,8 +6,8 @@ import (
"sync/atomic" "sync/atomic"
"time" "time"
"../rpc" "github.com/sammy007/monero-stratum/rpc"
"../util" "github.com/sammy007/monero-stratum/util"
) )
func (s *StratumServer) StatsIndex(w http.ResponseWriter, r *http.Request) { func (s *StratumServer) StatsIndex(w http.ResponseWriter, r *http.Request) {

View File

@ -6,7 +6,7 @@ import (
"encoding/hex" "encoding/hex"
"log" "log"
"../../cnutil" "github.com/sammy007/monero-stratum/cnutil"
) )
type BlockTemplate struct { type BlockTemplate struct {

View File

@ -6,7 +6,7 @@ import (
"strings" "strings"
"sync/atomic" "sync/atomic"
"../util" "github.com/sammy007/monero-stratum/util"
) )
var noncePattern *regexp.Regexp var noncePattern *regexp.Regexp

View File

@ -10,9 +10,9 @@ import (
"sync/atomic" "sync/atomic"
"time" "time"
"../../cnutil" "github.com/sammy007/monero-stratum/cnutil"
"../../hashing" "github.com/sammy007/monero-stratum/hashing"
"../util" "github.com/sammy007/monero-stratum/util"
) )
type Job struct { type Job struct {

View File

@ -12,9 +12,9 @@ import (
"sync/atomic" "sync/atomic"
"time" "time"
"../pool" "github.com/sammy007/monero-stratum/pool"
"../rpc" "github.com/sammy007/monero-stratum/rpc"
"../util" "github.com/sammy007/monero-stratum/util"
) )
type StratumServer struct { type StratumServer struct {

View File

@ -6,7 +6,7 @@ import (
"time" "time"
"unicode/utf8" "unicode/utf8"
"../../cnutil" "github.com/sammy007/monero-stratum/cnutil"
) )
var Diff1 = StringToBig("0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF") var Diff1 = StringToBig("0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF")