Skip to content

Commit

Permalink
Add Meson
Browse files Browse the repository at this point in the history
-Werror is dropped, because Meson's werror is more strict than configure
one.

This implementation does not support running tests. The Kyua testsuite
heavily relies on in-source builds. Tests would have to be rewritten
(at least the Kyuafile files, but probably more) to support Meson.

Meson does not support retrieving git info and providing it as a
compiler flag. Meson's vcs_tag() mechanism supports outputting to
a (header or source) file only. This would mean that xbps.h.in would
have to be modified.

No substitution is done on xbps.h.in. See #598 for explanation.

_DEFAULT_SOURCE is dropped, because _GNU_SOURCE implies _DEFAULT_SOURCE.

-D_FILE_OFFSET_BITS=64 is set automatically by Meson.

Work in progress!
  • Loading branch information
meator committed Dec 7, 2024
1 parent e82437f commit 5c3c04f
Show file tree
Hide file tree
Showing 31 changed files with 726 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ tests/*/*/*_test
tests/*/*/*_tests
include/xbps.h

subprojects/libarchive-*
subprojects/openssl-*
subprojects/packagecache
subprojects/zlib-*

# vim backup files
.*.swp
*~
19 changes: 19 additions & 0 deletions bin/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
subdir('xbps-alternatives')
subdir('xbps-create')
subdir('xbps-dgraph')
subdir('xbps-install')
subdir('xbps-pkgdb')
subdir('xbps-query')
subdir('xbps-reconfigure')
subdir('xbps-remove')
subdir('xbps-rindex')
subdir('xbps-uhelper')
subdir('xbps-checkvers')
subdir('xbps-fbulk')
subdir('xbps-digest')
subdir('xbps-fetch')

if host_machine.system() == 'linux'
subdir('xbps-uchroot')
subdir('xbps-uunshare')
endif
4 changes: 4 additions & 0 deletions bin/xbps-alternatives/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
src = ['main.c']

install_man('xbps-alternatives.1')
executable('xbps-alternatives', src, dependencies: libxbps_dep, install: true)
10 changes: 10 additions & 0 deletions bin/xbps-checkvers/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
src = ['main.c']

install_man('xbps-checkvers.1')
executable(
'xbps-checkvers',
src,
c_args: '-Wno-deprecated-declarations',
dependencies: libxbps_dep,
install: true,
)
4 changes: 4 additions & 0 deletions bin/xbps-create/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
src = ['main.c']

install_man('xbps-create.1')
executable('xbps-create', src, dependencies: libxbps_dep, install: true)
4 changes: 4 additions & 0 deletions bin/xbps-dgraph/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
src = ['main.c']

install_man('xbps-dgraph.1')
executable('xbps-dgraph', src, dependencies: libxbps_dep, install: true)
4 changes: 4 additions & 0 deletions bin/xbps-digest/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
src = ['main.c']

install_man('xbps-digest.1')
executable('xbps-digest', src, dependencies: libxbps_dep, install: true)
4 changes: 4 additions & 0 deletions bin/xbps-fbulk/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
src = ['main.c']

install_man('xbps-fbulk.1')
executable('xbps-fbulk', src, dependencies: libxbps_dep, install: true)
4 changes: 4 additions & 0 deletions bin/xbps-fetch/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
src = ['main.c', '../xbps-install/fetch_cb.c']

install_man('xbps-fetch.1')
executable('xbps-fetch', src, dependencies: libxbps_dep, install: true)
50 changes: 50 additions & 0 deletions bin/xbps-install/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
src = [
'main.c',
'transaction.c',
'question.c',
'fetch_cb.c',
'state_cb.c',
'util.c',
]

clock_gettime_code = '''
#include <time.h>
int main(void) {
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return 0;
}
'''

CC = meson.get_compiler('c')

rt = CC.find_library('rt', required: false)
extra_flags = []

if rt.found()
if CC.compiles(
clock_gettime_code,
name: 'clock_gettime() available',
args: '-D_GNU_SOURCE',
dependencies: rt,
)
extra_flags = '-DHAVE_CLOCK_GETTIME'
endif
else
if CC.compiles(
clock_gettime_code,
name: 'clock_gettime() available',
args: '-D_GNU_SOURCE',
)
extra_flags = '-DHAVE_CLOCK_GETTIME'
endif
endif

install_man('xbps-install.1')
executable(
'xbps-install',
src,
c_args: extra_flags,
dependencies: libxbps_dep,
install: true,
)
12 changes: 12 additions & 0 deletions bin/xbps-pkgdb/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
src = [
'main.c',
'check.c',
'check_pkg_files.c',
'check_pkg_alternatives.c',
'check_pkg_rundeps.c',
'check_pkg_symlinks.c',
'check_pkg_unneeded.c',
]

install_man('xbps-pkgdb.1')
executable('xbps-pkgdb', src, dependencies: libxbps_dep, install: true)
12 changes: 12 additions & 0 deletions bin/xbps-query/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
src = [
'main.c',
'list.c',
'show-deps.c',
'show-info-files.c',
'ownedby.c',
'search.c',
'../xbps-install/util.c',
]

install_man('xbps-query.1')
executable('xbps-query', src, dependencies: libxbps_dep, install: true)
4 changes: 4 additions & 0 deletions bin/xbps-reconfigure/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
src = ['main.c', 'find-deps.c']

install_man('xbps-reconfigure.1')
executable('xbps-reconfigure', src, dependencies: libxbps_dep, install: true)
10 changes: 10 additions & 0 deletions bin/xbps-remove/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
src = [
'main.c',
'clean-cache.c',
'../xbps-install/question.c',
'../xbps-install/util.c',
'../xbps-install/transaction.c',
]

