rebar3编译及发布erlang程序
2021/6/5 20:51:04
本文主要是介绍rebar3编译及发布erlang程序,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
确保已经安装erlang/OTP和rebar3,否则,可参考本人的“centos7安装erlang/otp”、“centos7安装rebar3”博文完成安装
【1】生成
rebar3为每种类型的项目都提供了模板,通过rebar3 new <template> <project-name>命令使用。
<template>的取值
app: 一个有监督树、有状态的OTP应用程序,是一个单应用程序
lib: 一个OTP依赖(无监督树),与其他模块联合使用,是一个单应用程序
release: 创建一个大型项目
escript: 一个特殊格式的单应用项目,可以编译为一个可执行的脚本程序
plugin: rebar3插件结构
shell 命令举例
rebar3 new app myapp
【2】配置依赖
依赖被配置在rebar.config文件的deps下
{deps, [
{cowboy, "1.0.1"}, % package
{cowboy, {git, "git://github.com/ninenines/cowboy.git", {tag, "1.0.1"}}} % alternatively, source
]
}.
添加依赖
将依赖添加到您项目的应用程序的.app.src文件中,配置你的项目启动时需要用到的依赖。
{application, <APPNAME>,
[{description, ""},
{vsn, "<APPVSN>"},
{registered, []},
{modules, []},
{applications, [
kernel
,stdlib
,cowboy
]},
{mod, {<APPNAME>_app, []}},
{env, []}
]}.
【3】构建项目
只有一个命令compile,就可以拉取应用需要的依赖并且编译整个应用程序
shell 命令
rebar3 compile
【4】生成系统
使用relx构建生成
创建一个应用程序,relx默认配置在rebar.config文件中
rebar3 new release myrel
查看rebar.config文件,我们会发现生成了一些新的元素
{relx, [{release, {myrel, "0.0.1"}, [myrel]},
{dev_mode, true},
{include_erts, false},
{extended_start_script, true}
]
}.
{profiles, [
{prod, [{relx, [{dev_mode, false},
{include_erts, true}]}]}
]
}.
发布:
cd relx
rebar3 release
cd ./_build/default/rel/myrel/bin&&ls
这篇关于rebar3编译及发布erlang程序的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-10-01基于Python+Vue开发的医院门诊预约挂号系统
- 2024-10-01基于Python+Vue开发的旅游景区管理系统
- 2024-10-01RestfulAPI入门指南:打造简单易懂的API接口
- 2024-10-01初学者指南:了解和使用Server Action
- 2024-10-01Server Component入门指南:搭建与配置详解
- 2024-10-01React 中使用 useRequest 实现数据请求
- 2024-10-01使用 golang 将ETH账户的资产平均分散到其他账户
- 2024-10-01JWT用户校验课程:从入门到实践
- 2024-10-01Server Component课程入门指南
- 2024-09-30Dnd-Kit学习:新手快速入门指南