Skip to content

Commit

Permalink
feat: build with meson
Browse files Browse the repository at this point in the history
  • Loading branch information
mpolitzer committed Apr 29, 2024
1 parent f02f2dc commit cc517d3
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 8 deletions.
60 changes: 60 additions & 0 deletions sys-utils/libcmt/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
project('libcmt', 'c',
default_options: ['default_library=both'],
version : run_command('tools/version.sh', 'get-vcs').stdout().strip())
meson.add_dist_script('tools/version.sh', 'set-dist', meson.project_version())

build = meson.get_compiler('c', native: true)
host = meson.get_compiler('c', native: false)

inccmt = include_directories('src')
install_headers(
'src/abi.h',
'src/buf.h',
'src/io.h',
'src/keccak.h',
'src/merkle.h',
'src/rollup.h',
'src/util.h')

src_base = files(
'src/abi.c',
'src/buf.c',
'src/keccak.c',
'src/merkle.c',
'src/rollup.c',
'src/util.c')

libcmt = library('cmt',
src_base + 'src/io.c',
override_options: ['b_coverage=false'],
install: true,
native: false)

pkg = import('pkgconfig')
pkg.generate(libraries: libcmt,
version: run_command('tools/version.sh', 'get-vcs').stdout().strip(),
name: 'libcmt',
filebase: 'libcmt',
description: 'libcmt')

libmock = library('cmt-mock',
src_base + 'src/io-mock.c',
native: true)

tests = [
'abi-multi',
'abi-single',
'buf',
'io',
'gio',
'keccak',
'merkle',
'progress',
'rollup',
]

foreach name: tests
src = 'tests/' + name + '.c'
exe = executable(name, src, include_directories: inccmt, link_with: libmock, native: true)
test(name, exe)
endforeach
12 changes: 12 additions & 0 deletions sys-utils/libcmt/riscv64.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[binaries]
c = 'riscv64-linux-gnu-gcc'
cpp = 'riscv64-linux-gnu-g++'
ld = 'riscv64-linux-gnu-ld'
ar = 'riscv64-linux-gnu-ar'
strip = 'riscv64-linux-gnu-strip'

[host_machine]
system = 'linux'
cpu_family = 'riscv64'
cpu = 'rv64gc'
endian = 'little'
8 changes: 0 additions & 8 deletions sys-utils/libcmt/tools/template/cross-control.template

This file was deleted.

9 changes: 9 additions & 0 deletions sys-utils/libcmt/tools/version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

if [ "$1" = "get-vcs" ]; then
git -C "$MESON_SOURCE_ROOT" describe --always --dirty
elif [ "$1" = "set-dist" ]; then
$MESONREWRITE --sourcedir="$MESON_PROJECT_DIST_ROOT" kwargs set project / version "$2"
else
exit 1
fi

0 comments on commit cc517d3

Please sign in to comment.