Skip to content

Commit

Permalink
WIP Migrate from autotools to meson
Browse files Browse the repository at this point in the history
For long-term maintainability and security.

Also removing non-liquid and non-TMC build options (not tested or
maintained).

Still to do: ensure it builds on Windows (cygwin/mingw/msys2?)
and add Windows builds in CI (github workflow)
  • Loading branch information
windytan committed May 25, 2024
1 parent fcc6e1d commit 2d61405
Show file tree
Hide file tree
Showing 23 changed files with 188 additions and 208 deletions.
112 changes: 98 additions & 14 deletions .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,108 @@ name: build

on:
push:
branches: [ master ]
branches: [ master, meson ]
pull_request:
branches: [ master ]

jobs:
build:

ubuntu-build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Install libraries
run: sudo apt-get install libsndfile1-dev libliquid-dev
- name: autoreconf
run: ./autogen.sh
- name: configure
run: ./configure
- name: make
run: make
- name: make check
run: make check
- uses: actions/checkout@v4
- name: Install dependencies (apt)
run: sudo apt install python3-pip ninja-build libsndfile1-dev libliquid-dev
- name: Install meson (pip3)
run: pip3 install --user meson
- name: meson setup
run: meson setup build
- name: compile
run: cd build && meson compile

macos-build:
runs-on: macos-latest

steps:
- uses: actions/checkout@v4
- name: Install dependencies (brew)
run: brew install meson libsndfile liquid-dsp
- name: meson setup
run: meson setup build
- name: compile
run: cd build && meson compile

windows-msys2-mingw-build:
runs-on: windows-latest

