Skip to content

Commit

Permalink
subproject/packaging improvements
Browse files Browse the repository at this point in the history
Install the readme and the license.
Override libbsd-overlay and libobsd dependencies in subproject.
  • Loading branch information
guijan committed Dec 27, 2024
1 parent 12b3ff3 commit 61987c7
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 27 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ jobs:
with:
msystem: ${{matrix.sys}}
path-type: strict
pacboy: gcc:p meson:p ninja:p
pacboy: |
gcc:p meson:p ninja:p dos2unix:
- uses: actions/[email protected]
- name: build
run: |
Expand Down
71 changes: 48 additions & 23 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2022 Guilherme Janczak <[email protected]>
# Copyright (c) 2022, 2024 Guilherme Janczak <[email protected]>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
Expand Down Expand Up @@ -105,21 +105,53 @@ libobsd = library('obsd', src,
dependencies: deps,
gnu_symbol_visibility: 'hidden',
override_options: link)
if subproj
if windows_host
custom_target('license',
command: ['unix2dos'],
input: 'LICENSE.txt',
feed: true,
output: 'LICENSE_libobsd.txt',
capture: true,
build_by_default: true)
else
configure_file(input: 'LICENSE.txt',
output: 'LICENSE_libobsd.txt',
copy: true)
endif
else

libobsd_dep = declare_dependency(link_with: libobsd,
dependencies: deps,
include_directories: incdir,
sources: gen_inc,
compile_args: user_args)
meson.override_dependency('libbsd-overlay', libobsd_dep)
meson.override_dependency('libobsd', libobsd_dep)

subdir('test')

### Installation. Headers and the library are handled elsewhere.

libobsd_license = 'LICENSE.txt'
libobsd_readme = 'README.md'
docdir = get_option('docdir')
if docdir == ''
docdir = get_option('datadir') / 'doc' \
/ meson.project_name() + '-' + meson.project_version()
endif
if windows_host
unix2dos = find_program('unix2dos')
custom_target('license',
command: [unix2dos],
input: libobsd_license,
feed: true,
capture: true,
output: subproj ? 'LICENSE_libobsd.txt' : libobsd_license,
build_by_default: true,
install: not subproj,
install_dir: docdir)
custom_target('readme',
command: [unix2dos],
input: libobsd_readme,
feed: true,
capture: true,
output: libobsd_readme,
build_by_default: true,
install: not subproj,
install_dir: docdir)
elif not subproj
install_data(libobsd_license, libobsd_readme,
install_dir: docdir,
install_tag: 'doc')
endif

if not subproj
install_man(man)

pkg = import('pkgconfig')
Expand All @@ -143,10 +175,3 @@ else
pointing_to: 'libobsd.pc')
endif
endif

libobsd_dep = declare_dependency(link_with: libobsd,
dependencies: deps,
include_directories: incdir,
sources: gen_inc,
compile_args: user_args)
subdir('test')
10 changes: 7 additions & 3 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2022 Guilherme Janczak <[email protected]>
# Copyright (c) 2022,2024 Guilherme Janczak <[email protected]>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
Expand All @@ -14,8 +14,12 @@

option('provide_libbsd', type: 'boolean', value: false,
description: 'Provide a libbsd-overlay.pc pkg-config definition.')
option('docdir', type: 'string',
description: 'Where to install the license, readme, and other'
+ ' documentation which isn\'t man pages.')

# This option is for development, not end users.
option('test_system', type: 'boolean', value: false,
description: 'Creates a Meson test suite named \'system\' which contains'
+ ' tests for functions present in the current system.')
description: 'Creates a Meson test suite named \'system\' which'
+ ' contains tests for functions present in the current'
+ ' system.')

0 comments on commit 61987c7

Please sign in to comment.