[dbi]: allow to build without mongodb
The tests won't be build as they depend on mongodb. To build without mongodb do meson configure -Dmongodb=false
This commit is contained in:
parent
0accea361c
commit
d973dc1eea
|
@ -16,6 +16,7 @@
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
libdbi_conf = configuration_data()
|
libdbi_conf = configuration_data()
|
||||||
|
libdbi_deps = [libcrypt_dep]
|
||||||
|
|
||||||
dbi_sources = files('''
|
dbi_sources = files('''
|
||||||
ogs-dbi.h
|
ogs-dbi.h
|
||||||
|
@ -31,6 +32,11 @@ mongo_sources = files('''
|
||||||
mongo/ims.c
|
mongo/ims.c
|
||||||
'''.split())
|
'''.split())
|
||||||
|
|
||||||
|
without_mongo_sources = files('''
|
||||||
|
mongo/dummy.c
|
||||||
|
mongo/ogs-mongoc.h
|
||||||
|
'''.split())
|
||||||
|
|
||||||
json_sources = files('''
|
json_sources = files('''
|
||||||
json/json.c
|
json/json.c
|
||||||
external/cjson/cJSON.c
|
external/cjson/cJSON.c
|
||||||
|
@ -38,10 +44,16 @@ json_sources = files('''
|
||||||
libdbi_sources += [json_sources]
|
libdbi_sources += [json_sources]
|
||||||
cjson_inc = include_directories('./external/')
|
cjson_inc = include_directories('./external/')
|
||||||
|
|
||||||
libmongoc_dep = dependency('libmongoc-1.0', required: true)
|
mongodb_optval = get_option('mongodb')
|
||||||
if libmongoc_dep.found()
|
if mongodb_optval
|
||||||
libdbi_conf.set('WITH_MONGOC', 1)
|
libmongoc_dep = dependency('libmongoc-1.0', required: true)
|
||||||
libdbi_sources += [mongo_sources]
|
if libmongoc_dep.found()
|
||||||
|
libdbi_conf.set('WITH_MONGOC', 1)
|
||||||
|
libdbi_sources += [mongo_sources]
|
||||||
|
libdbi_deps += [libmongoc_dep]
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
libdbi_sources += [without_mongo_sources]
|
||||||
endif
|
endif
|
||||||
|
|
||||||
configure_file(output : 'dbi-config-private.h', configuration : libdbi_conf)
|
configure_file(output : 'dbi-config-private.h', configuration : libdbi_conf)
|
||||||
|
@ -60,10 +72,10 @@ libdbi = library('ogsdbi',
|
||||||
version : libogslib_version,
|
version : libogslib_version,
|
||||||
c_args : dbi_cc_flags,
|
c_args : dbi_cc_flags,
|
||||||
include_directories : [libdbi_inc, libinc, cjson_inc],
|
include_directories : [libdbi_inc, libinc, cjson_inc],
|
||||||
dependencies : [libcrypt_dep, libmongoc_dep],
|
dependencies : libdbi_deps,
|
||||||
install : true)
|
install : true)
|
||||||
|
|
||||||
libdbi_dep = declare_dependency(
|
libdbi_dep = declare_dependency(
|
||||||
link_with : libdbi,
|
link_with : libdbi,
|
||||||
include_directories : [libdbi_inc, libinc],
|
include_directories : [libdbi_inc, libinc],
|
||||||
dependencies : [libcrypt_dep, libmongoc_dep])
|
dependencies : libdbi_deps)
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
|
||||||
|
* Author: Alexander Couzens <lynxis@fe80.eu>
|
||||||
|
*
|
||||||
|
* This file is part of Open5GS.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* This file will be used when build without mongodb support to support the old api */
|
||||||
|
#include "ogs-dbi.h"
|
||||||
|
|
||||||
|
int ogs_dbi_init(const char *db_uri)
|
||||||
|
{
|
||||||
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ogs_dbi_mongo_init(const char *db_uri)
|
||||||
|
{
|
||||||
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ogs_mongoc_init(const char *db_uri)
|
||||||
|
{
|
||||||
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ogs_mongoc_final(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
ogs_mongoc_t *ogs_mongoc(void)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,8 @@ subdir('lib')
|
||||||
subdir('src')
|
subdir('src')
|
||||||
subdir('misc')
|
subdir('misc')
|
||||||
# Don't build the tests unless we can run them (either natively or in an exe wrapper)
|
# Don't build the tests unless we can run them (either natively or in an exe wrapper)
|
||||||
build_tests = not meson.is_cross_build() or (meson.is_cross_build() and meson.has_exe_wrapper())
|
# tests also depend on mongodb
|
||||||
|
build_tests = get_option('mongodb') and (not meson.is_cross_build() or (meson.is_cross_build() and meson.has_exe_wrapper()))
|
||||||
if build_tests
|
if build_tests
|
||||||
subdir('tests')
|
subdir('tests')
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
option('metrics_impl', type : 'combo', choices : ['void', 'prometheus'], value : 'void', description : 'libogsmetrics implementation')
|
option('metrics_impl', type : 'combo', choices : ['void', 'prometheus'], value : 'void', description : 'libogsmetrics implementation')
|
||||||
|
option('mongodb', type : 'boolean', value : 'true', description : 'build with mongodb support')
|
||||||
|
|
Loading…
Reference in New Issue