steps:
- uses: msys2/setup-msys2@v2
with:
update: true
install: >-
autoconf
automake
git
make
mingw-w64-x86_64-gcc
mingw-w64-x86_64-libiconv
mingw-w64-x86_64-libsndfile
mingw-w64-x86_64-meson
mingw-w64-x86_64-python3
- name: Patch & build liquid-dsp
shell: msys2 {0}
run: |
git clone https://github.com/jgaeddert/liquid-dsp.git && cd liquid-dsp
perl -i -p -e 's/(AC_CHECK_LIB\(\[c\].+| sys\/resource.h)//g' configure.ac
./bootstrap.sh && ./configure --prefix=/mingw64 && make
make install
- uses: actions/checkout@v4
- name: Build redsea
shell: msys2 {0}
run: |
meson setup build && cd build && meson compile
- name: Package into distrib
shell: msys2 {0}
run: >-
mkdir -p distrib && cp build/redsea.exe distrib/ &&
ldd build/redsea.exe |
grep -iv windows |
grep -iv system32 |
grep -v :$ |
cut -f2 -d\> |
cut -f1 -d\( |
wk '{$1=$1};1' |
xargs -I{} cp {} distrib/
windows-cygwin-build:
runs-on: windows-latest

steps:
- run: git config --global core.autocrlf input
- uses: actions/checkout@v4
- uses: cygwin/cygwin-install-action@v4
with:
packages: >-
autoconf
automake
bzip2
gcc-core
gcc-g++
git
libiconv-devel
libsndfile-devel
make
meson
patch
perl
tar
xz
- name: Build liquid-dsp
shell: C:\cygwin\bin\bash.exe -eo pipefail '{0}'
run: git clone https://github.com/jgaeddert/liquid-dsp.git && cd liquid-dsp && ./bootstrap.sh && ./configure --prefix=/usr && make && make install
- name: Patch liquid-dsp
shell: C:\cygwin\bin\bash.exe -eo pipefail '{0}'
run: perl -i -p -e 's/(?<=\s)(_[A-Z])(?=[,\)])/\L\1__/g' /usr/include/liquid/liquid.h
- name: Build redsea
shell: C:\cygwin\bin\bash.exe -eo pipefail '{0}'
run: meson setup build && cd build && meson compile
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## HEAD

* Migrate build system from autotools to meson (#90)
* Add GitHub Workflows CI builds for macOS and Windows (MSYS2/MinGW + Cygwin)
* Remove unmaintained build options for non-liquid, non-TMC builds
* Add support for enhanced RadioText (eRT)
* Add support for Long PS in Group 15A
* Fix detection of invalid date/time (timestamps >2000 years ago)
Expand Down
2 changes: 0 additions & 2 deletions Makefile.am

This file was deleted.

28 changes: 9 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ supports a large [subset of RDS features][Wiki: Features].
[![release](https://img.shields.io/github/release/windytan/redsea.svg)](https://github.com/windytan/redsea/releases/latest)
![build](https://github.com/windytan/redsea/workflows/build/badge.svg)

Decoded RDS groups are printed to the terminal as [line-delimited JSON][https://jsonlines.org/] objects
Decoded RDS groups are printed to the terminal as [line-delimited JSON](https://jsonlines.org/) objects
or, optionally, undecoded hex blocks (`-x`). Please refer to the wiki for
[input data formats][Wiki: Input].

Expand Down Expand Up @@ -50,11 +50,12 @@ beginning.

1. Install the prerequisites. On Ubuntu:

$ sudo apt install git build-essential autoconf libsndfile1-dev libliquid-dev
$ sudo apt install git ninja-build build-essential python3-pip libsndfile1-dev libliquid-dev
$ pip3 install --user meson

Or on macOS (OSX) using Homebrew:
Or on macOS using Homebrew:

$ brew install autoconf automake libsndfile liquid-dsp
$ brew install meson libsndfile liquid-dsp
$ xcode-select --install

2. Clone the repository (unless you downloaded a release zip file):
Expand All @@ -64,23 +65,12 @@ Or on macOS (OSX) using Homebrew:

3. Compile redsea:

$ ./autogen.sh && ./configure && make

4. Install:

$ make install
$ meson setup build && cd build && meson compile

How to later get the latest updates and recompile:

$ git pull
$ ./autogen.sh && ./configure && make clean && make
$ make install

For a slower machine it can take some time to compile the TMC support. This can
be disabled (`./configure --disable-tmc`).

If you only need to decode hex or binary input and don't need demodulation,
you can compile redsea without liquid-dsp (`./configure --without-liquid`).
$ cd build && meson compile

[liquid-dsp]: https://github.com/jgaeddert/liquid-dsp/releases/tag/v1.3.2

Expand Down Expand Up @@ -174,7 +164,7 @@ type:
* For realtime decoding, a Raspberry Pi 1 or faster
* ~8 MB of free memory (~128 MB for RDS-TMC)
* C++14 compiler
* GNU autotools
* meson + ninja (for building)
* libiconv 1.16
* libsndfile 1.0.31
* [liquid-dsp][liquid-dsp] release 1.3.2
Expand All @@ -185,7 +175,7 @@ type:

### Can't find liquid-dsp on macOS

If you've installed [liquid-dsp][liquid-dsp] yet `configure` can't find it, it's
If you've installed [liquid-dsp][liquid-dsp] yet meson can't find it, it's
possible that XCode command line tools aren't installed. Run this command to fix
it:

Expand Down
2 changes: 0 additions & 2 deletions autogen.sh

This file was deleted.

91 changes: 0 additions & 91 deletions configure.ac

This file was deleted.

68 changes: 68 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
project('redsea', 'cpp', default_options : ['cpp_std=c++14', 'warning_level=3', 'buildtype=release'],
version: '0.22-SNAPSHOT')

# Store version number to be compiled in
conf = configuration_data()
conf.set_quoted('VERSION', meson.project_version())
configure_file(output : 'config.h',
configuration : conf)

### Compiler options ###

cc = meson.get_compiler('cpp')
add_project_arguments(cc.get_supported_arguments([
'-Wno-unknown-pragmas']), language: 'cpp')

if get_option('buildtype') == 'release'
add_project_arguments('-O3', language : 'cpp')
endif

### Dependencies ###

iconv = dependency('iconv')
sndfile = dependency('sndfile')

# Detecting liquid-dsp in a portable fashion
if build_machine.system() == 'darwin'
fs = import('fs')
# Homebrew system
if fs.is_dir('/opt/homebrew/lib')
liquid_lib = cc.find_library('liquid',
dirs : ['/opt/homebrew/lib'])
liquid_inc = include_directories('/opt/homebrew/include')
# MacPorts system
else
liquid_lib = cc.find_library('liquid',
dirs : ['/opt/local/lib'])
liquid_inc = include_directories('/opt/local/include')
endif
liquid = declare_dependency(dependencies : liquid_lib,
include_directories : liquid_inc)
else
liquid = cc.find_library('liquid')
endif

# M_PI
if build_machine.system() == 'windows'
add_project_arguments('-D_USE_MATH_DEFINES=1', language : 'cpp')
endif

sources = [
'ext/json/jsoncpp.cpp',
'src/block_sync.cc',
'src/channel.cc',
'src/common.cc',
'src/groups.cc',
'src/input.cc',
'src/liquid_wrappers.cc',
'src/options.cc',
'src/rdsstring.cc',
'src/redsea.cc',
'src/subcarrier.cc',
'src/tables.cc',
'src/tmc/tmc.cc',
'src/tmc/locationdb.cc',
'src/util.cc'
]

executable('redsea', sources, dependencies: [iconv, sndfile, liquid])
9 changes: 0 additions & 9 deletions src/Makefile.am

This file was deleted.

1 change: 0 additions & 1 deletion src/block_sync.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include <map>
#include <vector>

#include "config.h"
#include "src/groups.h"
#include "src/options.h"

Expand Down
2 changes: 0 additions & 2 deletions src/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
#ifndef CHANNEL_H_
#define CHANNEL_H_

#include "config.h"

#include "src/block_sync.h"
#include "src/common.h"
#include "src/options.h"
Expand Down

0 comments on commit 2d61405

Please sign in to comment.