1
0
mirror of https://github.com/falk-werner/webfused synced 2024-10-27 20:44:08 +00:00

Merge pull request #7 from falk-werner/meson_build

Switched build system to meson
This commit is contained in:
Falk Werner 2020-06-06 13:01:59 +02:00 committed by GitHub
commit 566bf39bba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 213 additions and 370 deletions

5
.gitignore vendored
View File

@ -1,3 +1,4 @@
/build/
/.deps/
/.vscode/
/.vscode/
/subprojects/*
!/subprojects/*.wrap

View File

@ -16,7 +16,6 @@ addons:
- ca-certificates
- openssl
- libssl-dev
- uuid-dev
- udev
- gettext
- python3
@ -30,81 +29,22 @@ addons:
env:
matrix:
- BUILD_TYPE=Coverage CHECK_TARGET=check
- BUILD_TYPE=Debug CHECK_TARGET=memcheck
- BUILD_TPYE=Release CHECK_TARGET=check
- BUILD_TYPE=MinSizeRel CHECK_TARGET=check
- BUILD_TYPE=debug COVERAGE=true CHECK_OPTS=
- BUILD_TYPE=debug COVERAGE=false CHECK_OPTS=--wrap='valgrind --error-exitcode=42'
- BUILD_TYPE=release COVERAGE=false CHECK_OPTS=
- BUILD_TYPE=minsize COVERAGE=false CHECK_OPTS=
before_install:
- mkdir .deps
- cd .deps
# libfuse
- sudo pip3 install --system meson
- wget https://github.com/libfuse/libfuse/archive/fuse-3.9.1.tar.gz -O fuse.tar.gz
- tar -xf fuse.tar.gz
- cd libfuse-fuse-3.9.1
- mkdir .build
- cd .build
- meson ..
- ninja
- sudo ninja install
- cd ..
- cd ..
# libwebsockets
- wget https://github.com/warmcat/libwebsockets/archive/v3.2.0.tar.gz -O libwebsockets.tar.gz
- tar -xf libwebsockets.tar.gz
- cd libwebsockets-3.2.0
- mkdir .build
- cd .build
- cmake ..
- make
- sudo make install
- cd ..
- cd ..
# jansson
- wget https://github.com/akheron/jansson/archive/v2.12.tar.gz -O jansson.tar.gz
- tar -xf jansson.tar.gz
- cd jansson-2.12
- mkdir .build
- cd .build
- cmake ..
- make
- sudo make install
- cd ..
- cd ..
# libwebfuse
- wget https://github.com/falk-werner/webfuse/archive/v0.2.0.tar.gz -O webfuse.tar.gz
- tar -xf webfuse.tar.gz
- cd webfuse-0.2.0
- mkdir .build
- cd .build
- cmake -DWITHOUT_TESTS=ON ..
- make
- sudo make install
- cd ..
- cd ..
# gtest
- wget https://github.com/google/googletest/archive/release-1.10.0.tar.gz
- tar -xf release-1.10.0.tar.gz
- cd googletest-release-1.10.0
- mkdir .build
- cd .build
- cmake ..
- make
- sudo make install
- cd ..
- cd ..
- cd ..
before_script:
- mkdir build
- meson -Dbuildtype=$BUILD_TYPE -Db_coverage=$COVERAGE build
- cd build
- cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE ..
- ninja
script:
- export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib:/usr/local/lib/x86_64-linux-gnu"
- make $CHECK_TARGET
- meson test $CHECK_OPTS
after_success:
- bash <(curl -s https://codecov.io/bash)

View File

@ -1,244 +0,0 @@
cmake_minimum_required (VERSION 3.10)
project(webfused VERSION 0.3.0 DESCRIPTION "Webfuse daemon")
option(WITHOUT_TESTS "disable unit tests" OFF)
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake")
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(FUSE3 REQUIRED fuse3)
pkg_check_modules(LWS REQUIRED libwebsockets)
pkg_check_modules(JANSSON REQUIRED jansson)
pkg_check_modules(UUID REQUIRED uuid)
pkg_check_modules(LIBCONFIG REQUIRED libconfig)
pkg_check_modules(OPENSSL REQUIRED openssl)
pkg_check_modules(WEBFUSE REQUIRED libwebfuse-adapter)
find_package(Pam REQUIRED)
add_definitions(-D_FILE_OFFSET_BITS=64)
include_directories(
"src"
${WEBFUSE_INCLUDE_DIRS}
)
link_directories(
${WEBFUSE_LIBRARY_DIRS}
)
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(C_WARNINGS -Wall -Wextra)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
include(coverage)
add_library(userdb STATIC
src/userdb/userdb.c
)
target_include_directories(userdb PUBLIC
${LIBCONFIG_INCLUDE_DIRS}
${OPENSSL_INCLUDE_DIRS}
${JANSSON_INCLUDE_DIRS}
)
target_compile_options(userdb PUBLIC ${OPENSSL_CFLAGS_OTHER})
add_library(webfused-static STATIC
src/webfused/daemon.c
src/webfused/mountpoint_factory.c
src/webfused/change_user.c
src/webfused/config/config.c
src/webfused/config/factory.c
src/webfused/config/settings.c
src/webfused/auth/authenticator.c
src/webfused/auth/factory.c
src/webfused/auth/file_authenticator.c
src/webfused/auth/pam_authenticator.c
src/webfused/log/log.c
src/webfused/log/logger.c
src/webfused/log/manager.c
src/webfused/log/stderr_logger.c
src/webfused/log/syslog_logger.c
)
add_executable(webfused
src/webfused/main.c
)
target_link_libraries(webfused PUBLIC
webfused-static
userdb
${LIBCONFIG_LIBRARIES}
${OPENSSL_LIBRARIES}
${WEBFUSE_LIBRARIES}
${UUID_LIBRARIES}
${PAM_LIBRARIES}
)
target_compile_options(webfused PUBLIC ${OPENSSL_CFLAGS_OTHER})
install(TARGETS webfused DESTINATION bin)
add_executable(webfuse-passwd
src/passwd/main.c
)
target_link_libraries(webfuse-passwd PUBLIC
userdb
${OPENSSL_LIBRARIES}
${JANSSON_LIBRARIES}
)
target_include_directories(webfuse-passwd PUBLIC
example/passwd
example/lib/userdb/include
${OPENSSL_INCLUDE_DIRS}
${JANSSON_INCLUDE_DIRS}
)
target_compile_options(webfuse-passwd PUBLIC ${OPENSSL_CFLAGS_OTHER})
install(TARGETS webfuse-passwd DESTINATION bin)
if(NOT WITHOUT_TESTS)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
include (CTest)
pkg_check_modules(GTEST gtest_main)
include(GoogleTest)
pkg_check_modules(GMOCK gmock)
add_executable(alltests
test/mock/config_builder.cc
test/mock/logger.cc
test/mock/credentials.cc
test/mock/settings.cc
test/mock/pam.cc
test/mock/libconfig.cc
test/mock/linux.cc
test/mock/server.cc
test/config/configfile.cc
test/config/configfile_version.cc
test/config/configfile_server.cc
test/config/configfile_auth.cc
test/config/configfile_filesystem.cc
test/config/configfile_log.cc
test/config/configfile_user.cc
test/config/config.cc
test/config/settings.cc
test/auth/factory.cc
test/auth/file_authenticator.cc
test/auth/pam_authenticator.cc
test/log/log.cc
test/log/log_manager.cc
test/log/stderr_logger.cc
test/log/syslog_logger.cc
test/daemon.cc
test/change_user.cc
test/mountpoint_factory.cc
test/userdb.cc
)
target_include_directories(alltests PRIVATE
src
test
${GMOCK_INCLUDE_DIRS}
${GTEST_INCLUDE_DIRS}
)
target_compile_options(alltests PRIVATE ${GMOCK_CFLAGS} ${GTEST_CFLAGS} "-pthread")
target_link_libraries(alltests PRIVATE
-Wl,--wrap=wf_credentials_type
-Wl,--wrap=wf_credentials_get
-Wl,--wrap=wf_server_create
-Wl,--wrap=wfd_settings_get_string
-Wl,--wrap=wfd_settings_get_string_or_default
-Wl,--wrap=wfd_settings_get_bool
-Wl,--wrap=wfd_config_create
-Wl,--wrap=wfd_config_dispose
-Wl,--wrap=wfd_config_set_server_vhostname
-Wl,--wrap=wfd_config_set_server_port
-Wl,--wrap=wfd_config_set_server_key
-Wl,--wrap=wfd_config_set_server_cert
-Wl,--wrap=wfd_config_set_server_document_root
-Wl,--wrap=wfd_config_add_auth_provider
-Wl,--wrap=wfd_config_add_filesystem
-Wl,--wrap=wfd_config_set_logger
-Wl,--wrap=wfd_config_set_user
-Wl,--wrap=pam_start
-Wl,--wrap=pam_end
-Wl,--wrap=pam_strerror
-Wl,--wrap=pam_authenticate
-Wl,--wrap=pam_acct_mgmt
-Wl,--wrap=config_setting_get_elem
-Wl,--wrap=getuid
-Wl,--wrap=getgrnam
-Wl,--wrap=setgid
-Wl,--wrap=setgroups
-Wl,--wrap=getpwnam
-Wl,--wrap=setuid
webfused-static
userdb
${LIBCONFIG_LIBRARIES}
${WEBFUSE_LIBRARIES}
${UUID_LIBRARIES}
${PAM_LIBRARIES}
${OPENSSL_LIBRARIES}
${GMOCK_LIBRARIES}
${GTEST_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
)
# copy test data
configure_file(etc/webfused.conf webfused.conf COPYONLY)
configure_file(test/invalid.conf invalid.conf COPYONLY)
configure_file(test/test_passwd.json test_passwd.json COPYONLY)
enable_testing()
gtest_discover_tests(alltests TEST_PREFIX alltests:)
add_custom_target(check
./alltests)
add_dependencies(check alltests)
add_custom_target(memcheck
valgrind --leak-check=full --error-exitcode=1 ./alltests)
add_dependencies(memcheck alltests)
add_custom_target(coverage
mkdir -p coverage
COMMAND lcov --initial --capture --directory . --output-file coverage/lcov_base.info --rc lcov_branch_coverage=1
COMMAND ./alltests
COMMAND lcov --capture --directory . --output-file coverage/lcov.info --rc lcov_branch_coverage=1
COMMAND lcov -a coverage/lcov_base.info -a coverage/lcov.info --output-file coverage/lcov.info --rc lcov_branch_coverage=1
COMMAND lcov --remove coverage/lcov.info '/usr/*' --output-file coverage/lcov.info --rc lcov_branch_coverage=1
COMMAND lcov --remove coverage/lcov.info '*/test/*' --output-file coverage/lcov.info --rc lcov_branch_coverage=1
COMMAND lcov --remove coverage/lcov.info '*/main.c' --output-file coverage/lcov.info --rc lcov_branch_coverage=1
)
add_dependencies(coverage alltests)
add_custom_target(coverage-report
COMMAND genhtml --branch-coverage --highlight --legend coverage/lcov.info --output-directory coverage/report
)
add_dependencies(coverage-report coverage)
endif(NOT WITHOUT_TESTS)

