From 6d7761f274007af5dbc1fcaf40ec1e9aeca448bf Mon Sep 17 00:00:00 2001 From: Neo Xu Date: Wed, 21 Dec 2022 15:33:43 +0800 Subject: [PATCH] luamodules/lsyslog: add lua syslog module Signed-off-by: Neo Xu --- interpreters/luamodules/luasyslog/.gitignore | 2 + interpreters/luamodules/luasyslog/Kconfig | 21 +++++++ interpreters/luamodules/luasyslog/Make.defs | 24 ++++++++ interpreters/luamodules/luasyslog/Makefile | 65 ++++++++++++++++++++ 4 files changed, 112 insertions(+) create mode 100644 interpreters/luamodules/luasyslog/.gitignore create mode 100644 interpreters/luamodules/luasyslog/Kconfig create mode 100644 interpreters/luamodules/luasyslog/Make.defs create mode 100644 interpreters/luamodules/luasyslog/Makefile diff --git a/interpreters/luamodules/luasyslog/.gitignore b/interpreters/luamodules/luasyslog/.gitignore new file mode 100644 index 000000000..f422926ff --- /dev/null +++ b/interpreters/luamodules/luasyslog/.gitignore @@ -0,0 +1,2 @@ +lsyslog/ +*.tar.gz diff --git a/interpreters/luamodules/luasyslog/Kconfig b/interpreters/luamodules/luasyslog/Kconfig new file mode 100644 index 000000000..418ce3496 --- /dev/null +++ b/interpreters/luamodules/luasyslog/Kconfig @@ -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_LSYSLOG_MODULE + bool "Lua syslog module" + default n + depends on INTERPRETERS_LUA + ---help--- + LUA syslog module + +if LUA_LSYSLOG_MODULE + +config LUA_LSYSLOG_VERSION + string "lsyslog version" + default "2.0.1" + ---help--- + Lua lsyslog module release version to fetch and build. + +endif # LUA_LSYSLOG_MODULE diff --git a/interpreters/luamodules/luasyslog/Make.defs b/interpreters/luamodules/luasyslog/Make.defs new file mode 100644 index 000000000..6b1d99078 --- /dev/null +++ b/interpreters/luamodules/luasyslog/Make.defs @@ -0,0 +1,24 @@ +############################################################################ +# apps/interpreters/luamodules/luasyslog/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_LSYSLOG_MODULE),) +CONFIGURED_APPS += $(APPDIR)/interpreters/luamodules/luasyslog + +endif diff --git a/interpreters/luamodules/luasyslog/Makefile b/interpreters/luamodules/luasyslog/Makefile new file mode 100644 index 000000000..52f188d35 --- /dev/null +++ b/interpreters/luamodules/luasyslog/Makefile @@ -0,0 +1,65 @@ +############################################################################ +# apps/interpreters/luamodules/luasyslog/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 + +LSYSLOG_VERSION = $(patsubst "%",%,$(strip $(CONFIG_LUA_LSYSLOG_VERSION))) +LSYSLOG_TARBALL = $(LSYSLOG_VERSION).tar.gz +LSYSLOG_UNPACK = lsyslog +LSYSLOG_URL_BASE = https://github.com/lunarmodules/luasyslog/archive/refs/tags +LSYSLOG_URL = $(LSYSLOG_URL_BASE)/$(LSYSLOG_TARBALL) +LSYSLOG_SRC = $(LSYSLOG_UNPACK) + +VPATH += $(LSYSLOG_SRC) +CSRCS = lsyslog.c + +CFLAGS += -D'openlog(a,b,c)={(void)a; (void)c;}' +CFLAGS += -D'closelog()={}' + +$(LSYSLOG_TARBALL): + $(Q) echo "Downloading $(LSYSLOG_TARBALL) from $(LSYSLOG_URL)" + $(Q) curl -O -L $(LSYSLOG_URL) + +$(LSYSLOG_UNPACK): $(LSYSLOG_TARBALL) + $(Q) echo "Unpacking $(LSYSLOG_TARBALL) to $(LSYSLOG_UNPACK)" + $(Q) tar -xvzf $(LSYSLOG_TARBALL) + $(Q) mv luasyslog-$(LSYSLOG_VERSION) $(LSYSLOG_UNPACK) + +$(LSYSLOG_UNPACK)/.patch: $(LSYSLOG_UNPACK) + touch $(LSYSLOG_UNPACK)/.patch + +# Download and unpack tarball if no git repo found +ifeq ($(wildcard $(LSYSLOG_UNPACK)/.git),) +distclean:: + $(call DELDIR, $(LSYSLOG_UNPACK)) + $(call DELFILE, $(LSYSLOG_TARBALL)) + +context:: $(LSYSLOG_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 = lsyslog + +include $(APPDIR)/interpreters/lua/Module.mk + +include $(APPDIR)/Application.mk