luarocks-build-xmake基于 xmake 的 luarocks 構(gòu)建模塊
luarocks-build-xmake 是一個(gè)基于 xmake 的 luarocks 構(gòu)建模塊,用于替換 luarocks 內(nèi)置的構(gòu)建系統(tǒng)去構(gòu)建 C/C++ 模塊,指定 xmake 作為構(gòu)建類型,并添加 luarocks-build-xmake 依賴項(xiàng)。
關(guān)于 xmake 構(gòu)建系統(tǒng),詳情見(jiàn):xmake.
例子1 (帶有 xmake.lua)
如果模塊工程中使用了 xmake.lua 來(lái)維護(hù)構(gòu)建,那么我們可以直接使用 xmake 去構(gòu)建它,rockspec 文件中不需要額外的配置構(gòu)建規(guī)則。
├── src
│ ├── test.c
│ └── test.h
└── xmake.lua
xmake.lua
我們需要使用 add_rules("luarocks.module") 添加針對(duì) luarocks 模塊構(gòu)建規(guī)則。
add_rules("mode.debug", "mode.release") target("example1.hello") add_rules("luarocks.module") add_files("src/test.c")
rockspec
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 (沒(méi)有 xmake.lua)
如果模塊工程中沒(méi)有使用 xmake.lua 來(lái)維護(hù),那么我們也可以使用 xmake 替代 luarocks 內(nèi)置的構(gòu)建來(lái)編譯,只需要在 rockspec 文件中去描述構(gòu)建規(guī)則。
├── src
├── test.c
└── test.h
rockspec
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 = {} }
設(shè)置特定 xmake 版本
dependencies = { "lua >= 5.1", "luarocks-build-xmake" } build = { type = "xmake", variables = { xmake = { version = "2.5.1" } }, copy_directories = {} }
設(shè)置 xmake 編譯參數(shù)
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 = {} }
評(píng)論
圖片
表情
