编译hyperledger fabric官方源码

来源:互联网 发布:ubuntu当个人日常使用 编辑:程序博客网 时间:2024/06/08 03:06

开发环境介绍

  • 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 directoryMakefile:263: recipe for target 'build/image/ccenv/payload' failedmake: *** [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-goroot@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.0Makefile:111: recipe for target 'license' failedmake: *** [license] Error 1

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

安装 gocov

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

安装 gocov-xml

gopm get -g -d github.com/AlekSi/gocov-xmlgo 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

过程就不贴了。