编译hyperledger fabric官方源码

开发环境介绍

  • UBUNTU 16.04 LTS
  • docker
  • docker-compose
  • git
  • go 1.8以上

进入fabric源码目录,

$GOPATH/src/github.com/hyperledger/fabric

编译,

make dist-clean all

我的环境报错,

cp: cannot stat 'build/docker/gotools/bin/protoc-gen-go': No such file or directory
Makefile:263: recipe for target 'build/image/ccenv/payload' failed
make: *** [build/image/ccenv/payload] Error 1

这个问题是因为fabric环境下找不到protoc-gen-go这个执行文件,解决方法是手动生成。


编译生成protoc-gen-go

root@pony-virtual-machine:~/gopath/src/github.com# gopm get -g -d github.com/golang/protobuf/protoc-gen-go

root@pony-virtual-machine:~/gopath/src/github.com/golang# go install github.com/golang/protobuf/protoc-gen-go

当然前提是你的环境支撑gopm命令。

到$GOPATH/bin目录下可以找到protoc-gen-go,把这个文件拷贝到刚才报错的目录

root@pony-virtual-machine:~/gopath/bin# cp protoc-gen-go /root/gopath/src/github.com/hyperledger/fabric/build/docker/gotools/bin/

这里分割点


再次编译。编译的时间有点久。最后编译报错, 原因我暂不清楚,不过不影响后面的操作。

the following files are missing SPDX-License-Identifier headers:
(standard input)

Please replace the Apache license header comment text with:
SPDX-License-Identifier: Apache-2.0
Makefile:111: recipe for target 'license' failed
make: *** [license] Error 1

在继续之前,还要安装gocov和gocov-xml,因为下面执行单元测试时会用到这两个执行文件。

安装 gocov

gopm get -g -d golang.org/x/tools/cover
gopm get -g -d github.com/axw/gocov/gocov
go install github.com/axw/gocov/gocov

安装 gocov-xml

gopm get -g -d github.com/AlekSi/gocov-xml
go install github.com/AlekSi/gocov-xml

然后拷贝到fabric目录下,

root@pony-virtual-machine:~/gopath/bin# cp gocov gocov-xml /root/gopath/src/github.com/hyperledger/fabric/build/docker/gotools/bin/

执行单元测试

make unit-test

过程就不贴了。

猜你喜欢

转载自blog.csdn.net/pony_maggie/article/details/78646185
今日推荐