Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
  • Loading branch information
zhaojh329 committed May 3, 2022
0 parents commit f1ec3cb
Show file tree
Hide file tree
Showing 40 changed files with 9,529 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## Environment

* arch:
* os:
* version:

## Description

```
Formating code blocks by wrapping them with pairs of ```
```
32 changes: 32 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: build
on: push
jobs:
build:
runs-on: ubuntu-20.04
strategy:
matrix:
include:
- lua: lua5.1
name: lua5.1
pkg: liblua5.1-0-dev
- lua: lua5.2
name: lua5.2
pkg: liblua5.2-dev
- lua: lua5.3
name: lua5.3
pkg: liblua5.3-dev
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: build
env:
name: ${{ matrix.name }}
pkg: ${{ matrix.pkg }}
run: |
sudo apt install -y libev-dev libjson-c-dev libssl-dev libmnl-dev $pkg
git clone https://git.openwrt.org/project/libubox.git
git clone https://git.openwrt.org/project/ubus.git
cd libubox && cmake . -DBUILD_LUA=OFF && sudo make install && cd ..
cd ubus && cmake . -DBUILD_LUA=OFF && sudo make install && cd ..
cmake . && make && sudo make install
33 changes: 33 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: release

on:
push:
tags:
- 'v*'

jobs:
release:
runs-on: ubuntu-20.04

steps:
- id: get-version
uses: battila7/get-version-action@v2

- uses: actions/checkout@v3
with:
submodules: true

- id: release-asset
run: |
version=${{ steps.get-version.outputs.version-without-v }}
cd ..
cp -r lua-eco lua-eco-$version
rm -rf lua-eco-$version/.git* lua-eco-$version/ssl/.git* lua-eco-$version/log/.git*
tar zcfv lua-eco-$version.tar.gz lua-eco-$version
- uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
draft: true
prerelease: false
files: ../lua-eco-*.tar.gz
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "ssl"]
path = ssl
url = https://github.com/zhaojh329/ssl.git
[submodule "log"]
path = log
url = https://github.com/zhaojh329/log.git
137 changes: 137 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
cmake_minimum_required(VERSION 3.0)

project(lua-eco C)

include(FindPkgConfig)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules/")

#set(CMAKE_VERBOSE_MAKEFILE ON)

# The version number.
set(ECO_VERSION_MAJOR 1)
set(ECO_VERSION_MINOR 0)
set(ECO_VERSION_PATCH 0)

find_package(Lua REQUIRED)
find_package(Libev REQUIRED)

pkg_search_module(LIBMNL libmnl)

add_compile_options(-D_GNU_SOURCE -O -Wall -Werror --std=gnu99)

# configure a header file to pass some of the CMake settings to the source code
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)

include_directories(${LUA_INCLUDE_DIR} ${LIBEV_INCLUDE_DIR})

option(ECO_LOG_SUPPORT "log facilities" ON)
option(ECO_SYS_SUPPORT "operating system facilities" ON)
option(ECO_SOCKET_SUPPORT "socket facilities" ON)
option(ECO_SSL_SUPPORT "ssl facilities" ON)
option(ECO_IW_SUPPORT "wireless utils facilities" ON)
option(ECO_FILE_SUPPORT "file facilities" ON)
option(ECO_UBUS_SUPPORT "ubus" ON)
option(ECO_DNS_SUPPORT "dns resolve" ON)
option(ECO_IP_SUPPORT "ip utils" ON)

set(TARGETS)

add_library(eco MODULE eco.c time.c)
target_link_libraries(eco PRIVATE ${LIBEV_LIBRARY})
set_target_properties(eco PROPERTIES OUTPUT_NAME eco PREFIX "")
target_include_directories(eco PRIVATE ${CMAKE_CURRENT_BINARY_DIR})

if (ECO_LOG_SUPPORT)
add_library(log MODULE log.c log/log.c)
set_target_properties(log PROPERTIES OUTPUT_NAME log PREFIX "")
list(APPEND TARGETS log)
endif()

if (ECO_SYS_SUPPORT)
add_library(sys MODULE sys.c)
target_link_libraries(sys PRIVATE ${LIBEV_LIBRARY})
set_target_properties(sys PROPERTIES OUTPUT_NAME sys PREFIX "")
list(APPEND TARGETS sys)
endif()

if (ECO_SOCKET_SUPPORT)
add_library(socket MODULE socket.c)
target_link_libraries(socket PRIVATE ${LIBEV_LIBRARY})
set_target_properties(socket PROPERTIES OUTPUT_NAME socket PREFIX "")
list(APPEND TARGETS socket)
endif()

if (ECO_IW_SUPPORT)
if (LIBMNL_FOUND)
add_library(iw MODULE iw.c)
target_include_directories(iw PRIVATE ${LIBMNL_INCLUDE_DIRS})
target_link_libraries(iw PRIVATE ${LIBEV_LIBRARY} ${LIBMNL_LIBRARIES})
set_target_properties(iw PROPERTIES OUTPUT_NAME iw PREFIX "")
list(APPEND TARGETS iw)
else()
message(WARNING "Not found libmnl. Skip build eco.iw")
endif()
endif()

if (ECO_SSL_SUPPORT)
add_subdirectory(ssl)
if (SSL_SUPPORT)
add_library(ssl MODULE ssl.c)
target_link_libraries(ssl PRIVATE ${LIBEV_LIBRARY} ${SSL_TARGET})
set_target_properties(ssl PROPERTIES OUTPUT_NAME ssl PREFIX "")
list(APPEND TARGETS ssl)
else()
message(WARNING "Not found any ssl library. Skip build eco.ssl")
endif()
endif()

if (ECO_FILE_SUPPORT)
add_library(file MODULE file.c)
target_link_libraries(file PRIVATE ${LIBEV_LIBRARY})
set_target_properties(file PROPERTIES OUTPUT_NAME file PREFIX "")
list(APPEND TARGETS file)
endif()

if (ECO_UBUS_SUPPORT)
find_library(UBUS NAMES ubus)
if (UBUS)
add_library(lubus MODULE ubus.c)
target_link_libraries(lubus PRIVATE ${LIBEV_LIBRARY} ubus)
set_target_properties(lubus PROPERTIES OUTPUT_NAME ubus PREFIX "")
list(APPEND TARGETS lubus)
else()
message(WARNING "Not found libubus. Skip build eco.ubus")
endif()
endif()

if (ECO_DNS_SUPPORT)
add_library(dns MODULE dns.c)
target_link_libraries(dns PRIVATE ${LIBEV_LIBRARY})
set_target_properties(dns PROPERTIES OUTPUT_NAME dns PREFIX "")
list(APPEND TARGETS dns)
endif()

if (ECO_IP_SUPPORT)
if (LIBMNL_FOUND)
add_library(ip MODULE ip.c)
target_include_directories(ip PRIVATE ${LIBMNL_INCLUDE_DIRS})
target_link_libraries(ip PRIVATE ${LIBEV_LIBRARY} ${LIBMNL_LIBRARIES})
set_target_properties(ip PROPERTIES OUTPUT_NAME ip PREFIX "")
list(APPEND TARGETS ip)
else()
message(WARNING "Not found libmnl. Skip build eco.ip")
endif()
endif()

set(LUA_INSTALL_PREFIX lib/lua/${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR})

install(
TARGETS eco
DESTINATION ${LUA_INSTALL_PREFIX}
)

install(
TARGETS ${TARGETS}
DESTINATION ${LUA_INSTALL_PREFIX}/eco
)
40 changes: 40 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Contributing
================================================================================

If you want to contribute to [lua-eco](https://github.com/zhaojh329/lua-eco), please follow these simple rules:

1. Press the fork button:

![fork](http://oi58.tinypic.com/jj2trm.jpg)

2. Clone the repository from your account with:

```
git clone https://github.com/your_github_username/lua-eco.git
```

3. Create a new branch with:

```
git checkout -b "lua-eco-1-fix"
```
You can name it however you want.

4. Make your changes

5. Commit and push your changes, then make a pull request from Github.

git commit --signoff
git push origin lua-eco-1-fix

6. Awaiting review, if accepted, merged!

**IMPORTANT**

Please, don't forget to update your fork. While you made your changes,
the content of the `master` branch can change because other pull requests
were merged and it can create conflicts. This is why you have to rebase
on `master` every time before pushing your changes and check that your
branch doesn't have any conflicts with `master`.

Thank you.
37 changes: 37 additions & 0 deletions CONTRIBUTING_ZH.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
贡献代码
================================================================================

如果你想为[lua-eco](https://github.com/zhaojh329/lua-eco)贡献代码, 请按照如下步骤:

1. 点击fork按钮:

![fork](http://oi58.tinypic.com/jj2trm.jpg)

2. 从你的github账户克隆仓库代码:

```
git clone https://github.com/你的github账户/lua-eco.git
```

3. 创建一个新的分支:

```
git checkout -b "lua-eco-1-fix"
```
你可以使用一个你想要的分支名称。

4. 修改代码

5. 提交代码并推送到服务器,然后从Github提交pull request。

git commit --signoff
git push origin lua-eco-1-fix

6. 等待审查,如果被接受,你的修改将会被合并到主分支。

**注意**

请不要忘记更新你的fork。当你修改代码时,主分支的内容可能已被修改,因为其他用户提交的pull request被合并,
这就会产生代码冲突。这就是为什么在你每次修改前都要在你的主分支上进行rebase操作

谢谢.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Jianhui Zhao <zhaojh329@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading

0 comments on commit f1ec3cb

Please sign in to comment.