forked from msys2/MINGW-packages
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request msys2#21182 from luau-project/luafilesystem
[new-package] luafilesystem
- Loading branch information
Showing
2 changed files
with
206 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
diff -Naur a/Makefile.mingw b/Makefile.mingw | ||
--- a/Makefile.mingw 1969-12-31 21:00:00.000000000 -0300 | ||
+++ b/Makefile.mingw 2024-06-17 12:37:55.857370395 -0300 | ||
@@ -0,0 +1,38 @@ | ||
+LUA_VERSION=5.1 | ||
+LUA_VERSION_SHORT=51 | ||
+ | ||
+PREFIX=/usr/local | ||
+LUA_BIN=$(PREFIX)/bin | ||
+LUA_INC=$(PREFIX)/include/lua$(LUA_VERSION) | ||
+LUA_CMODULE_DIR=$(PREFIX)/lib/lua/$(LUA_VERSION) | ||
+LUA_EXE_NAME=lua$(LUA_VERSION) | ||
+DLL_EXT=.dll | ||
+LUA_DLL=$(LUA_BIN)/lua$(LUA_VERSION_SHORT)$(DLL_EXT) | ||
+ | ||
+SRC_FILES= src/lfs.c | ||
+DEF_FILE= src/lfs.def | ||
+OBJ_FILES= src/lfs.o | ||
+TEST_FILE= tests/test.lua | ||
+OUT_FILE= lfs.dll | ||
+ | ||
+MKDIR_P= mkdir -p | ||
+RM= rm -f | ||
+INSTALL= install -p | ||
+INSTALL_EXEC= $(INSTALL) -m 0755 | ||
+INSTALL_DATA= $(INSTALL) -m 0644 | ||
+ | ||
+all: $(OUT_FILE) | ||
+ | ||
+$(OBJ_FILES): $(SRC_FILES) | ||
+ $(CC) -c "-I$(LUA_INC)" $(CFLAGS) -o $@ $< | ||
+ | ||
+$(OUT_FILE): $(OBJ_FILES) $(DEF_FILE) | ||
+ $(CC) -shared $(LDFLAGS) -o $@ "$(LUA_DLL)" $< | ||
+ | ||
+install: $(OUT_FILE) | ||
+ $(MKDIR_P) $(DESTDIR)$(LUA_CMODULE_DIR) | ||
+ $(RM) $(DESTDIR)$(LUA_CMODULE_DIR)/$(OUT_FILE) | ||
+ $(INSTALL_EXEC) $(OUT_FILE) $(DESTDIR)$(LUA_CMODULE_DIR)/$(OUT_FILE) | ||
+ | ||
+check: | ||
+ "$(LUA_BIN)/$(LUA_EXE_NAME)" $(TEST_FILE) | ||
\ No newline at end of file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
# Maintainer: luau-project <[email protected]> | ||
|
||
_realname=luafilesystem | ||
pkgbase=mingw-w64-${_realname} | ||
pkgname=("${MINGW_PACKAGE_PREFIX}-lua-${_realname}" | ||
"${MINGW_PACKAGE_PREFIX}-lua51-${_realname}" | ||
"${MINGW_PACKAGE_PREFIX}-lua53-${_realname}") | ||
_tagver=1_8_0 | ||
pkgver=1.8.0 | ||
pkgrel=1 | ||
arch=('any') | ||
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64') | ||
url='https://github.com/lunarmodules/luafilesystem' | ||
license=('spdx:MIT') | ||
makedepends=("${MINGW_PACKAGE_PREFIX}-cc" | ||
"${MINGW_PACKAGE_PREFIX}-lua" | ||
"${MINGW_PACKAGE_PREFIX}-lua51" | ||
"${MINGW_PACKAGE_PREFIX}-lua53" | ||
"${MINGW_PACKAGE_PREFIX}-pkgconf") | ||
source=("${url}/archive/refs/tags/v${_tagver}.tar.gz" | ||
"001-makefile-for-mingw.patch") | ||
sha256sums=('16d17c788b8093f2047325343f5e9b74cccb1ea96001e45914a58bbae8932495' | ||
'4eacf6828e8a4e1fedf48c704a5df5fb4d09e6357c0d72a265704a76cc33507f') | ||
|
||
prepare() { | ||
cd "${srcdir}/${_realname}-${_tagver}" | ||
patch -Np1 -i ${srcdir}/001-makefile-for-mingw.patch | ||
|
||
cd ${srcdir} | ||
|
||
cp -r "${srcdir}/${_realname}-${_tagver}" "${srcdir}/${_realname}-${_tagver}-51" | ||
cp -r "${srcdir}/${_realname}-${_tagver}" "${srcdir}/${_realname}-${_tagver}-53" | ||
|
||
# current Lua | ||
_lua_ver=$(pkgconf --variable=V lua) | ||
_lua_ver_short=$(echo $_lua_ver | sed -En "s/\.//p") | ||
|
||
_options=("--file=Makefile.mingw" | ||
"PREFIX=${MINGW_PREFIX}" | ||
"LUA_VERSION=${_lua_ver}" | ||
"LUA_VERSION_SHORT=${_lua_ver_short}" | ||
"LUA_EXE_NAME=lua" | ||
"LUA_INC=${MINGW_PREFIX}/include" | ||
"") | ||
|
||
sed -e "s/\#\!\/usr\/bin\/env lua5\.1/\#\!\/usr\/bin\/env lua/" \ | ||
-i "${srcdir}/${_realname}-${_tagver}"/tests/test.lua | ||
|
||
# Lua 5.1 | ||
_lua_ver51=$(pkgconf --variable=V lua5.1) | ||
_lua_ver_short51=$(echo $_lua_ver51 | sed -En "s/\.//p") | ||
|
||
_options51=("--file=Makefile.mingw" | ||
"PREFIX=${MINGW_PREFIX}" | ||
"LUA_VERSION=${_lua_ver51}" | ||
"LUA_VERSION_SHORT=${_lua_ver_short51}" | ||
"") | ||
|
||
# Lua 5.3 | ||
_lua_ver53=$(pkgconf --variable=V lua5.3) | ||
_lua_ver_short53=$(echo $_lua_ver53 | sed -En "s/\.//p") | ||
|
||
_options53=("--file=Makefile.mingw" | ||
"PREFIX=${MINGW_PREFIX}" | ||
"LUA_VERSION=${_lua_ver53}" | ||
"LUA_VERSION_SHORT=${_lua_ver_short53}" | ||
"") | ||
|
||
sed -e "s/\#\!\/usr\/bin\/env lua5\.1/\#\!\/usr\/bin\/env lua${_lua_ver53}/" \ | ||
-i "${srcdir}/${_realname}-${_tagver}-53"/tests/test.lua | ||
} | ||
|
||
build() { | ||
# current Lua | ||
cd "${srcdir}/${_realname}-${_tagver}" | ||
|
||
make \ | ||
"${_options[@]}" \ | ||
all | ||
|
||
# Lua 5.1 | ||
cd "${srcdir}/${_realname}-${_tagver}-51" | ||
|
||
make \ | ||
"${_options51[@]}" \ | ||
all | ||
|
||
# Lua 5.3 | ||
cd "${srcdir}/${_realname}-${_tagver}-53" | ||
|
||
make \ | ||
"${_options53[@]}" \ | ||
all | ||
} | ||
|
||
check() { | ||
# current Lua | ||
cd "${srcdir}/${_realname}-${_tagver}" | ||
|
||
make \ | ||
"${_options[@]}" \ | ||
check | ||
|
||
# Lua 5.1 | ||
cd "${srcdir}/${_realname}-${_tagver}-51" | ||
|
||
make \ | ||
"${_options51[@]}" \ | ||
check | ||
|
||
# Lua 5.3 | ||
cd "${srcdir}/${_realname}-${_tagver}-53" | ||
|
||
make \ | ||
"${_options53[@]}" \ | ||
check | ||
} | ||
|
||
package_lua-luafilesystem() { | ||
pkgdesc="File System Library for the Lua Programming Language (mingw-w64)" | ||
depends=("${MINGW_PACKAGE_PREFIX}-lua") | ||
|
||
cd "${srcdir}/${_realname}-${_tagver}" | ||
|
||
DESTDIR="${pkgdir}" make \ | ||
"${_options[@]}" \ | ||
install | ||
|
||
install -Dm644 "${srcdir}/${_realname}-${_tagver}/LICENSE" "${pkgdir}${MINGW_PREFIX}/share/licenses/lua${_lua_ver_short}-${_realname}/LICENSE" | ||
} | ||
|
||
package_lua51-luafilesystem() { | ||
pkgdesc="File System Library for the Lua ${_lua_ver51} Programming Language (mingw-w64)" | ||
depends=("${MINGW_PACKAGE_PREFIX}-lua51") | ||
|
||
cd "${srcdir}/${_realname}-${_tagver}-51" | ||
|
||
DESTDIR="${pkgdir}" make \ | ||
"${_options51[@]}" \ | ||
install | ||
|
||
install -Dm644 "${srcdir}/${_realname}-${_tagver}-51/LICENSE" "${pkgdir}${MINGW_PREFIX}/share/licenses/lua${_lua_ver_short51}-${_realname}/LICENSE" | ||
} | ||
|
||
package_lua53-luafilesystem() { | ||
pkgdesc="File System Library for the Lua ${_lua_ver53} Programming Language (mingw-w64)" | ||
depends=("${MINGW_PACKAGE_PREFIX}-lua53") | ||
|
||
cd "${srcdir}/${_realname}-${_tagver}-53" | ||
|
||
DESTDIR="${pkgdir}" make \ | ||
"${_options53[@]}" \ | ||
install | ||
|
||
install -Dm644 "${srcdir}/${_realname}-${_tagver}-53/LICENSE" "${pkgdir}${MINGW_PREFIX}/share/licenses/lua${_lua_ver_short53}-${_realname}/LICENSE" | ||
} | ||
|
||
# generate wrappers | ||
for _name in "${pkgname[@]}"; do | ||
_short="package_${_name#${MINGW_PACKAGE_PREFIX}-}" | ||
_func="$(declare -f "${_short}")" | ||
eval "${_func/#${_short}/package_${_name}}" | ||
done |