# luarocks-build-xmake **Repository Path**: xmake-io/luarocks-build-xmake ## Basic Information - **Project Name**: luarocks-build-xmake - **Description**: 一个使用 xmake 构建 c/c++ 模块的 luarocks 插件 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: https://xmake.io - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2021-01-16 - **Last Updated**: 2021-02-16 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README

luarocks-build-xmake

github-ci github-ci github-ci
Reddit Gitter Telegram QQ Discord license Donate

A luarocks build module based on xmake

## 简介 替换 luarocks 内置的构建系统去构建 C/C++ 模块,指定 xmake 作为构建类型,并添加 `luarocks-build-xmake` 依赖项。 关于 xmake 构建系统,详情见:[xmake](https://github.com/xmake-io/xmake). ## 例子1 (带有 xmake.lua) 如果模块工程中使用了 xmake.lua 来维护构建,那么我们可以直接使用 xmake 去构建它,rockspec 文件中不需要额外的配置构建规则。 ``` ├── src │   ├── test.c │   └── test.h └── xmake.lua ``` #### xmake.lua 我们需要使用 `add_rules("luarocks.module")` 添加针对 luarocks 模块构建规则。 ```lua add_rules("mode.debug", "mode.release") target("example1.hello") add_rules("luarocks.module") add_files("src/test.c") ``` #### rockspec ```lua package = "example1" version = "1.0-1" source = { url = "git://github.com/xmake-io/luarocks-build-xmake", tag = "example1" } dependencies = { "lua >= 5.1", "luarocks-build-xmake" } build = { type = "xmake", copy_directories = {} } ``` ## 例子2 (没有 xmake.lua) 如果模块工程中没有使用 xmake.lua 来维护,那么我们也可以使用 xmake 替代 luarocks 内置的构建来编译,只需要在 rockspec 文件中去描述构建规则。 ``` ├── src    ├── test.c    └── test.h ``` #### rockspec ```lua package = "example2" version = "1.0-1" source = { url = "git://github.com/xmake-io/luarocks-build-xmake", tag = "example2" } dependencies = { "lua >= 5.1", "luarocks-build-xmake" } build = { type = "xmake", modules = { ["example2.hello"] = { sources = "src/test.c" } }, copy_directories = {} } ``` ## 设置特定 xmake 版本 ```lua dependencies = { "lua >= 5.1", "luarocks-build-xmake" } build = { type = "xmake", variables = { xmake = { version = "2.5.1" } }, copy_directories = {} } ``` ## 设置 xmake 编译参数 ```lua dependencies = { "lua >= 5.1", "luarocks-build-xmake" } build = { type = "xmake", variables = { xmake = { plat = "mingw", arch = "x86_64", mode = "debug", cflags = "-DTEST1", cc = "gcc", ld = "gcc", ldflags = "...", mingw = "mingw sdk path", vs = "2019", vs_runtime = "MT", vs_toolset = "", vs_sdkver = "", } }, copy_directories = {} } ```