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:纯属个人学习笔记,如有不足请指出,谢谢!

  • 相关阅读:
    内存溢出和内存泄漏的区别
    java 23种设计模式 深入理解
    关于安装office注册表权限的解决方法
    Tomcat在Linux上的安装与配置
    初窥Linux 之 我最常用的20条命令
    redis使用初体验
    学习进度条——第12周
    找水王
    学习进度条——第11周
    学习进度条——第10周
  • 原文地址:https://www.cnblogs.com/ACshasow/p/4319067.html
Copyright © 2011-2022 走看看