github.com/ethereumproject/go-ethereum@v5.5.2+incompatible/scripts/build_sputnikvm.sh (about) 1 #!/usr/bin/env bash 2 3 set -e 4 5 OUTPUT="$1" 6 7 if [ ! "$OUTPUT" == "build" ] && [ ! "$OUTPUT" == "install" ]; then 8 echo "Specify 'install' or 'build' as first argument." 9 exit 1 10 else 11 echo "With SputnikVM, running geth $OUTPUT ..." 12 fi 13 14 installrust() { 15 curl https://sh.rustup.rs -sSf | sh 16 source $HOME/.cargo/env 17 } 18 19 # Prompt to install rust and cargo if not already installed. 20 if hash cargo 2>/dev/null; then 21 echo "Cargo installed OK, continuing" 22 else 23 while true; do 24 read -p "Install/build with SputnikVM requires Rust and cargo to be installed. Would you like to install them? [Yy|Nn]" yn 25 case $yn in 26 [yY]* ) installrust; echo "Rust and cargo have been installed and temporarily added to your PATH"; break;; 27 [nN]* ) echo "Can't compile SputniKVM. Exiting."; exit 0;; 28 esac 29 done 30 fi 31 32 OS=`uname -s` 33 34 geth_path="github.com/ethereumproject/go-ethereum" 35 sputnik_path="github.com/ETCDEVTeam/sputnikvm-ffi" 36 sputnik_dir="$GOPATH/src/$geth_path/vendor/$sputnik_path" 37 38 geth_bindir="$GOPATH/src/$geth_path/bin" 39 40 echo "Building SputnikVM" 41 make -C "$sputnik_dir/c" 42 43 echo "Doing geth $OUTPUT ..." 44 cd "$GOPATH/src/$geth_path" 45 46 LDFLAGS="$sputnik_dir/c/libsputnikvm.a " 47 case $OS in 48 "Linux") 49 LDFLAGS+="-ldl" 50 ;; 51 52 "Darwin") 53 LDFLAGS+="-ldl -lresolv" 54 ;; 55 56 CYGWIN*|MINGW32*|MSYS*) 57 LDFLAGS="-Wl,--allow-multiple-definition $sputnik_dir/c/sputnikvm.lib -lws2_32 -luserenv" 58 ;; 59 esac 60 61 62 if [ "$OUTPUT" == "install" ]; then 63 CGO_LDFLAGS=$LDFLAGS go install -ldflags '-X main.Version='$(git describe --tags) -tags="sputnikvm netgo" ./cmd/geth 64 elif [ "$OUTPUT" == "build" ]; then 65 mkdir -p "$geth_bindir" 66 CGO_LDFLAGS=$LDFLAGS go build -ldflags '-X main.Version='$(git describe --tags) -o $geth_bindir/geth -tags="sputnikvm netgo" ./cmd/geth 67 fi 68