install_man('xbps-remove.1')
executable('xbps-remove', src, dependencies: libxbps_dep, install: true)
11 changes: 11 additions & 0 deletions bin/xbps-rindex/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
src = [
'main.c',
'index-add.c',
'index-clean.c',
'remove-obsoletes.c',
'repoflush.c',
'sign.c',
]

install_man('xbps-rindex.1')
executable('xbps-rindex', src, dependencies: libxbps_dep, install: true)
4 changes: 4 additions & 0 deletions bin/xbps-uchroot/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
src = ['main.c']

install_man('xbps-uchroot.1')
executable('xbps-uchroot', src, dependencies: libxbps_dep, install: true)
4 changes: 4 additions & 0 deletions bin/xbps-uhelper/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
src = ['main.c', '../xbps-install/fetch_cb.c']

install_man('xbps-uhelper.1')
executable('xbps-uhelper', src, dependencies: libxbps_dep, install: true)
4 changes: 4 additions & 0 deletions bin/xbps-uunshare/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
src = ['main.c']

install_man('xbps-uunshare.1')
executable('xbps-uunshare', src, dependencies: libxbps_dep, install: true)
39 changes: 39 additions & 0 deletions data/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
install_man('xbps.d.5')
install_data(
'60:ae:0c:d6:f0:95:17:80:bc:93:46:7a:89:af:a3:2d.plist',
install_dir: dbdir,
)
install_data(
'repod-main.conf',
'xbps.conf',
install_dir: get_option('datadir') / 'xbps.d',
rename: ['00-repository-main.conf', 'xbps.conf'],
)
install_data(
'_xbps',
'_xbps_src',
install_dir: get_option('datadir') / 'zsh/site-functions',
)
install_data(
'xbps.bash',
install_dir: get_option('datadir') / 'bash-completion/completions',
rename: 'xbps',
)

foreach file : [
'xbps-checkvers',
'xbps-create',
'xbps-dgraph',
'xbps-install',
'xbps-pkgdb',
'xbps-query',
'xbps-reconfigure',
'xbps-remove',
'xbps-rindex',
]
install_symlink(
file,
pointing_to: 'xbps',
install_dir: get_option('datadir') / 'bash-completion/completions',
)
endforeach
39 changes: 39 additions & 0 deletions doc/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
doxygen = find_program('doxygen', required: true)
graphviz_dot = find_program('dot', required: true)

dot_format = get_option('api-docs-format')

foreach dotfile : [
'xbps_transaction_dictionary',
'xbps_pkgdb_dictionary',
'xbps_pkg_props_dictionary',
'xbps_pkg_files_dictionary',
'xbps_binary_pkg_content',
]
custom_target(
command: [graphviz_dot, '-T' + dot_format, '@INPUT@', '-o', '@OUTPUT@'],
input: dotfile + '.dot',
output: dotfile + '.' + dot_format,
build_by_default: true,
)
endforeach

sed = find_program('sed', required: true)
distver = get_option('api-docs-distver')
if distver == ''
command = [
'sh',
'-c',
sed.full_path() + ' -e \'s|@@PROJECT_NUMBER@@|$(date +%Y%m%d)|\' @INPUT@',
]
else
command = [sed, '-e', 's|@@PROJECT_NUMBER@@|' + distver + '|', '@INPUT@']
endif
xbps_api_doxyfile = custom_target(
command: command,
input: 'xbps_api_doxyfile.in',
capture: true,
output: 'xbps_api_doxyfile',
)

run_target('doxygen', command: [doxygen, xbps_api_doxyfile])
11 changes: 11 additions & 0 deletions include/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
configure_file(
input: 'xbps.h.in',
output: 'xbps.h',
copy: true,
install: true,
install_dir: get_option('includedir'),
)

install_subdir('xbps', install_dir: get_option('includedir'))

xbps_include = include_directories('.')
19 changes: 19 additions & 0 deletions lib/compat/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
compat_functions = []

if not compatibility_functions['vasprintf']
compat_functions += 'vasprintf.c'
endif
if not compatibility_functions['strcasestr']
compat_functions += 'strcasestr.c'
endif
if not compatibility_functions['strlcpy']
compat_functions += 'strlcpy.c'
endif
if not compatibility_functions['strlcat']
compat_functions += 'strlcat.c'
endif
if not compatibility_functions['humanize_number']
compat_functions += 'humanize_number.c'
endif

compat_files = files(compat_functions)
1 change: 1 addition & 0 deletions lib/external/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
external_files = files('dewey.c', 'fexec.c', 'mkpath.c')
27 changes: 27 additions & 0 deletions lib/fetch/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
src = ['common.c', 'fetch.c', 'file.c', 'ftp.c', 'http.c']

ftperr = custom_target(
'ftperr',
command: [files('errlist.sh'), 'ftp_errlist', 'FTP', '@INPUT@'],
capture: true,
input: 'ftp.errors',
output: 'ftperr.h',
)

httperr = custom_target(
'httperr',
command: [files('errlist.sh'), 'http_errlist', 'HTTP', '@INPUT@'],
capture: true,
input: 'http.errors',
output: 'httperr.h',
)

libfetch = static_library(
'fetch',
src,
ftperr,
httperr,
c_args: ['-DFTP_COMBINE_CWDS', '-DINET6', '-DWITH_SSL'],
gnu_symbol_visibility: 'hidden',
include_directories: [xbps_include, '.'],
)
Loading

0 comments on commit 5c3c04f

Please sign in to comment.