Skip to content

Commit

Permalink
Move build system to meson
Browse files Browse the repository at this point in the history
Also install asciidoc package in CI, so that it will build the
man pages as well.
  • Loading branch information
sergio-correia committed Jan 20, 2020
1 parent 00fc856 commit fed9020
Show file tree
Hide file tree
Showing 10 changed files with 186 additions and 163 deletions.
36 changes: 25 additions & 11 deletions .travis.test
Original file line number Diff line number Diff line change
@@ -1,33 +1,47 @@
#!/bin/bash -ex

findexe() {
while [ ${#} -gt 0 ]; do
while read -r -d: path; do
[ -f "${path}/${1}" ] \
&& [ -x "${path}/${1}" ] \
&& echo "${path}/${1}" && return 0
done <<< "${PATH}:"
shift
done
return 1
}

PM=dnf

case "$1" in
centos:7)
PM=yum
yum install -y yum-utils
yum -y install epel-release
;;
fedora:*)
rt=compiler-rt
;;
esac

BUILDENV="automake autoconf libtool pkgconfig git gcc make file clang $rt"
BUILDDEP="openssl-devel zlib-devel jansson-devel jose libjose*devel http-parser-devel wget systemd which"
BUILDENV="meson pkgconfig git gcc make file clang $rt"
BUILDDEP="openssl-devel zlib-devel jansson-devel jose libjose*devel http-parser-devel wget systemd which asciidoc"

$PM -y --nogpgcheck install $BUILDENV $BUILDDEP

autoreconf -if
mkdir build
cd build

if ! CFLAGS=-coverage LDFLAGS=-lgcov ./configure --prefix=/usr; then
cat ./config.log
exit 1
fi
export CFLAGS="-g -coverage"

make -j8 -k check V=1 TESTS=

if ! make -j8 check; then
cat ./test-suite.log
if ! meson ..; then
cat meson-logs/meson-log.txt >&2
exit 1
fi

ninja=$(findexe ninja ninja-build)
"${ninja}" test

bash <(curl -s https://codecov.io/bash)
# vim: set ts=8 shiftwidth=4 softtabstop=4 expandtab smarttab colorcolumn=80:
60 changes: 0 additions & 60 deletions Makefile.am

This file was deleted.

10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ protect.

Building Tang is fairly straightforward:

$ autoreconf -if
$ ./configure --prefix=/usr --libdir=/usr/lib64
$ make
$ sudo make install
$ mkdir build && cd build
$ meson .. --prefix=/usr
$ ninja
$ sudo ninja install

You can even run the tests if you'd like:

$ make check
$ meson test

### Server Enablement

Expand Down
87 changes: 0 additions & 87 deletions configure.ac

This file was deleted.

4 changes: 4 additions & 0 deletions doc/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
mans += join_paths(meson.current_source_dir(), 'tang-show-keys.1')
mans += join_paths(meson.current_source_dir(), 'tang.8')

# vim:set ts=2 sw=2 et:
85 changes: 85 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
project('tang', 'c',
version: '7',
license: 'GPL3+',
default_options: [
'c_std=c99',
'prefix=/usr',
'sysconfdir=/etc',
'localstatedir=/var',
'warning_level=3',
'werror=true'
]
)

libexecdir = join_paths(get_option('prefix'), get_option('libexecdir'))
sysconfdir = join_paths(get_option('prefix'), get_option('sysconfdir'))
bindir = join_paths(get_option('prefix'), get_option('bindir'))
systemunitdir = join_paths(get_option('prefix'), 'lib/systemd/system')
licensedir = join_paths(get_option('prefix'), 'share', 'licenses', meson.project_name())
cachedir = join_paths(get_option('localstatedir'), 'cache', meson.project_name())
jwkdir = join_paths(get_option('localstatedir'), 'db', meson.project_name())

data = configuration_data()
data.set('libexecdir', libexecdir)
data.set('sysconfdir', sysconfdir)
data.set('systemunitdir', systemunitdir)
data.set('cachedir', cachedir)
data.set('jwkdir', jwkdir)

add_project_arguments(
'-D_POSIX_C_SOURCE=200809L',
'-Wstrict-aliasing',
'-Wchar-subscripts',
'-Wformat-security',
'-Wmissing-declarations',
'-Wmissing-prototypes',
'-Wnested-externs',
'-Wpointer-arith',
'-Wshadow',
'-Wsign-compare',
'-Wstrict-prototypes',
'-Wtype-limits',
'-Wunused-function',
'-Wno-missing-field-initializers',
'-Wno-unused-parameter',
'-Wno-pedantic',
language: 'c'
)

jose = dependency('jose', version: '>=8')
a2x = find_program('a2x', required: false)
compiler = meson.get_compiler('c')
if not compiler.has_header('http_parser.h')
error('http-parser devel files not found.')
endif
http_parser = compiler.find_library('http_parser')

licenses = ['COPYING']
libexecbins = []
bins = []
mans = []
units = []

subdir('doc')
subdir('src')
subdir('units')
subdir('tests')

install_data(libexecbins, install_dir: libexecdir)
install_data(bins, install_dir: bindir)
install_data(units, install_dir: systemunitdir)
install_data(licenses, install_dir: licensedir)

if a2x.found()
foreach m : mans
custom_target(m.split('/')[-1], input: m + '.adoc', output: m.split('/')[-1],
command: [a2x, '-f', 'manpage', '-D', meson.current_build_dir(), '@INPUT@'],
install_dir: join_paths(get_option('mandir'), 'man' + m.split('.')[-1]),
install: true
)
endforeach
else
warning('Will not build man pages due to missing a2x (asciidoc) dependency!')
endif

# vim:set ts=2 sw=2 et:
14 changes: 14 additions & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
tangd = executable('tangd',
'http.h',
'http.c',
'tangd.c',
dependencies: [jose, http_parser],
install: true,
install_dir: libexecdir
)

bins += join_paths(meson.current_source_dir(), 'tang-show-keys')
libexecbins += join_paths(meson.current_source_dir(), 'tangd-keygen')
libexecbins += join_paths(meson.current_source_dir(), 'tangd-update')

# vim:set ts=2 sw=2 et:
22 changes: 22 additions & 0 deletions tests/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
sd_activate = find_program(
'systemd-socket-activate',
'systemd-activate',
required: false
)

if sd_activate.found()
env = environment()
env.prepend('PATH',
join_paths(meson.source_root(), 'src'),
join_paths(meson.build_root(), 'src'),
separator: ':'
)
env.set('SD_ACTIVATE', sd_activate.path() + ' --inetd')

test('adv', find_program('adv'), env: env)
test('rec', find_program('rec'), env: env)
else
warning('Will not run the tests due to missing dependencies!')
endif

# vim:set ts=2 sw=2 et:
31 changes: 31 additions & 0 deletions units/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
tangd_keygen_service = configure_file(
input: 'tangd-keygen.service.in',
output: 'tangd-keygen.service',
configuration: data
)

tangd_service = configure_file(
input: 'tangd@.service.in',
output: 'tangd@.service',
configuration: data
)

tangd_update_path = configure_file(
input: 'tangd-update.path.in',
output: 'tangd-update.path',
configuration: data
)

tangd_update_service = configure_file(
input: 'tangd-update.service.in',
output: 'tangd-update.service',
configuration: data
)

units += join_paths(meson.current_source_dir(), 'tangd.socket')
units += tangd_keygen_service
units += tangd_service
units += tangd_update_path
units += tangd_update_service

# vim:set ts=2 sw=2 et:
File renamed without changes.

0 comments on commit fed9020

Please sign in to comment.