View File

@ -1,22 +0,0 @@
find_package(PkgConfig)
pkg_check_modules(PC_PAM QUIET pam)
set(PAM_DEFINITIONS ${PC_PAM_CFLAGS_OTHER})
find_path(PAM_INCLUDE_DIR security/pam_appl.h
HINTS ${PC_PAM_INCLUDEDIR} ${PC_PAM_INCLUDE_DIRS}
)
find_library(PAM_LIBRARY NAMES pam
HINTS ${PC_PAM_LIBDIR} ${PC_PAM_LIBRARY_DIRS}
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Pam DEFAULT_MSG
PAM_LIBRARY PAM_INCLUDE_DIR
)
mark_as_advanced(PAM_INCLUDE_DIR PAM_LIBRARY)
set(PAM_LIBRARIES ${PAM_LIBRARY})
set(PAM_INCLUDE_DIRS ${PAM_INCLUDE_DIR})

View File

@ -1,30 +0,0 @@
set(CMAKE_C_FLAGS_COVERAGE
"${CMAKE_C_FLAGS_DEBUG} -pg --coverage -fprofile-arcs -ftest-coverage"
CACHE STRING "Flags used by the C compiler during coverage builds"
FORCE
)
set(CMAKE_CXX_FLAGS_COVERAGE
"${CMAKE_CXX_FLAGS_DEBUG} -pg --coverage -fprofile-arcs -ftest-coverage"
CACHE STRING "Flags used by the C++ compiler during coverage builds."
FORCE
)
set(CMAKE_EXE_LINKER_FLAGS_COVERAGE
""
CACHE STRING "Flags used for linking binaries during coverage builds."
FORCE
)
set(CMAKE_SHARED_LINKER_FLAGS_COVERAGE
""
CACHE STRING "Flags used by the shared libraries linker during coverage builds."
FORCE
)
mark_as_advanced(
CMAKE_C_FLAGS_COVERAGE
CMAKE_CXX_FLAGS_COVERAGE
CMAKE_EXE_LINKER_FLAGS_COVERAGE
CMAKE_SHARED_LINKER_FLAGS_COVERAGE
)

