centos 7.2 下为erlang添加protobuffs
来源:互联网 发布:红外光谱数据库下载 编辑:程序博客网 时间:2024/06/16 00:44
安装前提:
1.已经安装好erlang otp
2.配置了rebar (配置方法:http://www.cnblogs.com/panfeng412/archive/2011/08/14/2137990.html)
3.安装git (centos:yum install git ubantu:sudo apt install git)
[作者:点A点C]
在rebar.config中的deps中加入protobuffs
{deps, [{protobuffs,".*",{git,"https://github.com/basho/erlang_protobuffs.git",""}},
{'proper', ".*", {git,"https://github.com/manopapad/proper.git", "master"}},
{'goldrush',".*",{git,"https://github.com/extend/goldrush.git","mastter"}},
{'lager',".*",{git, "https://github.com/erlang-lager/lager.git","master"}}]}.
然后执行 ./rebar get-deps
在get-deps过程中会下载 meck(protobuffs的依赖库)和protobuffs两个依赖库。
到这里之后你可以在src下新建一个test.proto文件
test.proto文件:
message Person {
required int32 age = 1;
required string name = 2;
}
message Family {
repeated Person person =1;
}
然后执行编译命令 ./rebar clean compile
会发现在rebar 同级目录生成了一个include文件夹,里面包含一个test.hrl的文件,打开会看到如下:
这就是proto编译生成头文件。
其实到这里整个protobuffs就算可以用了,但我们为了结构的清晰不希望所有的文件都放在src中,(我希望我的协议文件都在在和src同级的proto文件夹下)。
因为rebar的文档中并没有写如何配置,只是给出了src_dirs这个参数可以设置其他的源文件的地址,但直接在rebar.config中加入{src_dirs,["proto"]}并没有用,然后在rebar源码中找到关于对protobuffs的编译代码,rebar_proto_comiler.erl文件
这里设置了读取config的proto_opts项,然后下面会有src_dirs,这里的如果没有配置的时候默认是src文件夹,所以其实src_dirs是配在proto_opts下的,参照rebar.config.sample,
这是例子中给出的配置:
然后我将自己的也配置成了下面这样,
完成之后,在src同级目录下新建一个proto文件夹,然后在里面创建*.proto文件,再执行./rebar compile 的时候就会编译proto下的协议文件。
[作者:点A点C]
阅读全文
0 0
- centos 7.2 下为erlang添加protobuffs
- centos7.2 下为erlang添加lager日志框架
- centos 下为PHP添加svn扩展
- centos 下为php添加mongodb扩展
- centos下为php添加gd扩展
- centos下为php添加pdo_mysql扩展
- centos下为redis添加service
- CentOs下编译安装erlang
- centOS下,源码安装erlang
- CentOS下为xxx用户添加sudo 权限
- Centos 6 下安装 erlang 手记
- Centos 6 下安装 erlang 手记
- CentOS下安装Erlang和RabbitMQ
- 在CentOS下,源码安装Erlang:
- Centos 6 下安装 erlang 手记
- Centos 6 下安装 erlang 手记
- vmware下centos 7.2添加硬盘使用
- CentOS下添加端口
- 初涉UnityEditor
- jQuery知识总结
- 第六章 跟踪用户动作
- django的sql返回结果QuerySets
- Linux nginx安装步骤
- centos 7.2 下为erlang添加protobuffs
- 中钰睿泓浅谈设计师的创新
- 使用IntelliJ IDEA开发SpringMVC网站(二)框架配置
- 云客Drupal8源码分析之配置系统Configuration(四):配置schema与类型化
- 使用Mycat操作Oracle数据库(三) -- mycat-eye监控mycat性能参数
- UI设计师自学如何区分临摹和抄袭(上)
- MySQL二阶段提交以及xtrabackup如何保证备份不丢失数据
- 编译完Android后,执行emulator提示“emulator:未找到命令”
- 计算机基础: 使用"大白菜"进行安装系统