feature: MSYS2 support on src/makefile
Description
The changes in the src/makefile allows to build luasocket on MSYS2 shells with the compiler toolchain for each environment:
-
mingw32 -
mingw64 -
ucrt64 -
clang32 -
clang64 -
clangarm64
How to test the changes
Initial setup of tools (only once)
- Go to https://www.msys2.org/, download the installer and install MSYS2;
- Type
ucrt64on Windows start menu to open a MSYS2 shell for the ucrt64 environment listed above; - Update core system packages
pacman -Syuu - Sync package database
pacman -Syuu - Install useful linux tools, git, a C compiler and Lua 5.1:
pacman -S --needed base-devel git mingw-w64-ucrt-x86_64-cc mingw-w64-ucrt-x86_64-lua51 - Change to
/tmpdirectory and clone my branchcd /tmp && git clone --branch=msys2-makefile https://github.com/luau-project/luasocket - Leave the shell opened for the test
Test
- In the same shell above, build luasocket for ucrt64 environment:
make -C luasocket/src PLAT=msys2ucrt64 LUAV=5.1 all - Install the library:
make -C luasocket/src PLAT=msys2ucrt64 LUAV=5.1 install - Run a simple test
lua5.1 luasocket/test/hello.lua - Enjoy.
[!NOTE]
Lua C modules get installed at
/ucrt64/lib/lua/5.1and .lua files at/ucrt64/share/lua/5.1for the ucrt64 environment, in case you want to remove them.
Extra
If you guys want, I can contribute a Github workflow to test luasocket on MSYS2 tools.
@luau-project I think better msys2 support is great! Did you test with other Lua versions than 5.1, in particular 5.4?
A GitHub workflow would be great too, since I think most contributors to LuaSocket do not have a Windows machine with msys2 set up. I have not used it in a long time and just noticed they provide an official GitHub Action now.
@luau-project I think better msys2 support is great! Did you test with other Lua versions than 5.1, in particular 5.4?
A GitHub workflow would be great too, since I think most contributors to LuaSocket do not have a Windows machine with msys2 set up. I have not used it in a long time and just noticed they provide an official GitHub Action now.
Hello @catwell . I tested it on every 64 bit environment on MSYS2 (but not the ARM one). I even submitted a pull request on MSYS2 https://github.com/msys2/MINGW-packages/pull/21344 to add luasocket on their repositories based on this makefile changes.
As you can see on the MSYS2 PR, it is building fine for every 64 bit env. I didn't test on 32 bit envs though, because I do not have such a machine. However, I'm still confident it does.
@luau-project I think better msys2 support is great! Did you test with other Lua versions than 5.1, in particular 5.4?
A GitHub workflow would be great too, since I think most contributors to LuaSocket do not have a Windows machine with msys2 set up. I have not used it in a long time and just noticed they provide an official GitHub Action now.
Just a small notice: on MSYS2, the available versions are current Lua (5.4), Lua 5.3 and Lua 5.1. There is no Lua 5.2.
Hello @catwell .
Based on build.yml, I have finished a working msys2.yml GitHub workflow for the makefile changes above.
Should I push this workflow? (I'm supposing you have write access to the repository).
Just in case, I'll write the workflow here. I'm waiting your signal to push it:
name: Build on MSYS2
on:
push:
branches:
- master
pull_request:
jobs:
build:
name: Test ${{ matrix.Lua.version }} from MSYS2 package mingw-w64-${{ matrix.MSYS2.env }}-${{ matrix.Lua.msys2_pkg_name }}
runs-on: windows-latest
strategy:
matrix:
Lua:
# For future updates:
# the fields 'msys2_pkg_name' and 'msys2_lua_exe'
# in the matrix below are always 'lua'
# for the current Lua version .
- { version: '5.4', msys2_pkg_name: 'lua', msys2_lua_exe: 'lua' }
- { version: '5.3', msys2_pkg_name: 'lua53', msys2_lua_exe: 'lua5.3' }
# At the moment, Lua 5.2 is not on MSYS2 repositories.
- { version: '5.1', msys2_pkg_name: 'lua51', msys2_lua_exe: 'lua5.1' }
- { version: '5.1', msys2_pkg_name: 'luajit', msys2_lua_exe: 'luajit' }
MSYS2:
- { sys: ucrt64, env: ucrt-x86_64 }
- { sys: mingw64, env: x86_64 }
- { sys: mingw32, env: i686 }
- { sys: clang64, env: clang-x86_64 }
- { sys: clang32, env: clang-i686 }
defaults:
run:
shell: msys2 {0}
env:
LUA_EXE: /${{ matrix.MSYS2.sys }}/bin/${{ matrix.Lua.msys2_lua_exe }}
steps:
- uses: msys2/setup-msys2@v2
name: Setup MSYS2
with:
msystem: ${{ matrix.MSYS2.sys }}
install: |
base-devel
git
mingw-w64-${{ matrix.MSYS2.env }}-cc
mingw-w64-${{ matrix.MSYS2.env }}-${{ matrix.Lua.msys2_pkg_name }}
- name: Checkout
uses: actions/checkout@v4
- name: Build
if: ${{ !contains(matrix.Lua.msys2_pkg_name, 'luajit') }}
run: |
make -C src \
PLAT=msys2${{ matrix.MSYS2.sys }} \
LUAV=${{ matrix.Lua.version }} \
DEBUG=DEBUG \
all
- name: Build with luajit
if: ${{ contains(matrix.Lua.msys2_pkg_name, 'luajit') }}
run: |
make -C src \
PLAT=msys2${{ matrix.MSYS2.sys }} \
LUAV=${{ matrix.Lua.version }} \
DEBUG=DEBUG \
"MYCFLAGS=$(pkgconf.exe --cflags lua${{ matrix.Lua.version }})" \
all
- name: Install
run: |
make -C src \
PLAT=msys2${{ matrix.MSYS2.sys }} \
LUAV=${{ matrix.Lua.version }} \
DEBUG=DEBUG \
install
- name: Run regression tests
run: |
cd test
${{ env.LUA_EXE }} hello.lua
${{ env.LUA_EXE }} testsrvr.lua > /dev/null &
${{ env.LUA_EXE }} testclnt.lua
${{ env.LUA_EXE }} stufftest.lua
${{ env.LUA_EXE }} excepttest.lua
${{ env.LUA_EXE }} test_bind.lua
${{ env.LUA_EXE }} test_getaddrinfo.lua
${{ env.LUA_EXE }} ltn12test.lua
${{ env.LUA_EXE }} mimetest.lua
${{ env.LUA_EXE }} urltest.lua
${{ env.LUA_EXE }} test_socket_error.lua
kill %1
I do have write access to the repository and I don't see a problem with you pushing the workflow. I will probably wait for feedback from @Tieske or @alerque to merge but I can run the workflow in the meantime.
By the way, is your nickname in any way related to @luau-lang?
I do have write access to the repository and I don't see a problem with you pushing the workflow. I will probably wait for feedback from @Tieske or @alerque to merge but I can run the workflow in the meantime.
Pushed it.
By the way, is your nickname in any way related to @luau-lang?
Oh, no. When I created this gh acc, I didn't even know the roblox luau.
Sorry, it took me some time to run the workflows because the new one didn't appear in the list so I was wondering what I had to do... It turns out when you allow the run they still get picked up and run anyway!
Thanks for the contribution. This should become available via the dev (scm) rockspec soon. I don't know when the next release will be, honestly I haven't assessed where this project is at or what it needs before the next tag in a while and I'm kinda busy at the moment. If anybody has input on that ("the SCM version works fine, just send it", "suggest cleaning up X first", "X and Y PRs should land first) I'd be happy to hear input on another issues.