mirror of https://github.com/ericonr/purr-c.git
Add meson build system.
This commit is contained in:
parent
158596366a
commit
fa1c550090
|
@ -18,3 +18,12 @@ jobs:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
- run: xbps-install -Sy clang make bearssl-devel
|
- run: xbps-install -Sy clang make bearssl-devel
|
||||||
- run: CC=clang ci/run.sh
|
- run: CC=clang ci/run.sh
|
||||||
|
clang-musl-meson:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container: voidlinux/voidlinux-musl
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
- run: |
|
||||||
|
xbps-install -Syu || xbps-install -yu xbps
|
||||||
|
xbps-install -y clang meson ninja bearssl-devel
|
||||||
|
- run: CC=clang ci/run-meson.sh
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
purr
|
purr
|
||||||
tests
|
tests
|
||||||
gemi
|
gemi
|
||||||
|
build/
|
||||||
*.o
|
*.o
|
||||||
*.a
|
*.a
|
||||||
*.d
|
*.d
|
||||||
|
|
10
README.md
10
README.md
|
@ -21,7 +21,15 @@ You can build and install the project with the commands below:
|
||||||
```
|
```
|
||||||
$ ./configure # creates config.mk
|
$ ./configure # creates config.mk
|
||||||
$ make
|
$ make
|
||||||
$ make install PREFIX=$HOME/.local/bin
|
$ make install PREFIX=$HOME/.local
|
||||||
|
```
|
||||||
|
|
||||||
|
Alternatively, you can use the Meson build system:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ meson build --prefix $HOME/.local
|
||||||
|
$ ninja -C build
|
||||||
|
$ ninja -C install
|
||||||
```
|
```
|
||||||
|
|
||||||
## Programs
|
## Programs
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
#!/bin/sh -x
|
||||||
|
meson build/
|
||||||
|
ninja -C build/ all
|
||||||
|
RATELIMIT=1 ninja -C build/ test
|
|
@ -0,0 +1,72 @@
|
||||||
|
project('purr-c', 'c',
|
||||||
|
version : '0.1',
|
||||||
|
default_options : ['warning_level=3'])
|
||||||
|
|
||||||
|
compiler = meson.get_compiler('c')
|
||||||
|
|
||||||
|
bearssl = compiler.find_library('bearssl', required: true)
|
||||||
|
|
||||||
|
gnu_source = '#define _GNU_SOURCE'
|
||||||
|
getrandom = compiler.has_header_symbol('sys/random.h', 'getrandom')
|
||||||
|
arc4random = compiler.has_header_symbol('stdlib.h', 'arc4random')
|
||||||
|
gnu_progname = compiler.has_header_symbol(
|
||||||
|
'errno.h',
|
||||||
|
'program_invocation_short_name',
|
||||||
|
prefix: gnu_source
|
||||||
|
)
|
||||||
|
bsd_progname = compiler.has_header_symbol('stdlib.h', 'getprogname')
|
||||||
|
sock_cloexec = compiler.has_header_symbol('sys/socket.h', 'SOCK_CLOEXEC')
|
||||||
|
pipe2 = compiler.has_header_symbol('unistd.h', 'pipe2', prefix: gnu_source)
|
||||||
|
|
||||||
|
args = []
|
||||||
|
if arc4random
|
||||||
|
args += '-DHAVE_ARC4RANDOM'
|
||||||
|
elif getrandom
|
||||||
|
args += '-DHAVE_GETRANDOM'
|
||||||
|
else
|
||||||
|
error('no random buf impl')
|
||||||
|
endif
|
||||||
|
if bsd_progname
|
||||||
|
args += '-DHAVE_GETPROGNAME'
|
||||||
|
elif gnu_progname
|
||||||
|
args += '-DHAVE_PROG_INVOCATION'
|
||||||
|
elif
|
||||||
|
error('no progname impl')
|
||||||
|
endif
|
||||||
|
if sock_cloexec
|
||||||
|
args += '-DHAVE_SOCK_CLOEXEC_H'
|
||||||
|
endif
|
||||||
|
if pipe2
|
||||||
|
args += '-DHAVE_PIPE2'
|
||||||
|
endif
|
||||||
|
add_project_arguments(args, language: 'c')
|
||||||
|
|
||||||
|
purrlib = static_library(
|
||||||
|
'purrlib',
|
||||||
|
'mmap_file.c',
|
||||||
|
'gemini.c',
|
||||||
|
'read_certs.c',
|
||||||
|
'urls.c',
|
||||||
|
'files.c',
|
||||||
|
'pager.c',
|
||||||
|
'comm.c',
|
||||||
|
'formats.c',
|
||||||
|
'encrypt.c',
|
||||||
|
'socket.c',
|
||||||
|
)
|
||||||
|
|
||||||
|
executable('purr', 'purr.c', link_with: purrlib, dependencies: bearssl, install: true)
|
||||||
|
executable('gemi', 'gemi.c', link_with: purrlib, dependencies: bearssl, install: true)
|
||||||
|
|
||||||
|
command = 'ln -sf purr ${DESTDIR}/${MESON_INSTALL_PREFIX}/@0@/@1@'
|
||||||
|
meson.add_install_script('sh', '-c', command.format(get_option('bindir'), 'meow'))
|
||||||
|
meson.add_install_script('sh', '-c', command.format(get_option('bindir'), 'meowd'))
|
||||||
|
|
||||||
|
tests = executable('tests', 'tests.c', link_with: purrlib, dependencies: bearssl, install: false)
|
||||||
|
test('library-tests', tests)
|
||||||
|
test(
|
||||||
|
'executable-tests',
|
||||||
|
find_program('test.sh'),
|
||||||
|
args: meson.current_source_dir() / 'README.md',
|
||||||
|
workdir: meson.current_build_dir()
|
||||||
|
)
|
9
test.sh
9
test.sh
|
@ -1,4 +1,5 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
readme="${1:-README.md}"
|
||||||
EXIT=
|
EXIT=
|
||||||
assert () {
|
assert () {
|
||||||
if [ "$1" != "$2" ]; then
|
if [ "$1" != "$2" ]; then
|
||||||
|
@ -21,15 +22,15 @@ r="$(./purr r https://www.wikipedia.org | xbps-digest)"
|
||||||
assert "$e" "$r"
|
assert "$e" "$r"
|
||||||
|
|
||||||
echo "Pastebin and retrieve - unencrypted"
|
echo "Pastebin and retrieve - unencrypted"
|
||||||
e="$(xbps-digest README.md)"
|
e="$(xbps-digest "$readme")"
|
||||||
r="$(./purr r $(./purr s README.md) | xbps-digest)"
|
r="$(./purr r $(./purr s "$readme") | xbps-digest)"
|
||||||
assert "$e" "$r"
|
assert "$e" "$r"
|
||||||
|
|
||||||
rate_limit
|
rate_limit
|
||||||
|
|
||||||
echo "Pastebin and retrieve - encrypted"
|
echo "Pastebin and retrieve - encrypted"
|
||||||
e="$(xbps-digest README.md)"
|
e="$(xbps-digest "$readme")"
|
||||||
r="$(./purr -e r $(./purr -e s README.md) | xbps-digest)"
|
r="$(./purr -e r $(./purr -e s "$readme") | xbps-digest)"
|
||||||
assert "$e" "$r"
|
assert "$e" "$r"
|
||||||
|
|
||||||
# TODO: find some reliable way of testing gemi
|
# TODO: find some reliable way of testing gemi
|
||||||
|
|
Loading…
Reference in New Issue