sensh: add meson build system

The top-level Makefile is difficult to use and add new source files. Add
a new build system so that a future set of breaking changes can remove
it.
This commit is contained in:
Richard Acayan
2023-03-24 22:27:02 -04:00
parent 935b2fa39b
commit e8dfce1a67
5 changed files with 160 additions and 3 deletions

View File

@@ -10,15 +10,21 @@ which lines were entered by the user.
- gcc
- libqrtr
- make
- meson or make
- protobuf-c
- qmic (https://github.com/andersson/qmic)
# Installation
There is a Makefile to compile this:
This can be compiled using Meson:
$ make
$ meson setup build
$ ninja -C build
There is also a Makefile to compile this, if you can get it to work:
$ mkdir build
$ make -k
# Usage

34
meson.build Normal file
View File

@@ -0,0 +1,34 @@
#
# Build system root
#
# Copyright (C) 2023 Richard Acayan
#
# This file is part of sensh.
#
# Sensh is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
project('sensh', 'c')
libqrtr = meson.get_compiler('c').find_library('qrtr')
libprotobuf_c = dependency('libprotobuf-c')
subdir('protobuf')
subdir('qmi')
executable('sensh',
'sensh.c',
qmi,
protobufs,
dependencies : [libprotobuf_c, libqrtr])

48
protobuf/meson.build Normal file
View File

@@ -0,0 +1,48 @@
#
# Protocol buffers build system
#
# Copyright (C) 2023 Richard Acayan
#
# This file is part of sensh.
#
# Sensh is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
protoc = find_program('protoc-c')
protobuf_src = [
'sns_client_event_msg',
'sns_client_request_msg',
'sns_proximity_event',
'sns_std_attr_event',
'sns_std_attr_req',
'sns_std_sensor_event',
'sns_std_suid',
'sns_suid_event',
'sns_suid_req']
protobufs = []
foreach protobuf : protobuf_src
protobufs += custom_target(protobuf,
command : [
protoc,
'--c_out=@OUTDIR@',
'--proto_path=@CURRENT_SOURCE_DIR@',
'--dependency_out=@DEPFILE@',
'@INPUT@'],
input : protobuf + '.proto',
output : ['@BASENAME@.pb-c.c', '@BASENAME@.pb-c.h'],
depfile : '@BASENAME@.pb-c.d')
endforeach

28
qmi/meson.build Normal file
View File

@@ -0,0 +1,28 @@
#
# QMI Build system
#
# Copyright (C) 2023 Richard Acayan
#
# This file is part of sensh.
#
# Sensh is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
qmic = find_program('qmic')
wrapper = files('qmic_wrapper.sh')
qmi = custom_target('qmi_sns_client',
command : [wrapper, qmic, '@INPUT@', '@OUTDIR@'],
input : 'sns_client.qmi',
output : ['qmi_sns_client.c', 'qmi_sns_client.h'])

41
qmi/qmic_wrapper.sh Executable file
View File

@@ -0,0 +1,41 @@
#!/bin/sh
#
# QMI interface compiler wrapper
#
# Copyright (C) 2023 Richard Acayan
#
# This file is part of sensh.
#
# Sensh is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
qmic="$1"
#
# Usage: qmic_wrapper.sh QMIC INPUT OUTPUT_DIRECTORY
#
# Example: qmic_wrapper.sh /usr/bin/qmic ../qmi/sns_client.qmi qmi/
#
#
# We need to move into the output directory so QMIC puts the files in the
# correct place, but the path to the input might be relative to the directory
# we are already in. Open the file now and pipe it to stdin so the pathname
# gets processed relative to the correct directory.
#
exec < "$2"
cd "$3"
exec "$qmic" -k