diff --git a/.github/workflows/cmake-windows.yml b/.github/workflows/cmake-windows.yml index 995429068..9ae6d8272 100644 --- a/.github/workflows/cmake-windows.yml +++ b/.github/workflows/cmake-windows.yml @@ -39,7 +39,7 @@ jobs: export PATH=${{github.workspace}}/llvm-mingw-20230320-ucrt-ubuntu-18.04-x86_64/bin:$PATH mkdir build_windows cd build_windows - cmake -DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}/cross-compile/freedv-mingw-llvm-x86_64.cmake .. + cmake -DBOOTSTRAP_LPCNET=1 -DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}/cross-compile/freedv-mingw-llvm-x86_64.cmake .. - name: Build freedv-gui shell: bash diff --git a/CMakeLists.txt b/CMakeLists.txt index a3381e247..57cbaf27c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,7 +48,7 @@ endif(APPLE) # Adds a tag to the end of the version string. Leave empty # for official release builds. -set(FREEDV_VERSION_TAG "devel") +set(FREEDV_VERSION_TAG "") # Prevent in-source builds to protect automake/autoconf config. # If an in-source build is attempted, you will still need to clean up a few @@ -130,7 +130,9 @@ set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_VERBOSE_MAKEFILE TRUE CACHE BOOL "Verbose makefile.") set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE CACHE BOOL "Enable IDE features.") set(USE_INTERNAL_CODEC2 FALSE CACHE BOOL - "Download and build codec2 and lpcnetfreedv instead of using the system library.") + "Download and build codec2 instead of using the system library.") +set(BOOTSTRAP_LPCNET FALSE CACHE BOOL + "Download and build LPCNet instead of using the system library.") set(USE_STATIC_DEPS FALSE CACHE BOOL "Download and build static libraries instead of system libraries.") set(USE_STATIC_PORTAUDIO FALSE CACHE BOOL @@ -254,7 +256,7 @@ if(MINGW) # shared DLL doesn't work. set(USE_STATIC_PORTAUDIO TRUE) unset(USE_INTERNAL_CODEC2 CACHE) - set(USE_INTERNAL_CODEC2 TRUE CACHE BOOL "Perform nternal buils of codec2 and lpcnetfreedv") + set(USE_INTERNAL_CODEC2 TRUE CACHE BOOL "Perform internal builds of codec2") # Setup HOST variables. include(cmake/MinGW.cmake) # This sets up the exe icon for windows under mingw. @@ -349,7 +351,8 @@ if(CODEC2_BUILD_DIR) CONFIGS lpcnetfreedv.cmake ) else() - message(FATAL_ERROR "Must use LPCNet from build directory if using codec2 from build directory.") + set(LPCNET_DISABLED YES) + add_definitions(-DLPCNET_DISABLED) endif() elseif(USE_INTERNAL_CODEC2) message(STATUS "Will attempt internal build of codec2 and lpcnetfreedv.") diff --git a/README.md b/README.md index 9bf649b6f..54f4b8a46 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,24 @@ This document describes how to build the FreeDV GUI program for various operatin ``` $ ./build_linux/src/freedv ``` - + +## Building without LPCNet + +In preparation for possible future deprecation of FreeDV 2020 and 2020B modes, it is +possible to build without requiring the [LPCNet](https://github.com/drowe67/LPCNet.git) library. +To do this, pass `LPCNET_DISABLE=1` as an environment variable to the build script, i.e. + +``` +$ LPCNET_DISABLE=1 ./build_linux.sh +``` + +or alternatively, do not pass in `LPCNET_BUILD_DIR` to `cmake` if manually executing the build. +This also has the side effect of disabling 2020 and 2020B in the user interface, preventing either +from being selected. + +*Note: if you don't already have Codec2 installed on your machine, you will need to pass `-DBOOTSTRAP_LPCNET=1` +to `cmake` in order for LPCNet to also be built.* + ## Installing on Linux You need to install the codec2 and lpcnetfreedv shared libraries, and freedv-gui: diff --git a/USER_MANUAL.md b/USER_MANUAL.md index 100c7ad5d..01f0ec4ba 100644 --- a/USER_MANUAL.md +++ b/USER_MANUAL.md @@ -889,7 +889,7 @@ LDPC | Low Density Parity Check Codes - a family of powerful FEC codes # Release Notes -## V1.9.9 TBD 2024 +## V1.9.9 April 2024 1. Bugfixes: * Cache PortAudio sound info to improve startup performance. (PR #689) @@ -904,6 +904,8 @@ LDPC | Low Density Parity Check Codes - a family of powerful FEC codes * Add context menu for copying messages to the clipboard. (PR #694) 3. Documentation: * Remove broken links in README. (PR #709) +4. Build system: + * Add ability to build without LPCNet in preparation for potential future deprecation of 2020/2020B. (PR #711) ## V1.9.8 February 2024 diff --git a/build_linux.sh b/build_linux.sh index a0c3eb3dc..0478938e1 100755 --- a/build_linux.sh +++ b/build_linux.sh @@ -8,6 +8,7 @@ set -x -e UT_ENABLE=${UT_ENABLE:-0} +LPCNET_DISABLE=${LPCNET_DISABLE:-0} # Allow building of either PulseAudio or PortAudio variants FREEDV_VARIANT=${1:-pulseaudio} @@ -26,15 +27,31 @@ LPCNET_BRANCH=v0.5 # OK, build and test LPCNet cd $FREEDVGUIDIR -if [ ! -d LPCNet ]; then - git clone https://github.com/drowe67/LPCNet.git +if [ $LPCNET_DISABLE == 0 ]; then + if [ ! -d LPCNet ]; then + git clone https://github.com/drowe67/LPCNet.git + fi + cd $LPCNETDIR && git switch master && git pull && git checkout $LPCNET_BRANCH + mkdir -p build_linux && cd build_linux && rm -Rf * + cmake .. + if [ $? == 0 ]; then + make + if [ $? == 0 ]; then + # sanity check test + cd src && sox ../../wav/wia.wav -t raw -r 16000 - | ./lpcnet_enc -s | ./lpcnet_dec -s > /dev/null + else + echo "Warning: LPCNet build failed, disabling" + LPCNET_DISABLE=1 + fi + else + echo "Warning: LPCNet build failed, disabling" + LPCNET_DISABLE=1 + fi +fi + +if [ $LPCNET_DISABLE == 0 ]; then + LPCNET_CMAKE_CMD="-DLPCNET_BUILD_DIR=$LPCNETDIR/build_linux" fi -cd $LPCNETDIR && git switch master && git pull && git checkout $LPCNET_BRANCH -mkdir -p build_linux && cd build_linux && rm -Rf * -cmake .. -make -# sanity check test -cd src && sox ../../wav/wia.wav -t raw -r 16000 - | ./lpcnet_enc -s | ./lpcnet_dec -s > /dev/null # First build and install vanilla codec2 as we need -lcodec2 to build LPCNet cd $FREEDVGUIDIR @@ -42,11 +59,13 @@ if [ ! -d codec2 ]; then git clone https://github.com/drowe67/codec2.git fi cd codec2 && git switch main && git pull && git checkout $CODEC2_BRANCH -mkdir -p build_linux && cd build_linux && rm -Rf * && cmake -DLPCNET_BUILD_DIR=$LPCNETDIR/build_linux .. && make VERBOSE=1 -# sanity check test -cd src -export LD_LIBRARY_PATH=$LPCNETDIR/build_linux/src -./freedv_tx 2020 $LPCNETDIR/wav/wia.wav - | ./freedv_rx 2020 - /dev/null +mkdir -p build_linux && cd build_linux && rm -Rf * && cmake $LPCNET_CMAKE_CMD .. && make VERBOSE=1 +if [ $LPCNET_DISABLE == 0 ]; then + # sanity check test + cd src + export LD_LIBRARY_PATH=$LPCNETDIR/build_linux/src + ./freedv_tx 2020 $LPCNETDIR/wav/wia.wav - | ./freedv_rx 2020 - /dev/null +fi # Finally, build freedv-gui cd $FREEDVGUIDIR @@ -59,5 +78,5 @@ if [[ "$FREEDV_VARIANT" == "pulseaudio" ]]; then else PULSEAUDIO_PARAM="-DUSE_PULSEAUDIO=0" fi -cmake $PULSEAUDIO_PARAM -DUNITTEST=$UT_ENABLE -DCMAKE_BUILD_TYPE=Debug -DCODEC2_BUILD_DIR=$CODEC2DIR/build_linux -DLPCNET_BUILD_DIR=$LPCNETDIR/build_linux .. +cmake $PULSEAUDIO_PARAM -DUNITTEST=$UT_ENABLE -DCMAKE_BUILD_TYPE=Debug -DCODEC2_BUILD_DIR=$CODEC2DIR/build_linux $LPCNET_CMAKE_CMD .. make VERBOSE=1 diff --git a/build_osx.sh b/build_osx.sh index 14afdf96c..4611e6be2 100755 --- a/build_osx.sh +++ b/build_osx.sh @@ -11,6 +11,7 @@ export HAMLIBDIR=$FREEDVGUIDIR/hamlib export CODEC2_BRANCH=1.2.0 export LPCNET_BRANCH=v0.5 export UT_ENABLE=${UT_ENABLE:-0} +LPCNET_DISABLE=${LPCNET_DISABLE:-0} # Prerequisite: build dylibbundler if [ ! -d macdylibbundler ]; then @@ -32,16 +33,31 @@ make install # OK, build and test LPCNet cd $FREEDVGUIDIR -if [ ! -d LPCNet ]; then - git clone https://github.com/drowe67/LPCNet.git +if [ $LPCNET_DISABLE == 0 ]; then + if [ ! -d LPCNet ]; then + git clone https://github.com/drowe67/LPCNet.git + fi + cd $LPCNETDIR && git checkout master && git pull && git checkout $LPCNET_BRANCH + mkdir -p build_osx && cd build_osx && rm -Rf * + cmake -DBUILD_OSX_UNIVERSAL=1 .. + if [ $? == 0 ]; then + make -j4 + if [ $? == 0 ]; then + # sanity check test + cd src && sox ../../wav/wia.wav -t raw -r 16000 - | ./lpcnet_enc -s | ./lpcnet_dec -s > /dev/null + else + echo "Warning: LPCNet build failed, disabling" + LPCNET_DISABLE=1 + fi + else + echo "Warning: LPCNet build failed, disabling" + LPCNET_DISABLE=1 + fi fi -cd $LPCNETDIR && git checkout master && git pull && git checkout $LPCNET_BRANCH -mkdir -p build_osx && cd build_osx && rm -Rf * -cmake -DBUILD_OSX_UNIVERSAL=1 .. -make -j4 -# sanity check test -cd src && sox ../../wav/wia.wav -t raw -r 16000 - | ./lpcnet_enc -s | ./lpcnet_dec -s > /dev/null +if [ $LPCNET_DISABLE == 0 ]; then + LPCNET_CMAKE_CMD="-DLPCNET_BUILD_DIR=$LPCNETDIR/build_osx" +fi # Build codec2 with LPCNet and test FreeDV 2020 support cd $FREEDVGUIDIR @@ -49,7 +65,7 @@ if [ ! -d codec2 ]; then git clone https://github.com/drowe67/codec2-new.git codec2 fi cd codec2 && git switch main && git pull && git checkout $CODEC2_BRANCH -mkdir -p build_osx && cd build_osx && rm -Rf * && cmake -DLPCNET_BUILD_DIR=$LPCNETDIR/build_osx -DBUILD_OSX_UNIVERSAL=1 .. && make VERBOSE=1 -j4 +mkdir -p build_osx && cd build_osx && rm -Rf * && cmake ${LPCNET_CMAKE_CMD} -DBUILD_OSX_UNIVERSAL=1 .. && make VERBOSE=1 -j4 # sanity check test cd src @@ -62,5 +78,5 @@ if [ -d .git ]; then git pull fi mkdir -p build_osx && cd build_osx && rm -Rf * -cmake -DUNITTEST=1 -DBUILD_OSX_UNIVERSAL=1 -DUNITTEST=$UT_ENABLE -DCMAKE_BUILD_TYPE=Debug -DBOOTSTRAP_WXWIDGETS=1 -DUSE_STATIC_SPEEXDSP=1 -DUSE_STATIC_PORTAUDIO=1 -DUSE_STATIC_SAMPLERATE=1 -DUSE_STATIC_SNDFILE=1 -DHAMLIB_INCLUDE_DIR=${HAMLIBDIR}/include -DHAMLIB_LIBRARY=${HAMLIBDIR}/lib/libhamlib.dylib -DCODEC2_BUILD_DIR=$CODEC2DIR/build_osx -DLPCNET_BUILD_DIR=$LPCNETDIR/build_osx .. +cmake -DUNITTEST=1 -DBUILD_OSX_UNIVERSAL=1 -DUNITTEST=$UT_ENABLE -DCMAKE_BUILD_TYPE=Debug -DBOOTSTRAP_WXWIDGETS=1 -DUSE_STATIC_SPEEXDSP=1 -DUSE_STATIC_PORTAUDIO=1 -DUSE_STATIC_SAMPLERATE=1 -DUSE_STATIC_SNDFILE=1 -DHAMLIB_INCLUDE_DIR=${HAMLIBDIR}/include -DHAMLIB_LIBRARY=${HAMLIBDIR}/lib/libhamlib.dylib -DCODEC2_BUILD_DIR=$CODEC2DIR/build_osx ${LPCNET_CMAKE_CMD} .. make VERBOSE=1 -j8 diff --git a/build_signed_windows_release.sh b/build_signed_windows_release.sh index 414980933..683bb497d 100755 --- a/build_signed_windows_release.sh +++ b/build_signed_windows_release.sh @@ -33,7 +33,7 @@ for arch in x86_64 i686 aarch64; do cd $BUILD_ARCH_DIR # Kick off new build with the given architecture - cmake -DSIGN_WINDOWS_BINARIES=1 -DPKCS11_CERTIFICATE_FILE=$CERT_URL_FILE -DPKCS11_KEY_FILE=$KEY_URL_FILE -DINTERMEDIATE_CERT_FILE=$INTERMEDIATE_CERT_FILE -DCMAKE_TOOLCHAIN_FILE=$SCRIPT_DIR/cross-compile/freedv-mingw-llvm-$arch.cmake $SCRIPT_DIR + cmake -DBOOTSTRAP_LPCNET=1 -DSIGN_WINDOWS_BINARIES=1 -DPKCS11_CERTIFICATE_FILE=$CERT_URL_FILE -DPKCS11_KEY_FILE=$KEY_URL_FILE -DINTERMEDIATE_CERT_FILE=$INTERMEDIATE_CERT_FILE -DCMAKE_TOOLCHAIN_FILE=$SCRIPT_DIR/cross-compile/freedv-mingw-llvm-$arch.cmake $SCRIPT_DIR make -j6 package cp FreeDV-*.exe $WIN_BUILD_DIR cd $WIN_BUILD_DIR diff --git a/cmake/BuildCodec2.cmake b/cmake/BuildCodec2.cmake index 8b484fc1a..b7afa480e 100644 --- a/cmake/BuildCodec2.cmake +++ b/cmake/BuildCodec2.cmake @@ -9,10 +9,15 @@ if(BUILD_OSX_UNIVERSAL) endif(BUILD_OSX_UNIVERSAL) # Bootstrap lpcnetfreedv library -include(cmake/BuildLPCNet.cmake) +if(BOOTSTRAP_LPCNET) + include(cmake/BuildLPCNet.cmake) + set(CODEC2_CMAKE_ARGS ${CODEC2_CMAKE_ARGS} -DLPCNET_BUILD_DIR=${CMAKE_BINARY_DIR}/LPCNet_build) +else(BOOTSTRAP_LPCNET) + add_definitions(-DLPCNET_DISABLED) + set(LPCNET_DISABLED YES) +endif(BOOTSTRAP_LPCNET) # Build codec2 library with lpcnetfreedv -set(CODEC2_CMAKE_ARGS ${CODEC2_CMAKE_ARGS} -DLPCNET_BUILD_DIR=${CMAKE_BINARY_DIR}/LPCNet_build) include(ExternalProject) ExternalProject_Add(build_codec2 SOURCE_DIR codec2_src @@ -33,7 +38,9 @@ set_target_properties(codec2 PROPERTIES IMPORTED_IMPLIB "${BINARY_DIR}/src/libcodec2${CMAKE_IMPORT_LIBRARY_SUFFIX}" ) +if(BOOTSTRAP_LPCNET) add_dependencies(build_codec2 build_lpcnetfreedv) +endif(BOOTSTRAP_LPCNET) set(CODEC2_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/codec2_src/src ${CMAKE_BINARY_DIR}/codec2_build) include_directories(${CODEC2_INCLUDE_DIRS}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cd55fcfb6..ba8f79c38 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -47,18 +47,24 @@ else() endif(APPLE) # Link imported or build tree targets. +if(NOT LPCNET_DISABLED) +set(LPCNET_LIB_NAME lpcnetfreedv) +else(NOT LPCNET_DISABLED) +set(LPCNET_LIB_NAME ) +endif(NOT LPCNET_DISABLED) + if(APPLE) -target_link_libraries(FreeDV fdv_audio fdv_audio_pipeline fdv_config fdv_gui_controls fdv_gui_dialogs fdv_gui_util fdv_os_wrapper fdv_rig_control fdv_reporting fdv_sox fdv_util lpcnetfreedv codec2) +target_link_libraries(FreeDV fdv_audio fdv_audio_pipeline fdv_config fdv_gui_controls fdv_gui_dialogs fdv_gui_util fdv_os_wrapper fdv_rig_control fdv_reporting fdv_sox fdv_util ${LPCNET_LIB_NAME} codec2) else(APPLE) -target_link_libraries(freedv fdv_audio fdv_audio_pipeline fdv_config fdv_gui_controls fdv_gui_dialogs fdv_gui_util fdv_os_wrapper fdv_rig_control fdv_reporting fdv_sox fdv_util lpcnetfreedv codec2) +target_link_libraries(freedv fdv_audio fdv_audio_pipeline fdv_config fdv_gui_controls fdv_gui_dialogs fdv_gui_util fdv_os_wrapper fdv_rig_control fdv_reporting fdv_sox fdv_util ${LPCNET_LIB_NAME} codec2) endif(APPLE) # Add build dependencies for internally built external libraries. if(USE_INTERNAL_CODEC2) if(APPLE) - add_dependencies(FreeDV build_codec2 build_lpcnetfreedv) + add_dependencies(FreeDV build_codec2) else(APPLE) - add_dependencies(freedv build_codec2 build_lpcnetfreedv) + add_dependencies(freedv build_codec2) endif(APPLE) endif() diff --git a/src/main.cpp b/src/main.cpp index 251ed0221..3748687ee 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -288,7 +288,10 @@ void MainFrame::test2020Mode_() { printf("Making sure your machine can handle 2020 mode:\n"); - bool allowed = test2020HWAllowed_(); + bool allowed = false; + +#if !defined(LPCNET_DISABLED) + allowed = test2020HWAllowed_(); wxGetApp().appConfiguration.freedvAVXSupported = allowed; if (!allowed) @@ -363,6 +366,7 @@ void MainFrame::test2020Mode_() std::cout << "One second of 2020 decoded in " << timeTaken.count() << " ms" << std::endl; } +#endif // !defined(LPCNET_DISABLED) std::cout << "2020 allowed: " << allowed << std::endl; @@ -859,7 +863,7 @@ MainFrame::MainFrame(wxWindow *parent) : TopFrame(parent, wxID_ANY, _("FreeDV ") } #endif -#if defined(FREEDV_MODE_2020) +#if defined(FREEDV_MODE_2020) && !defined(LPCNET_DISABLED) // First time use: make sure 2020 mode will actually work on this machine. if (wxGetApp().appConfiguration.firstTimeUse) { @@ -869,7 +873,10 @@ MainFrame::MainFrame(wxWindow *parent) : TopFrame(parent, wxID_ANY, _("FreeDV ") { wxGetApp().appConfiguration.freedvAVXSupported = test2020HWAllowed_(); } -#endif // defined(FREEDV_MODE_2020) +#else + // Disable LPCNet if not compiled in. + wxGetApp().appConfiguration.freedv2020Allowed = false; +#endif // defined(FREEDV_MODE_2020) && !defined(LPCNET_DISABLED) if(!wxGetApp().appConfiguration.freedv2020Allowed || !wxGetApp().appConfiguration.freedvAVXSupported) { diff --git a/src/ongui.cpp b/src/ongui.cpp index 0405a3972..01f8049de 100644 --- a/src/ongui.cpp +++ b/src/ongui.cpp @@ -9,7 +9,9 @@ #include #include "main.h" +#if !defined(LPCNET_DISABLED) #include "lpcnet_freedv.h" +#endif // defined(LPCNET_DISABLED) #include "gui/dialogs/dlg_easy_setup.h" #include "gui/dialogs/dlg_filter.h" @@ -351,8 +353,14 @@ void MainFrame::OnHelpAbout(wxCommandEvent& event) wxT("freedv-gui version: %s\n") wxT("freedv-gui git hash: %s\n") wxT("codec2 git hash: %s\n") - wxT("lpcnet git hash: %s\n"), - FREEDV_VERSION, FREEDV_VERSION, GIT_HASH, freedv_get_hash(), lpcnet_get_hash()); +#if !defined(LPCNET_DISABLED) + wxT("lpcnet git hash: %s\n") +#endif // !defined(LPCNET_DISABLED) + , FREEDV_VERSION, FREEDV_VERSION, GIT_HASH, freedv_get_hash() +#if !defined(LPCNET_DISABLED) + , lpcnet_get_hash() +#endif // !defined(LPCNET_DISABLED) + ); wxMessageBox(msg, wxT("About"), wxOK | wxICON_INFORMATION, this); }