luarocks 牛刀小试

图片

luarocks 安装

macOS 环境安装

brew install luarocks

linux 环境安装

sudo apt install build-essential libreadline-dev
wget https://luarocks.org/releases/luarocks-3.2.0.tar.gz
tar zxpf luarocks-3.2.0.tar.gz
cd luarocks-3.2.0
./configure (这里会检测 lua 是否安装,没有安装会失败)
make build
make install

windows 环境安装

luarocks 使用

初始化项目

新建一个rockspec文件,文件命名规则 {{name}}-{{version}}-{{rockspec提交更新次数}}.rockspec 如:nana-0.0.5-3.rockspec

package = "nana"
version = "0.0.5-3"
source = {
   url = "git://github.com/horan-geeker/nana",
   tag = "v0.5.0",
}
description = {
   summary = "http api server framework",
   detailed = [[
        Nana is a http restful api framework written in Lua which need be used in openresty platform and it's designed reference Laravel framework styles
   ]],
   homepage = "https://github.com/horan-geeker/nana",
   license = "MIT/X11"
}
dependencies = {
   "lua >= 5.1, < 5.4",
}
build = {
    type = "builtin",
    modules = {
        ["bootstrap"] = "bootstrap.lua"
    }
}

其中

  • package 同 {{name}}
  • version 同 {{version}}
  • source 里 url 是项目 github 的地址,tag 是项目的 tag
  • description 是项目说明,在 luarocks 网站里会带着链接和说明文案

写好描述文件之后可以操作上传 luarocks upload nana-0.0.5-3.rockspec

点赞
Robotics
Robotics

大佬,请问如何用luarocks安装luasql?尽管Lua for windows 5.1.4里有现成的,但是已经过时了,支持不了lua5.4或5.3了。

https://lua-china.com/posts/42

2021-02-07 09:58:12