Skip to content

Commit 68a96bf

Browse files
authored
Merge pull request #15 from tidesdb/minor-adjustments-code-style-comment-headers-additions
Added clang format, added code_formatter.sh, formatted code, added he…
2 parents 01a7660 + d8f6468 commit 68a96bf

8 files changed

+66
-7
lines changed

.clang-format

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
BasedOnStyle: Google
2+
IndentWidth: 4
3+
ColumnLimit: 100
4+
AllowShortFunctionsOnASingleLine: None
5+
KeepEmptyLinesAtTheStartOfBlocks: false
6+
AlignConsecutiveMacros: true
7+
BreakBeforeBraces: Allman

.github/workflows/build_and_test_lua.yml

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ jobs:
3535
cd tidesdb
3636
cmake -DTIDESDB_WITH_SANITIZER=OFF --debug-output -S . -B build && make -C build/
3737
sudo cmake --install build
38+
sudo ldconfig
3839
3940
4041
- name: Install Lua and Lua development files

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,8 @@ luac.out
4242
#cmake build artifacts
4343
build
4444

45+
cmake-build-debug
46+
.idea
47+
build
48+
.vscode
49+

CMakeLists.txt

+6-4
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ set(CMAKE_C_STANDARD 23)
55
set(PROJECT_VERSION 0.1.0)
66
add_compile_options(-Wextra -Wall)
77

8-
find_package(Lua 5.3 REQUIRED)
8+
# set CMP0156 policy
9+
cmake_policy(SET CMP0156 NEW)
10+
11+
find_library(LIBRARY_TIDEDB NAMES tidesdb REQUIRED) # require tidesdb library
912

10-
find_library(LIBRARY_TIDEDB NAMES tidesdb)
13+
find_package(Lua 5.3 REQUIRED)
1114

1215
add_library(tidesdb_lua SHARED tidesdb-lua.c)
1316
target_include_directories(tidesdb_lua PRIVATE ${LUA_INCLUDE_DIR})
14-
target_link_libraries(tidesdb_lua ${LIBRARY_TIDEDB})
15-
target_link_libraries(tidesdb_lua ${LUA_LIBRARIES})
17+
target_link_libraries(tidesdb_lua ${LUA_LIBRARIES} tidesdb)

code_formatter.sh

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
# Before submitting a PR, run this script to format the source code.
4+
5+
EXCLUDE_DIRS="external\|cmake-build-debug\|.idea|build|cmake"
6+
7+
find . -type f -name "*.c" -o -name "*.h" | grep -v "$EXCLUDE_DIRS" | xargs clang-format -i

spec/tidesdb_spec.lua

+19
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
--[[
2+
*
3+
* Copyright (C) TidesDB
4+
*
5+
* Original Author: Evgeny Kornev
6+
*
7+
* Licensed under the Mozilla Public License, v. 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* https://www.mozilla.org/en-US/MPL/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,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*
19+
]]
120
package.cpath = 'tidesdb-lua/build/?.so;build/?.so;' .. package.cpath
221

322
describe("load", function()

test_lua.lua

+19
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
--[[
2+
*
3+
* Copyright (C) TidesDB
4+
*
5+
* Original Author: Evgeny Kornev
6+
*
7+
* Licensed under the Mozilla Public License, v. 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* https://www.mozilla.org/en-US/MPL/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,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*
19+
]]
120
local lib = require("libtidesdb_lua")
221

322
local code, message

tidesdb-lua.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* Copyright (C) Evgeny Kornev
3+
* Copyright (C) TidesDB
44
*
55
* Original Author: Evgeny Kornev
66
*
@@ -16,13 +16,12 @@
1616
* See the License for the specific language governing permissions and
1717
* limitations under the License.
1818
*/
19-
2019
#include <lua.h>
2120
#include <lauxlib.h>
2221
#include <lualib.h>
2322
#include <stdio.h>
2423
#include <string.h>
25-
#include <tidesdb.h>
24+
#include <tidesdb/tidesdb.h>
2625

2726
#define LUA_RET_CODE() \
2827
if(ret) \

0 commit comments

Comments
 (0)