Skip to content

Commit cb812cb

Browse files
XuNeoxiaoxiang781216
authored andcommitted
luasyslog: add cmake support
nsh> nsh> lua Lua 5.4.0 Copyright (C) 1994-2020 Lua.org, PUC-Rio > for k,v in pairs(lsyslog) >> do >> print(k,v) >> end open function: 0x402d49c0 FACILITY_LOCAL4 0.0 FACILITY_AUTH 0.0 _COPYRIGHT Copyright (C) 1994-2021 Nicolas Casalini (DarkGod) FACILITY_DAEMON 0.0 FACILITY_LOCAL1 0.0 LOG_WARNING 4.0 close function: 0x402d4990 FACILITY_AUTHPRIV 0.0 LOG_ALERT 1.0 _DESCRIPTION LuaSyslog allows to use log to an unix Syslog daemon, direct or via LuaLogging FACILITY_CRON 0.0 FACILITY_FTP 0.0 LOG_DEBUG 7.0 FACILITY_LOCAL0 0.0 LOG_NOTICE 5.0 FACILITY_LOCAL5 0.0 LOG_EMERG 0.0 FACILITY_LPR 0.0 _VERSION LuaSyslog 2.0.1 FACILITY_LOCAL7 0.0 FACILITY_KERN 0.0 log function: 0x402d4944 FACILITY_LOCAL2 0.0 LOG_INFO 6.0 FACILITY_NEWS 0.0 FACILITY_LOCAL6 0.0 FACILITY_SYSLOG 0.0 FACILITY_USER 0.0 FACILITY_LOCAL3 0.0 FACILITY_UUCP 0.0 LOG_ERR 3.0 FACILITY_MAIL 0.0 LOG_CRIT 2.0 > lsyslog.log(lsyslog.LOG_EMERG, "Hello") Hello > Signed-off-by: xuxingliang <[email protected]>
1 parent e42de5d commit cb812cb

File tree

2 files changed

+100
-0
lines changed

2 files changed

+100
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# ##############################################################################
2+
# apps/interpreters/luamodules/CMakeLists.txt
3+
#
4+
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
5+
# license agreements. See the NOTICE file distributed with this work for
6+
# additional information regarding copyright ownership. The ASF licenses this
7+
# file to you under the Apache License, Version 2.0 (the "License"); you may not
8+
# use this file except in compliance with the License. You may obtain a copy of
9+
# the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16+
# License for the specific language governing permissions and limitations under
17+
# the License.
18+
#
19+
# ##############################################################################
20+
21+
nuttx_add_subdirectory()
22+
23+
nuttx_generate_kconfig(MENUDESC "LUA Modules")
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# ##############################################################################
2+
# apps/interpreters/luamodules/luasyslog/CMakeLists.txt
3+
#
4+
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
5+
# license agreements. See the NOTICE file distributed with this work for
6+
# additional information regarding copyright ownership. The ASF licenses this
7+
# file to you under the Apache License, Version 2.0 (the "License"); you may not
8+
# use this file except in compliance with the License. You may obtain a copy of
9+
# the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16+
# License for the specific language governing permissions and limitations under
17+
# the License.
18+
#
19+
# ##############################################################################
20+
21+
if(CONFIG_LUA_LSYSLOG_MODULE)
22+
23+
# ############################################################################
24+
# Config and Fetch luasyslog
25+
# ############################################################################
26+
27+
set(SRC_DIR ${CMAKE_CURRENT_LIST_DIR}/lsyslog)
28+
29+
if(NOT EXISTS ${SRC_DIR})
30+
set(LSYSLOG_URL https://github.com/lunarmodules/luasyslog/archive/refs/tags)
31+
FetchContent_Declare(
32+
lsyslog_fetch
33+
URL ${LSYSLOG_URL}/${CONFIG_LUA_LSYSLOG_VERSION}.tar.gz SOURCE_DIR
34+
${SRC_DIR}
35+
DOWNLOAD_NO_PROGRESS true
36+
TIMEOUT 30)
37+
38+
FetchContent_GetProperties(lsyslog_fetch)
39+
40+
if(NOT lua_fetch_POPULATED)
41+
FetchContent_Populate(lsyslog_fetch)
42+
endif()
43+
endif()
44+
45+
# ############################################################################
46+
# Flags
47+
# ############################################################################
48+
set(LUA_SYSTEM_READLINE_DEF
49+
[=[
50+
#define openlog(a,b,c) {(void)a; (void)c;}
51+
#define closelog() {}
52+
]=])
53+
54+
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/def_lua_readline.h
55+
"${LUA_SYSTEM_READLINE_DEF}")
56+
list(APPEND CFLAGS
57+
"SHELL:-include ${CMAKE_CURRENT_BINARY_DIR}/def_lua_readline.h")
58+
59+
# ############################################################################
60+
# Sources
61+
# ############################################################################
62+
63+
set(CSRCS ${SRC_DIR}/lsyslog.c)
64+
65+
# ############################################################################
66+
# Include Directory
67+
# ############################################################################
68+
69+
# ############################################################################
70+
# Library Configuration
71+
# ############################################################################
72+
73+
target_sources(apps PRIVATE ${CSRCS})
74+
75+
# register lua mod
76+
nuttx_add_luamod(MODS lsyslog)
77+
endif()

0 commit comments

Comments
 (0)