zoukankan      html  css  js  c++  java
  • 通过rebar构建erlang工程

    1.创建一个项目文件夹:

    mkdir myapp
    cd myapp
    

    2.下载rebar的二进制文件到这个项目的文件夹。

    git clone https://github.com/basho/rebar.git;
    

     3.使用rebar模板系统构建我们工程的“骨架”。

    rebar creat-app appid=myapp
    

     这条命令执行后会在项目文件中产生一个子文件夹“src”,其包含三个文件:

     myapp.app.src:otp应用程序的资源文件

      myapp_app.erl:一个OTP应用程序的Application behaviour

    myapp_sup.erl:一个OTP应用程序的Supervisor behaviour

    4.编译工程

    rebar compile
    

     执行完之后会产生一个ebin文件夹,在ebin下会生成与src文件夹下源文件对应的beam文件。同时,rebar会根据myapp.app.src动态生成一个合适OTP项目资源文件。

    另外,rebar clean可以清除编译的beam文件
    5.添加常用依赖
    在工程目录下(与src文件夹在同一目录),新建rebar.config文件,文件内容如下:
    {erl_opts, [debug_info,{parse_transform, lager_transform}]}.
    
    
    {deps, [
      			{lager_amqp_backend, ".*", {git, "https://github.com/jbrisbin/lager_amqp_backend.git", "master"}},
      			{amqp_client,   ".*", {git, "https://github.com/jbrisbin/amqp_client.git", {tag,"rabbitmq_2.7.0"}}},
      			{ranch, ".*", {git, "https://github.com/ninenines/ranch.git", {tag,"1.1.0"}}},
    				{protobuffs, ".*", {git, "git://github.com/basho/erlang_protobuffs.git", master}}
    				]
    }.
    

     之后运行,rebar get-deps即可生成deps文件夹,完成基本创建。

    ps:纯属个人学习笔记,如有不足请指出,谢谢!

  • 相关阅读:
    关于互联网下的大数据及大数据对人的影响
    综合练习:词频统计=
    五星红旗
    页面性能
    前端一些常见的基础知识
    h5常见问题汇总及解决方案
    CF 184
    2013520 训练赛后总结
    斜率优化动态规划
    2013522 完美世界复赛第三场
  • 原文地址:https://www.cnblogs.com/ACshasow/p/4319067.html
Copyright © 2011-2022 走看看