Skip to content

Commit 549d98a

Browse files
committed
add fu_utils
1 parent 6e70ef9 commit 549d98a

34 files changed

+8652
-40
lines changed

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ PROGRAM := pg_probackup
3737
# pg_probackup sources
3838
OBJS := src/utils/configuration.o src/utils/json.o src/utils/logger.o \
3939
src/utils/parray.o src/utils/pgut.o src/utils/thread.o src/utils/remote.o src/utils/file.o
40+
OBJS += src/fu_util/impl/ft_impl.o src/fu_util/impl/fo_impl.o
4041
OBJS += src/archive.o src/backup.o src/catalog.o src/checkdb.o src/configure.o src/data.o \
4142
src/delete.o src/dir.o src/fetch.o src/help.o src/init.o src/merge.o \
4243
src/parsexlog.o src/ptrack.o src/pg_probackup.o src/restore.o src/show.o src/stream.o \
@@ -87,7 +88,8 @@ endif
8788
undefine PG_MAJORVER
8889

8990
#
90-
PG_CPPFLAGS = -I$(libpq_srcdir) ${PTHREAD_CFLAGS} -I$(top_pbk_srcdir)/src -I$(BORROW_DIR)
91+
PG_CPPFLAGS = -I$(libpq_srcdir) ${PTHREAD_CFLAGS} -I$(top_pbk_srcdir)src -I$(BORROW_DIR)
92+
PG_CPPFLAGS += -I$(top_pbk_srcdir)src/fu_util -Wno-declaration-after-statement
9193
ifdef VPATH
9294
PG_CPPFLAGS += -Isrc
9395
endif

gen_probackup_project.pl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ sub build_pgprobackup
214214
$probackup->AddIncludeDir("$currpath");
215215
$probackup->AddIncludeDir("$currpath/src");
216216
$probackup->AddIncludeDir("$currpath/src/utils");
217+
$probackup->AddIncludeDir("$currpath/src/fu_util");
217218

218219
if ($libpgfeutils)
219220
{

src/fu_util/CMakeLists.txt

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
cmake_minimum_required(VERSION 3.16)
2+
project(fu_utils VERSION 0.1 LANGUAGES C)
3+
4+
set(CMAKE_C_STANDARD 99)
5+
set(CMAKE_C_EXTENSIONS true)
6+
7+
include(CheckCSourceCompiles)
8+
9+
add_library(fu_utils impl/ft_impl.c impl/fo_impl.c)
10+
11+
set(THREADS_PREFER_PTHREAD_FLAG ON)
12+
find_package(Threads REQUIRED)
13+
target_link_libraries(fu_utils PRIVATE Threads::Threads)
14+
15+
# Detect for installed beautiful https://github.com/ianlancetaylor/libbacktrace
16+
include_directories(.)
17+
find_library(LIBBACKTRACE backtrace)
18+
if(LIBBACKTRACE)
19+
set(CMAKE_REQUIRED_LIBRARIES backtrace)
20+
check_c_source_compiles("
21+
#include <backtrace.h>
22+
int main(void) {
23+
struct backtrace_state *st = backtrace_create_state(NULL, 0, NULL, NULL);
24+
return 0;
25+
}
26+
" HAVE_LIBBACKTRACE)
27+
if (HAVE_LIBBACKTRACE)
28+
target_compile_definitions(fu_utils PRIVATE HAVE_LIBBACKTRACE)
29+
endif()
30+
endif()
31+
32+
configure_file(fu_utils_cfg.h.in fu_utils_cfg.h)
33+
target_include_directories(fu_utils INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}")
34+
target_include_directories(fu_utils PRIVATE "${PROJECT_BINARY_DIR}")
35+
target_link_libraries(fu_utils PUBLIC backtrace)
36+
37+
install(TARGETS fu_utils DESTINATION lib)
38+
install(FILES fm_util.h ft_util.h fo_obj.h
39+
ft_sort.inc.h ft_ss_examples.h ft_search.inc.h ft_array.inc.h
40+
ft_ar_examples.h "${PROJECT_BINARY_DIR}/fu_utils_cfg.h"
41+
DESTINATION include/fu_utils)
42+
install(FILES impl/ft_impl.h impl/fo_impl.h DESTINATION include/fu_utils/impl)
43+
44+
add_subdirectory(test)

src/fu_util/LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
MIT License
2+
3+
Copyright (c) 2022-2022 Postgres Professional
4+
Copyright (c) 2022-2022 Yura Sokolov
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.

0 commit comments

Comments
 (0)