View File

@ -2,11 +2,9 @@
To install dependecies, see below.
cd webfused
mkdir build
meson build
cd build
cmake ..
make
ninja
./webfused -f webfused.conf
## Dependencies
@ -20,6 +18,10 @@ To install dependecies, see below.
- [linux-pam](http://www.linux-pam.org/)
- [Google Test](https://github.com/google/googletest) *(Test only)*
It is recommended to provide all dependencies outside of the project.
To simply development, some dependencies are bundled using meson wrap files. Note that installing webfused will also install subprojects, when they are used (this is typically not what you want).
### libfuse
To install libfuse, meson is needed. Please refer to [meson quick guide](https://mesonbuild.com/Quick-guide.html) for setup instructions.

155
meson.build Normal file
View File

@ -0,0 +1,155 @@
project('webfused', 'c', 'cpp', version: '0.3.0', license: 'LGPL-3.0+')
without_tests = get_option('without_tests')
c_compiler = meson.get_compiler('c')
openssl_dep = dependency('openssl', version: '>=1.1.1')
libconfig_dep = dependency('libconfig', version: '>=1.5')
pam_dep = c_compiler.find_library('pam')
libwebsockets_dep = dependency('libwebsockets', version: '>=4.0.13', required: false)
if not libwebsockets_dep.found()
cmake = import('cmake')
libwebsockets = cmake.subproject('libwebsockets')
libwebsockets_dep = libwebsockets.dependency('websockets_shared')
endif
jansson_dep = dependency('jansson', version: '>=2.11', fallback: ['jansson', 'jansson_dep'])
libfuse_dep = dependency('fuse3', version: '>=3.8.0', fallback: ['fuse3', 'libfuse_dep'])
gtest_dep = dependency('gtest', version: '>=1.10.0', fallback: ['gtest', 'gtest_dep'])
gmock_main_dep = dependency('gmock_main', version: '>=1.10.0', fallback: ['gtest', 'gmock_main_dep'])
webfuse_adapter_dep = dependency('webfuse_adapter', version: '>=0.3.0',
fallback: ['webfuse', 'webfuse_adapter_dep'], default_options: ['without_provider=true'])
inc_dir = include_directories('src')
libuserdb = static_library('userdb',
'src/userdb/userdb.c',
include_directories: inc_dir,
dependencies: [libconfig_dep, openssl_dep, jansson_dep])
libuserdb_dep = declare_dependency(
include_directories: inc_dir,
link_with: libuserdb,
dependencies: [libconfig_dep, openssl_dep, jansson_dep])
libwebfused = static_library('webfused',
'src/webfused/daemon.c',
'src/webfused/mountpoint_factory.c',
'src/webfused/change_user.c',
'src/webfused/config/config.c',
'src/webfused/config/factory.c',
'src/webfused/config/settings.c',
'src/webfused/auth/authenticator.c',
'src/webfused/auth/factory.c',
'src/webfused/auth/file_authenticator.c',
'src/webfused/auth/pam_authenticator.c',
'src/webfused/log/log.c',
'src/webfused/log/logger.c',
'src/webfused/log/manager.c',
'src/webfused/log/stderr_logger.c',
'src/webfused/log/syslog_logger.c',
include_directories: inc_dir,
dependencies: [libuserdb_dep, webfuse_adapter_dep, pam_dep],
install: false)
libwebfused_dep = declare_dependency(
include_directories: inc_dir,
link_with: libwebfused,
dependencies: [libuserdb_dep, webfuse_adapter_dep, pam_dep],
install: false)
webfused = executable('webfused',
'src/webfused/main.c',
include_directories: inc_dir,
dependencies: [libwebfused_dep],
install: true)
install_data('etc/webfused.conf', install_dir: '/etc')
if not without_tests
gtest_dep = dependency('gtest', version: '>=1.10.0', fallback: ['gtest', 'gtest_dep'])
gmock_main_dep = dependency('gmock_main', version: '>=1.10.0', fallback: ['gtest', 'gmock_main_dep'])
webfused_conf = configure_file(input: 'etc/webfused.conf' , output: 'webfused.conf' , copy: true)
invalid_conf = configure_file(input: 'test/invalid.conf' , output: 'invalid.conf' , copy: true)
test_passwd_json = configure_file(input: 'test/test_passwd.json', output: 'test_passwd.json', copy: true)
alltests = executable('alltests',
'test/mock/config_builder.cc',
'test/mock/logger.cc',
'test/mock/credentials.cc',
'test/mock/settings.cc',
'test/mock/pam.cc',
'test/mock/libconfig.cc',
'test/mock/linux.cc',
'test/mock/server.cc',
'test/config/configfile.cc',
'test/config/configfile_version.cc',
'test/config/configfile_server.cc',
'test/config/configfile_auth.cc',
'test/config/configfile_filesystem.cc',
'test/config/configfile_log.cc',
'test/config/configfile_user.cc',
'test/config/config.cc',
'test/config/settings.cc',
'test/auth/factory.cc',
'test/auth/file_authenticator.cc',
'test/auth/pam_authenticator.cc',
'test/log/log.cc',
'test/log/log_manager.cc',
'test/log/stderr_logger.cc',
'test/log/syslog_logger.cc',
'test/daemon.cc',
'test/change_user.cc',
'test/mountpoint_factory.cc',
'test/userdb.cc',
include_directories: ['src', 'test'],
link_args: [
'-Wl,--wrap=wf_credentials_type',
'-Wl,--wrap=wf_credentials_get',
'-Wl,--wrap=wf_server_create',
'-Wl,--wrap=wfd_settings_get_string',
'-Wl,--wrap=wfd_settings_get_string_or_default',
'-Wl,--wrap=wfd_settings_get_bool',
'-Wl,--wrap=wfd_config_create',
'-Wl,--wrap=wfd_config_dispose',
'-Wl,--wrap=wfd_config_set_server_vhostname',
'-Wl,--wrap=wfd_config_set_server_port',
'-Wl,--wrap=wfd_config_set_server_key',
'-Wl,--wrap=wfd_config_set_server_cert',
'-Wl,--wrap=wfd_config_set_server_document_root',
'-Wl,--wrap=wfd_config_add_auth_provider',
'-Wl,--wrap=wfd_config_add_filesystem',
'-Wl,--wrap=wfd_config_set_logger',
'-Wl,--wrap=wfd_config_set_user',
'-Wl,--wrap=pam_start',
'-Wl,--wrap=pam_end',
'-Wl,--wrap=pam_strerror',
'-Wl,--wrap=pam_authenticate',
'-Wl,--wrap=pam_acct_mgmt',
'-Wl,--wrap=config_setting_get_elem',
'-Wl,--wrap=getuid',
'-Wl,--wrap=getgrnam',
'-Wl,--wrap=setgid',
'-Wl,--wrap=setgroups',
'-Wl,--wrap=getpwnam',
'-Wl,--wrap=setuid'
],
dependencies: [
libwebfused_dep,
gtest_dep,
gmock_main_dep])
test('alltests', alltests)
endif

1
meson_options.txt Normal file
View File

@ -0,0 +1 @@
option('without_tests', type: 'boolean', value: false, description: 'disable unit tests')

View File

@ -133,7 +133,7 @@ int wfd_daemon_run(int argc, char * argv[])
{
while (!shutdown_requested)
{
wf_server_service(server, WFD_SERVICE_TIMEOUT);
wf_server_service(server);
}
wf_server_dispose(server);

7
subprojects/fuse3.wrap Normal file
View File

@ -0,0 +1,7 @@
[wrap-file]
directory = libfuse-fuse-3.8.0
source_url = https://github.com/libfuse/libfuse/archive/fuse-3.8.0.tar.gz
source_filename = fuse-3.8.0.tar.gz
source_hash = 1781225ba4d11d76eb105e02e54976939974547eb40bab4b4e91167854224024

10
subprojects/gtest.wrap Normal file
View File

@ -0,0 +1,10 @@
[wrap-file]
directory = googletest-release-1.10.0
source_url = https://github.com/google/googletest/archive/release-1.10.0.zip
source_filename = gtest-1.10.0.zip
source_hash = 94c634d499558a76fa649edb13721dce6e98fb1e7018dfaeba3cd7a083945e91
patch_url = https://wrapdb.mesonbuild.com/v1/projects/gtest/1.10.0/1/get_zip
patch_filename = gtest-1.10.0-1-wrap.zip
patch_hash = 04ff14e8880e4e465f6260221e9dfd56fea6bc7cce4c4aff0dc528e4a2c8f514

10
subprojects/jansson.wrap Normal file
View File

@ -0,0 +1,10 @@
[wrap-file]
directory = jansson-2.11
source_url = http://www.digip.org/jansson/releases/jansson-2.11.tar.bz2
source_filename = jansson-2.11.tar.bz2
source_hash = 783132e2fc970feefc2fa54199ef65ee020bd8e0e991a78ea44b8586353a0947
patch_url = https://wrapdb.mesonbuild.com/v1/projects/jansson/2.11/3/get_zip
patch_filename = jansson-2.11-3-wrap.zip
patch_hash = 0bcac510994890048d42658c674e33dd7d88715fc1e3bf49d10012f57b0e0020

View File

@ -0,0 +1,6 @@
[wrap-file]
directory = libwebsockets-4.0.13
source_url = https://github.com/warmcat/libwebsockets/archive/v4.0.13.zip
source_filename = v4.0.13.zip
source_hash = 0914ea3fdec496daf6b6a5c00f7ba1b52eb8cc3d55b66685df92920b232fd7a5

7
subprojects/webfuse.wrap Normal file
View File

@ -0,0 +1,7 @@
[wrap-file]
directory = webfuse-0.3.1
source_url = https://github.com/falk-werner/webfuse/archive/v0.3.1.tar.gz
source_filename = v0.3.1.tar.gz
source_hash = 46624b5f29e8f87dd1aebfce3b13ca87e766bc59546b6e5f49665d2f8c555d62