Skip to content

Commit

Permalink
exchange usage of inlined libraries with git submodules
Browse files Browse the repository at this point in the history
Integrate the git submodules as subproject in
the meson.build as static library and pass down
default values for specific meson options to the
subprojects. In addition, the other tooling like
clang-tidy script needed to be adjusted to
include the libraries.

Signed-off-by: Michael Engel <[email protected]>
  • Loading branch information
engelmi committed Aug 9, 2023
1 parent e83bfaa commit d3a4351
Show file tree
Hide file tree
Showing 17 changed files with 49 additions and 1,659 deletions.
2 changes: 2 additions & 0 deletions .gitconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[safe]
directory = /root
1 change: 1 addition & 0 deletions .markdownlint-cli2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ globs:

ignores:
- "doc/man/*.md"
- "subprojects/*/*.md"
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ DESTDIR ?=
BUILDDIR=builddir

CODESPELL_PARAMS=\
-S Makefile,imgtype,copy,AUTHORS,bin,.git,CHANGELOG.md,changelog.txt,.cirrus.yml,"*.xz,*.gz,*.tar,*.tgz,*ico,*.png,*.1,*.5,*.orig,*.rej,*.xml,*xsl",build.ninja,intro-targets.json,./tests/tests/tier0/proxy-service-fails-on-typo-in-file/systemd/simple.service,tags,./builddir\
-S Makefile,imgtype,copy,AUTHORS,bin,.git,CHANGELOG.md,changelog.txt,.cirrus.yml,"*.xz,*.gz,*.tar,*.tgz,*ico,*.png,*.1,*.5,*.orig,*.rej,*.xml,*xsl",build.ninja,intro-targets.json,./tests/tests/tier0/proxy-service-fails-on-typo-in-file/systemd/simple.service,tags,./builddir,./subprojects,\
-L keypair,flate,uint,iff,od,ERRO

build:
Expand Down
9 changes: 7 additions & 2 deletions build-scripts/build-srpm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,13 @@ sed \

# Prepare source archive
[[ -d rpmbuild/SOURCES ]] || mkdir -p rpmbuild/SOURCES
git archive --format=tar --prefix=hirte-$VERSION/ --add-file=hirte.spec HEAD \
| gzip -9 > rpmbuild/SOURCES/hirte-$VERSION.tar.gz

git archive --format=tar --prefix=hirte-$VERSION/ --add-file=hirte.spec -o hirte-$VERSION.tar HEAD
git submodule foreach --recursive \
"git archive --prefix=hirte-$VERSION/\$path/ --output=\$sha1.tar HEAD && \
tar --concatenate --file=$(pwd)/hirte-$VERSION.tar \$sha1.tar && rm \$sha1.tar"
gzip hirte-$VERSION.tar
mv hirte-$VERSION.tar.gz rpmbuild/SOURCES/

# Build source package
rpmbuild \
Expand Down
8 changes: 7 additions & 1 deletion build-scripts/clang-tidy-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ additional_opts=$1
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
SRC_DIR=$SCRIPT_DIR/../src
BUILD_DIR=$SCRIPT_DIR/../builddir
SUBPROJECTS_DIR=$SCRIPT_DIR/../subprojects

ALL_SRC_FILES=$(find $SRC_DIR -name "*.[ch]" \
! -path "$SRC_DIR/libhirte/ini/ini.[ch]" \
Expand All @@ -18,5 +19,10 @@ do
echo "Linting $src_file..."

# Header config.h is autogenerated during the build, so it needs to be added manually here as a parameter
clang-tidy $additional_opts --quiet $src_file -- -I $SRC_DIR -I $BUILD_DIR -include config.h
clang-tidy $additional_opts --quiet $src_file -- \
-I $SRC_DIR \
-I $BUILD_DIR \
-I $SUBPROJECTS_DIR/hashmap.c \
-I $SUBPROJECTS_DIR/inih \
-include config.h
done
24 changes: 16 additions & 8 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,6 @@ if api_bus == 'user'
common_cflags += '-DUSE_USER_API_BUS'
endif

# inih library options
# Set option of maximum line length
# 500 characters for actual value
# 20 characters as buffer (key, library internal usage, etc.)
common_cflags += '-DINI_MAX_LINE=520'
# Set option to abort parsing on first error
common_cflags += '-DINI_STOP_ON_FIRST_ERROR=1'

# Build time configuration header file
conf = configuration_data()

Expand All @@ -55,6 +47,22 @@ config_h = configure_file(
add_project_arguments('-include', 'config.h', language : 'c')


# (External) subprojects used by hirte
inih = subproject('inih', default_options: [
'default_library=static', # include it as static library
'-Dinih:distro_install=false', # disable distro install so other options are used
'-Dinih:max_line_length=520', # set maximum line length so that ~500 characters can be used as value
'-Dinih:stop_on_first_error=true', # abort after first error when parsing file
])
inih_dep = inih.get_variable('inih_dep')

hashmapc = subproject('hashmap.c', default_options: [
'default_library=static', # include it as static library
'werror=false' # don't treat warnings as errors since it
])
hashmapc_dep = hashmapc.get_variable('hashmapc_dep')


# Subdirectory for the shared library.
subdir('src/libhirte')

Expand Down
4 changes: 3 additions & 1 deletion src/agent/agent.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
#include <stdbool.h>
#include <sys/socket.h>

// NOLINTNEXTLINE
#include <hashmap.h>

#include "libhirte/common/cfg.h"
#include "libhirte/common/common.h"
#include "libhirte/hashmap/hashmap.h"

#include "types.h"

Expand Down
2 changes: 2 additions & 0 deletions src/agent/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ executable(
node_src,
dependencies: [
systemd_dep,
inih_dep,
hashmapc_dep,
],
link_with: [
hirte_lib,
Expand Down
5 changes: 3 additions & 2 deletions src/libhirte/common/cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
#include <string.h>
#include <unistd.h>

#include <hashmap.h>
#include <ini.h>

#include "libhirte/common/list.h"
#include "libhirte/common/network.h"
#include "libhirte/hashmap/hashmap.h"
#include "libhirte/ini/ini.h"

#include "cfg.h"
#include "common.h"
Expand Down
20 changes: 0 additions & 20 deletions src/libhirte/hashmap/LICENSE

This file was deleted.

Loading

0 comments on commit d3a4351

Please sign in to comment.