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 10, 2023
1 parent 1519c2e commit 4c1eeb2
Show file tree
Hide file tree
Showing 23 changed files with 72 additions and 1,664 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: 'true'
# Use githash of a tested commit instead of merge commit
ref: ${{ github.event.pull_request.head.sha }}

Expand Down Expand Up @@ -64,6 +65,8 @@ jobs:
- name: Checkout sources
uses: actions/checkout@v3
with:
submodules: 'true'

- name: Download artifact
uses: actions/download-artifact@v3
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@v3
with:
submodules: 'true'

- name: Check SPDX headers
run: |
Expand All @@ -66,6 +68,8 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@v3
with:
submodules: 'true'

- name: Initialize meson configuration
run: |
Expand All @@ -90,6 +94,8 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@v3
with:
submodules: 'true'

- name: Running markdown lint
uses: DavidAnson/markdownlint-cli2-action@v9
Expand All @@ -107,6 +113,8 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@v3
with:
submodules: 'true'

- name: Run flake8
run: |
Expand All @@ -126,6 +134,8 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@v3
with:
submodules: 'true'

- name: Install dependencies
run: |
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@v3
with:
submodules: 'true'

- name: Install dependencies
run: |
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@v3
with:
submodules: 'true'

- name: Building hirte
run: |
Expand Down
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"
6 changes: 2 additions & 4 deletions LICENSES/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,5 @@ The following exceptions apply:
* Files `selinux/meson.build` and `selinux/build-selinux.sh` are copied from
[flatpak](https://github.com/flatpak/flatpak) project and they are licensed under the original license,
**LGPL-2.1-or-later**.
* Files under `src/libhirte/ini/` are copied from [inih](https://github.com/benhoyt/inih) project and they're
licensed under the original license, **BSD-3-Clause**.
* Files under `src/libhirte/hashmap/` are copied from [hashmap.c](https://github.com/tidwall/hashmap.c) project
and they are licensed under the original license, **MIT**.
* Files under [`subprojects/`](../subprojects/) are integrated as git submodules and they are licensed under the
respective original license.
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
1 change: 1 addition & 0 deletions build-scripts/spdx-header-chech.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ result=0
found_files="
$(find -type f -regex ${CHECKED_FILES} \
-not -path './builddir/*' \
-not -path './subprojects/*' \
-not -path './doc/arch/*')
"

Expand Down
26 changes: 17 additions & 9 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,14 +47,30 @@ 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')

# Configuration files
subdir('config')

# selinux
subdir('selinux')
#subdir('selinux')

# build each binary
subdir('src/manager')
Expand Down
3 changes: 2 additions & 1 deletion src/agent/agent.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
#include <stdbool.h>
#include <sys/socket.h>

#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 4c1eeb2

Please sign in to comment.