Skip to content

Commit

Permalink
Merge pull request #654 from drowe67/ms-refactor-gui-code
Browse files Browse the repository at this point in the history
Refactor and clean up source tree.
  • Loading branch information
tmiw authored Jan 15, 2024
2 parents e3e462d + 97ce4cc commit 47bf1d8
Show file tree
Hide file tree
Showing 49 changed files with 562 additions and 935 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/cmake-macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Build FreeDV (macOS)

on:
push:
branches-ignore:
- 'dr-render-manual'

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Debug

jobs:
build:
# The CMake configure and build commands are platform agnostic and should work equally
# well on Windows or Mac. You can convert this to a matrix build if you need
# cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: macos-latest

steps:
- uses: actions/checkout@v2

- name: Install packages
shell: bash
working-directory: ${{github.workspace}}
run: brew install automake libtool

- name: Build freedv-gui
shell: bash
working-directory: ${{github.workspace}}
run: UT_ENABLE=1 ./build_osx.sh

- name: Execute unit tests
shell: bash
working-directory: ${{github.workspace}}/build_osx
run: make test

355 changes: 355 additions & 0 deletions CHANGELOG_OLD.md

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ if(APPLE)

# Workaround for Xcode 15 bug preventing FreeDV binaries from starting
# on older versions of macOS. See https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes#Linking.
add_link_options("-Wl,-ld_classic")
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 15.0.0.0)
add_link_options("-Wl,-ld_classic")
endif(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 15.0.0.0)
else(APPLE)
project(
${PROJECT_NAME}
Expand Down Expand Up @@ -76,6 +78,9 @@ message(STATUS "Compilation date = XX${DATE_RESULT}XX")
#
configure_file(cmake/version.h.in src/version.h @ONLY)

# Generate custom CTest config
configure_file(cmake/CTestCustom.cmake ${CMAKE_BINARY_DIR})

# Set default build type
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug")
Expand Down
153 changes: 33 additions & 120 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,25 @@ This document describes how to build the FreeDV GUI program for various operatin
* [FreeDV GUI User Manual](USER_MANUAL.md)
* [Building for Windows using Docker](docker/README_docker.md)

## Building on Ubuntu Linux (16-20) with PortAudio
## Building on Ubuntu Linux

```
$ sudo apt install libspeexdsp-dev libsamplerate0-dev sox git \
libwxgtk3.0-gtk3-dev portaudio19-dev libhamlib-dev libasound2-dev libao-dev \
libwxgtk3.2-dev libhamlib-dev libasound2-dev libao-dev \
libgsm1-dev libsndfile1-dev cmake module-assistant build-essential
$ git clone https://github.com/drowe67/freedv-gui.git
$ cd freedv-gui
(if using pipewire/PulseAudio -- recommended and the default)
$ sudo apt install libpulse-dev
$ ./build_linux.sh
(if using PortAudio)
$ sudo apt install portaudio19-dev
$ ./build_linux.sh portaudio
```
(For Ubuntu 20.04 the wxWidgets package is named `libwxgtk3.0-gtk3-dev`.)

(Depending on release you may need to use `libwxgtk3.0-gtk3-dev` instead of `libwxgtk3.2-dev`.)

Then run with:
```
Expand All @@ -26,50 +35,26 @@ This document describes how to build the FreeDV GUI program for various operatin

Note this builds all libraries locally, nothing is installed on your machine. ```make install``` is not required.

## Building on Fedora Linux with PortAudio
## Building on Fedora Linux
```
$ sudo dnf groupinstall "Development Tools"
$ sudo dnf install cmake wxGTK3-devel portaudio-devel libsamplerate-devel \
$ sudo dnf install cmake wxGTK3-devel libsamplerate-devel \
libsndfile-devel speexdsp-devel hamlib-devel alsa-lib-devel libao-devel \
gsm-devel gcc-c++ sox
$ git clone https://github.com/drowe67/freedv-gui.git
$ cd freedv-gui
(if using pipewire/PulseAudio -- default and recommended)
$ sudo dnf install pulseaudio-libs-devel
$ ./build_linux.sh
(if using PortAudio)
$ sudo dnf install portaudio-devel
$ ./build_linux.sh portaudio
```
Then run with:
```
$ ./build_linux/src/freedv
```

## Building on Ubuntu Linux (16-20) with PulseAudio
```
$ sudo apt install libspeexdsp-dev libsamplerate0-dev sox git \
libwxgtk3.0-gtk3-dev libhamlib-dev libasound2-dev libao-dev \
libgsm1-dev libsndfile1-dev cmake module-assistant build-essential libpulse-dev
$ git clone https://github.com/drowe67/freedv-gui.git
$ cd freedv-gui
$ ./build_linux.sh pulseaudio
```
(For Ubuntu 20.04 the wxWidgets package is named `libwxgtk3.0-gtk3-dev`.)

Then run with:
```
$ ./build_linux/src/freedv
```

Note this builds all libraries locally, nothing is installed on your machine. ```make install``` is not required.

## Building on Fedora Linux with PulseAudio
```
$ sudo dnf groupinstall "Development Tools"
$ sudo dnf install cmake wxGTK3-devel libsamplerate-devel \
libsndfile-devel speexdsp-devel hamlib-devel alsa-lib-devel libao-devel \
gsm-devel pulseaudio-libs-devel gcc-c++ sox
$ git clone https://github.com/drowe67/freedv-gui.git
$ cd freedv-gui
$ ./build_linux.sh pulseaudio
```
Then run with:
```
$ ./build_linux/src/freedv
```
Expand All @@ -87,125 +72,53 @@ You need to install the codec2 and lpcnetfreedv shared libraries, and freedv-gui
$ sudo ldconfig
```

## Generating Debian packages

To generate a Debian/Ubuntu package, simply run the "cpack" command after running "make". The resulting .deb file can then be installed by running "dpkg -i" (once Codec2 and LPCNet packages are also installed).

## Testing

The ```wav``` directory contains test files of modulated audio that you can use to test FreeDV (see the [USER_MANUAL](USER_MANUAL.md)).

## Building for Windows using Docker

The Windows build process has been automated using a Docker container, see the freedv-gui Docker [README](docker/README_docker.md).
## Building for Windows

## Building for Windows on Fedora (Cross compiling)

Install basic MinGW development packages:
```
$ sudo dnf install mingw{32,64}-filesystem mingw{32,64}-binutils \
mingw{32,64}-gcc mingw{32,64}-crt mingw{32,64}-headers mingw32-nsis
```

Install dependencies of FreeDV/Codec2:
```
$ sudo dnf install mingw{32,64}-speex
```

Enable Freetel specific packages not currently in Fedora proper:
```
$ sudo dnf install dnf-plugins-core
$ sudo dnf copr enable hobbes1069/mingw
$ sudo dnf install mingw{32,64}-wxWidgets3 mingw{32,64}-hamlib \
mingw{32,64}-portaudio mingw{32,64}-libsndfile mingw{32,64}-libsamplerate.noarch
```

Clone freedv-gui:
```
$ cd
$ git clone https://github.com/drowe67/freedv-gui.git
```

Building FreeDV for 64 Bit windows:
```
$ cd ~/freedv-gui
$ ./build_windows.sh
$ cd build_win64
$ make package
```

**OR** Building FreeDV for 32 Bit windows:
```
$ cd ~/freedv-gui
$ CMAKE=mingw32-cmake ./build_windows.sh
$ cd build_win32
$ make package
```

### Building FreeDV using LLVM MinGW (EXPERIMENTAL)

It is now possible to use the LLVM version of MinGW to build FreeDV. This allows
Windows releases are built using the LLVM version of MinGW. This allows
one to build FreeDV for ARM as well as for Intel Windows systems, including support
for 2020 mode (on systems fast enough to acceptably decode it).

#### Prerequisites
### Prerequisites

* CMake >= 3.25.0
* Linux (tested on Ubuntu 22.04)
* *NOTE: This does not currently work on macOS due to CMake using incorrect library suffixes.*
* NSIS for generating the installer (for example, `sudo apt install nsis` on Ubuntu)

#### Instructions
### Instructions

1. Download LLVM MinGW at https://github.com/mstorsjo/llvm-mingw/releases/tag/20220906.
1. Download LLVM MinGW at https://github.com/mstorsjo/llvm-mingw/releases/.
2. Decompress into your preferred location. For example: `tar xvf llvm-mingw-20220906-ucrt-ubuntu-18.04-x86_64.tar.xz` (The exact filename here will depend on the file downloaded in step (1). Note that for best results, you should use a build containing "ucrt" in the file name corresponding to the platform which you're building the Windows binary from.)
3. Add LLVM MinGW to your PATH: `export PATH=/path/to/llvm-mingw-20220906-ucrt-ubuntu-18.04-x86_64/bin:$PATH`. (The folder containing the LLVM tools is typically named the same as the file downloaded in step (2) minus the extension.)
4. Create a build folder inside freedv-gui: `mkdir build_windows`
5. Run CMake to configure the FreeDV build: `cd build_windows && cmake -DCMAKE_TOOLCHAIN_FILE=${PWD}/../cross-compile/freedv-mingw-llvm-[architecture].cmake ..`
* Valid architectures are: aarch64, armv7, i686, x86_64
* Valid architectures are: aarch64 (64 bit ARM), i686 (32 bit Intel/AMD), x86_64 (64 bit Intel/AMD)
6. Build FreeDV as normal: `make` (You can also add `-j[num]` to the end of this command to use multiple cores and shorten the build time.)
7. Create FreeDV installer: `make package`

#### Known Issues
### Known Issues

* NSIS-related issues:
* ARM installers will not properly register in Windows despite installing properly. You can still run the application manually by navigating to C:\Program Files\FreeDV \[version\]\ using File Explorer and double-clicking on `freedv.exe`.

### Testing Windows Build
## Building and installing on macOS

Conveniently, it is possible to run Windows executables using Wine on Fedora:
Using MacPorts, most of the appropriate dependencies can be installed by:

Testing LPCNet:
```
$ cd ~/freedv-gui/LPCNet/build_win/src
$ WINEPATH=$HOME/freedv-gui/codec2/build_win/src';'$HOME/freedv-gui/build_win/_CPack_Packages/win64/NSIS/FreeDV-1.4.0-devel-win64/bin/ wine lpcnet_enc.exe --infile all.wav --outfile all.bit
$ WINEPATH=$HOME/freedv-gui/codec2/build_win/src';'$HOME/freedv-gui/build_win/_CPack_Packages/win64/NSIS/FreeDV-1.4.0-devel-win64/bin/ wine lpcnet_dec.exe --infile all.bin --outfile all_out.raw
$ cat all_out.raw | aplay -f S16_LE -r 16000
$ sudo port install automake git libtool sox +universal cmake
```

Testing FreeDV API:
and on Homebrew:

```
$ cd freedv-gui/codec2/build_win/src
$ WINEPATH=$HOME/freedv-gui/LPCNet/build_win/src';'$HOME/freedv-gui/build_win/_CPack_Packages/win64/NSIS/FreeDV-1.4.0-devel-win64/bin/ wine freedv_rx 2020 ~/freedv-gui/wav/all_2020.wav out.raw
$ play -t .s16 -r 16000 -b 16 out.raw
$ brew install automake libtool git sox cmake
```

## Building and installing on macOS

Using MacPorts, most of the appropriate dependencies can be installed by:

$ sudo port install subversion git libtool sox +universal cmake

It should be fairly similar using HomeBrew, but you will need to replace all the /opt/ paths in the following instructions.

Note: If using an ARM Mac, you may need to build and install the Git version of MacPorts first. See https://guide.macports.org/#installing.macports.git for more details on how to do this.

Once the dependencies are installed, you can then run the `build_osx.sh` script inside the source tree to build
FreeDV and associated libraries (codec2, LPCNet, hamlib). A FreeDV.app app bundle will be created inside the build_osx/src
folder which can be copied to your system's Applications folder.

## Building and installing on FreeBSD

In ```build_linux.sh``` change the ```build_linux``` directory to build_freebsd.
Loading

0 comments on commit 47bf1d8

Please sign in to comment.