-
-
Notifications
You must be signed in to change notification settings - Fork 765
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Luarocks functionality to XMake #1043
Comments
Do you mean to use xmake instead of luarocks' built-in build system to build all the binary libraries used by lua packages? Make all lua packages adapt to more toolchains, such as llvm-mingw? If so, you can use the xrepo command provided by the dev/master version of xmake. see https://github.com/xmake-io/xrepo/ This command can be used to find and install packages maintained by third-party package management tools, such as conan/vcpkg/homebrew/pacman. Although xrepo does not support luarocks yet, but I will consider to add support for it. E.g xrepo install -p mingw -a arm64 luarocks::xxx
xrepo fetch -p mingw -a arm64 luarocks::xxx |
Yes, that's almost exactly what I was thinking. I had probably seen that in your help files and it subliminally triggered the idea. :-) Let me know what I can do to help. Is there some way I can distribute my compiler/lua toolchain with xmake? Currently I'm using Windows msi installers. I have no desire to use windows store at the moment. I can use my MSI on chocolatey. |
At present, xmake does not support generate installation packages, but you can customize on_package/ Or customize on_install, and then execute |
I can consider in the next version, let xmake package manager and xrepo command support it, but you may need to wait some time, the current version 2.3.9 I do not plan to add new new features, because it will be released soon. |
Thanks for the suggestions. I'm currently cross compiling on FreeBSD (as you know) and my WIX scripts are all entangled with Visual Studio. I will need to find a better solution to installers. Your xmake project is very exciting to me and I had (wild, fitful) dreams of using xmake as a binary package manager on Windows. :-) |
You can try nsis. The windows installer of xmake is made by using nsi scripts. In addition, it provides makensis command line to make windows installation packages and it is open source. It seems that it can also be used on linux. https://mohanjith.net/blog/2007/08/makensis-on-linux.html
At present, the focus of xmake is to build c/c++ and depend on package management. There are still many things to do, such as distributed compilation. In the future, when I have free time, I may consider studying binary packaging and distribution. But currently this is not the focus of xmake. |
While I mentioned a binary package manager, that's more of a tangent. Here is some more thoughts on the Luarocks integration idea. Luarocks does not handle pre-requisites and this falls over flat on Windows (I thank @siffiejoe for reminding me of this drawback). Ignoring the configuration warning, the following is an example where I am trying to use a pcre module:
The pre-requisite problem originally made me thing of integrating xmake into luarocks (the opposite of this feature request). If one is using Lua and LuaRocks primarily to support a desktop scripting environment, calling xmake from luarocks makes "more sense". A custom call to an xmake script could be added to run a package command and install components in a directory known to luarocks, possibly even as an adendem to the rocktree. HOWEVER, If one approaches the problem from an application perspective (e.g. an executable for distribution), then the problem is different. The developer would likely want the executable binaries to exist within the application directory structure with the scripts in a known location. Luarocks sort of supports this through project rock trees but again, it feels like the focus is desktop scripting (maybe I'm incorrect?). XMake is superior here because packages can be installed anywhere one wishes. XMake could be configured to work with a luarocks config script and place components where needed. My final thought is some form of segue until then. I am wondering about creating an xmake script to build a bunch of packages and install them in a library directory. Thoughts, comments? @siffiejoe? Regards, |
@RussellHaley I have added one patch to support it. see luarocks/luarocks#1265 I tested it on macos/linux and macos/mingw, it works fine for me. but I cannot test it on windows. you can try it. About using xmake instead of luarocks/builtin build type, this patch can also support it. build = {
type = "builtin",
modules = {
["ltui"] = {
sources = "src/core/lcurses/lcurses.c",
libraries = {"curses"}
}
} But currently I don't have a good way to completely hook and replace the luarocks/builtin build type, I can only modify it by hard-coding # use xmake instead of `builtin` build type
# How to do it?
# export LUAROCKS_BUILDTYPE=xmake ?
$ luarocks install ltui # builtin -> xmake
$ luarocks install LuaSocket #builtin -> xmake |
I think this issue has nothing to do with xmake v2.5.1, which does not require modification of xmake's code. So I removed it from v2.5.1 Milestone, but I will continue to pay attention to this issue. |
Hi Ruki, Absolutely, please push this out. I have no ability to absorb this for a week or so. Thank you for the suggestions you have made. I will review them asap and will try and provide some feedback. Your the best Ruki! |
New solution: https://github.com/xmake-io/luarocks-build-xmake |
I have forked and installed it with a standard LuaRocks installation.
I'll go do some testing with some simple C only scenarios in Windows. |
It should work now for all platforms on ci, but automatic installation of xmake is not yet supported. https://github.com/xmake-io/luarocks-build-xmake/actions |
I works for me on ci.
I have improved to find xmake to fix this problem. |
I have fully implemented luarocks-build-xmake, and support automatic download and installation of xmake if it is missing. Example1 (with xmake.lua)We can build c/c++ modules if the project contain xmake.lua
xmake.luaWe need to use add_rules("mode.debug", "mode.release")
target("example1.hello")
add_rules("luarocks.module")
add_files("src/test.c") rockspecpackage = "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
rockspecpackage = "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 versiondependencies = {
"lua >= 5.1",
"luarocks-build-xmake"
}
build = {
type = "xmake",
variables = {
xmake = {
version = "2.5.1"
}
},
copy_directories = {}
} Set xmake compilation configurationdependencies = {
"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 = {}
} |
Amazing, I look forward to testing. I postulate that the compilation configuration can be set through the luarocks config file in the "variables" block:
|
It should work for lualib configs. |
I am going to close it, we can continue to discuss related topics in luarocks-build-xmake/issues. |
Is your feature request related to a problem? Please describe.
I would like to see XMake take on the LuaRocks functionality. I'd like to try and take it on myself, though it's low priority at the moment. I'm mostly asking for your input. Perhaps even if you could write item 1 below, that would allow me to look at the rest? I'm not suggesting you take it on unless you're really keen, but I would be willing to financially contribute.
Describe the solution you'd like
I see it happening in four steps:
Describe alternatives you've considered
N/A
Additional context
I'm still new to xmake, so "bare with me". Luarocks may be a little different than xmake because it can be used to set up a global tree, user tree or project tree of binaries for use with scripts. But xmake has the tools for downloading, building and installing packages, but doesn't necessarily maintain a list of installed items (that's a guess)? A rockspec file is a subset of a xmake file. A rocktree file used to manage installed modules is really an install manifest; like an xmake.lua file is in reverse.
Luarocks is written to be portable between 5.1 and 5.x (I believe the default install is still 5.1), so there may be a possibility of just running luarocks as a Plugin (though I know little about plugins yet). I've gone through the LuaRocks code a few times.
Alternatively, the LuaRocks functionality is quite generic and perhaps could be easily massaged into xmake (as noted above)? I found the LuaRocks functionality of rock trees to be similar to npm in functionality.
Or maybe it's just a matter of a pre-built task in xmake that writes/installs to a known location and updates a rocktree file?
The "All In One" executable I use on Windows are built in linux and are binaries combined with the lua scripts. Luarocks uses a bunch of lua modules FROM the luarocks repository, so it may be a large part of the code is portable to xmake. Who knows?
One of the things that drives feature suggestion is a problem that I have with Luarocks when using llvm-mingw (e.g. clang/lld): Luarocks assumes mingw is gcc/mingw and links directly to the DLL, which doesn't work in llvm. I'm not saying Hisham at LuaRocks won't fix it, but it's been a problem for a while, which lead me to think of this solution. I will be re-posting about the issue at LuaRocks repo soon (not tonight, it's too late).
Thanks Ruki, I look forward to the conversation. It's low priority. Cheers!
The text was updated successfully, but these errors were encountered: