xmake-io / luarocks-build-xmake

A luarocks build module based on xmake
https://xmake.io
Apache License 2.0
19 stars 2 forks source link
cplusplus lua luarocks makefile xmake

luarocks-build-xmake

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

A luarocks build module based on xmake

Introduction (中文)

A fork of built-in build system for C++ rocks. Specify "xmake" as build type and "luarocks-build-xmake" as dependency to use it.

About xmake, please see xmake.

Example1 (with xmake.lua)

We can build c/c++ modules if the project contain xmake.lua

├── src
│   ├── test.c
│   └── test.h
└── xmake.lua

xmake.lua

We need to use add_rules("luarocks.module") to add build rules for luarocks modules.

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 = {}
}

Example2 (without xmake.lua)

We can use xmake as builtin build type to build c/c++ modules if the project does not contain xmake.lua

├── 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 = {}
}

Set special xmake version

dependencies = {
    "lua >= 5.1",
    "luarocks-build-xmake"
}
build = {
    type = "xmake",
    variables = {
        xmake = {
            version = "2.5.1"
        }
    },
    copy_directories = {}
}

Set xmake compilation configuration

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 = {}
}