luamodules/lfs: add luafilesystem module

Signed-off-by: Neo Xu <neo.xu1990@gmail.com>
This commit is contained in:
Neo Xu 2022-12-21 15:30:50 +08:00 committed by Xiang Xiao
parent 7f11c91054
commit 7a2774b75a
5 changed files with 140 additions and 0 deletions

View File

@ -0,0 +1,2 @@
lfs/
*.tar.gz

View File

@ -0,0 +1,30 @@
From f84640912e5c3ff37a2b2b4aab011a3e6cfde6a8 Mon Sep 17 00:00:00 2001
From: Xu Xingliang <xuxingliang@xiaomi.com>
Date: Mon, 5 Dec 2022 18:58:40 +0800
Subject: [PATCH] call symlink or link directly.
Signed-off-by: Xu Xingliang <xuxingliang@xiaomi.com>
---
src/lfs.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/lfs.c b/src/lfs.c
index e5e5ee4..db6ae18 100644
--- a/src/lfs.c
+++ b/src/lfs.c
@@ -566,10 +566,8 @@ static int make_link(lua_State * L)
const char *oldpath = luaL_checkstring(L, 1);
const char *newpath = luaL_checkstring(L, 2);
#ifndef _WIN32
- return pushresult(L,
- (lua_toboolean(L, 3) ? symlink : link) (oldpath,
- newpath),
- NULL);
+ return pushresult(L, (lua_toboolean(L, 3) ? symlink(oldpath, newpath)\
+ : link(oldpath, newpath)), NULL);
#else
int symbolic = lua_toboolean(L, 3);
STAT_STRUCT oldpathinfo;
--
2.25.1

View File

@ -0,0 +1,21 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
config LUA_LFS_MODULE
bool "Lua file system module"
default n
depends on INTERPRETERS_LUA
---help---
LUA file system module
if LUA_LFS_MODULE
config LUA_LFS_VERSION
string "LFS version"
default "1_8_0"
---help---
Luv release version to fetch and build.
endif # LUA_LFS_MODULE

View File

@ -0,0 +1,24 @@
############################################################################
# apps/interpreters/luamodules/lfs/Make.defs
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
ifneq ($(CONFIG_LUA_LFS_MODULE),)
CONFIGURED_APPS += $(APPDIR)/interpreters/luamodules/lfs
endif

View File

@ -0,0 +1,63 @@
############################################################################
# apps/interpreters/luamodules/lfs/Makefile
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
include $(APPDIR)/Make.defs
LFS_VERSION = $(patsubst "%",%,$(strip $(CONFIG_LUA_LFS_VERSION)))
LFS_TARBALL = v$(LFS_VERSION).tar.gz
LFS_UNPACK = lfs
LFS_URL_BASE = https://github.com/lunarmodules/luafilesystem/archive/refs/tags
LFS_URL = $(LFS_URL_BASE)/$(LFS_TARBALL)
LFS_SRC = $(LFS_UNPACK)$(DELIM)src
VPATH += $(LFS_SRC)
CSRCS = lfs.c
$(LFS_TARBALL):
$(Q) echo "Downloading $(LFS_TARBALL) from $(LFS_URL)"
$(Q) curl -O -L $(LFS_URL)
$(LFS_UNPACK): $(LFS_TARBALL)
$(Q) echo "Unpacking $(LFS_TARBALL) to $(LFS_UNPACK)"
$(Q) tar -xvzf $(LFS_TARBALL)
$(Q) mv luafilesystem-$(LFS_VERSION) $(LFS_UNPACK)
$(Q) patch -d $(LFS_UNPACK) -p1 < 0001-call-symlink-or-link-directly.patch
$(LFS_UNPACK)/.patch: $(LFS_UNPACK)
touch $(LFS_UNPACK)/.patch
# Download and unpack tarball if no git repo found
ifeq ($(wildcard $(LFS_UNPACK)/.git),)
distclean::
$(call DELDIR, $(LFS_UNPACK))
$(call DELFILE, $(LFS_TARBALL))
context:: $(LFS_UNPACK)/.patch
endif
# Set LUAMODNAME and include Module.mk to add this module to the list of
# builtin modules for the Lua interpreter. LUAMODNAME should match the
# module's luaopen function.
LUAMODNAME = lfs
include $(APPDIR)/interpreters/lua/Module.mk
include $(APPDIR)/Application.mk