Cleaned up the MacOS tools and enabled the plutosdr_source in the MacOS CI

This commit is contained in:
Alexandre 2021-11-17 15:04:20 -06:00
parent a08f5c35af
commit 170a48f83f
9 changed files with 256 additions and 492 deletions

View File

@ -95,9 +95,15 @@ jobs:
- name: Install SDRplay API
run: wget https://www.sdrplay.com/software/SDRplay_RSP_API-MacOSX-3.07.3.pkg && sudo installer -pkg SDRplay_RSP_API-MacOSX-3.07.3.pkg -target /
- name: Install libiio
run: mkdir libiio && cd libiio && wget https://github.com/analogdevicesinc/libiio/releases/download/v0.23/macOS-10.15.pkg && sudo installer -pkg macOS-10.15.pkg -target /
- name: Install libad9361
run: wget https://github.com/analogdevicesinc/libad9361-iio/releases/download/v0.2/libad9361-0.2.pkg && sudo installer -pkg libad9361-0.2.pkg -target /
- name: Prepare CMake
working-directory: ${{runner.workspace}}/build
run: cmake $GITHUB_WORKSPACE -DOPT_BUILD_PLUTOSDR_SOURCE=OFF -DOPT_BUILD_SOAPY_SOURCE=OFF -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_AUDIO_SINK=OFF -DOPT_BUILD_PORTAUDIO_SINK=ON -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON -DOPT_BUILD_M17_DECODER=ON -DUSE_DOTAPP_DEFAULTS=ON -DCMAKE_BUILD_TYPE=Release
run: cmake $GITHUB_WORKSPACE -DOPT_BUILD_PLUTOSDR_SOURCE=ON -DOPT_BUILD_SOAPY_SOURCE=OFF -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_AUDIO_SINK=OFF -DOPT_BUILD_PORTAUDIO_SINK=ON -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON -DOPT_BUILD_M17_DECODER=ON -DUSE_DOTAPP_DEFAULTS=ON -DCMAKE_BUILD_TYPE=Release
- name: Build
working-directory: ${{runner.workspace}}/build
@ -105,7 +111,7 @@ jobs:
- name: Create Archive
working-directory: ${{runner.workspace}}
run: cd $GITHUB_WORKSPACE && sh make_macos_dotapp_new.sh ${{runner.workspace}}/build ./SDR++.app && zip -r ${{runner.workspace}}/sdrpp_macos_intel.zip SDR++.app
run: cd $GITHUB_WORKSPACE && sh make_macos_dotapp.sh ${{runner.workspace}}/build ./SDR++.app && zip -r ${{runner.workspace}}/sdrpp_macos_intel.zip SDR++.app
- name: Save Archive
uses: actions/upload-artifact@v2

183
macos/bundle_utils.sh Normal file
View File

@ -0,0 +1,183 @@
#==============================================#
# MacOS Bundle Utilities #
# Copyright(C) Ryzerth, 2021 #
#==============================================#
# ========================= Customization =========================
# bundle_is_not_to_be_installed [dylib_name]
bundle_is_not_to_be_installed() {
# NOTE: Customize this list to exclude libraries you don't want copied into the bundle
if [ "$1" = "libsdrpp_core.dylib" ]; then echo 1; fi
if [ "$1" = "OpenGL" ]; then echo 1; fi
if [ "$1" = "libc++.1.dylib" ]; then echo 1; fi
if [ "$1" = "libSystem.B.dylib" ]; then echo 1; fi
if [ "$1" = "Cocoa" ]; then echo 1; fi
if [ "$1" = "IOKit" ]; then echo 1; fi
if [ "$1" = "CoreFoundation" ]; then echo 1; fi
if [ "$1" = "AppKit" ]; then echo 1; fi
if [ "$1" = "CoreGraphics" ]; then echo 1; fi
if [ "$1" = "CoreServices" ]; then echo 1; fi
if [ "$1" = "Foundation" ]; then echo 1; fi
if [ "$1" = "CoreAudio" ]; then echo 1; fi
if [ "$1" = "AudioToolbox" ]; then echo 1; fi
if [ "$1" = "AudioUnit" ]; then echo 1; fi
if [ "$1" = "libobjc.A.dylib" ]; then echo 1; fi
}
# ========================= FOR INTERNAL USE ONLY =========================
# bundle_get_first_element [elem0] [elem1] [elem2] ...
bundle_get_first_element() {
echo $1
}
# bundle_get_second_element [elem0] [elem1] [elem2] ...
bundle_get_second_element() {
echo $2
}
# bundle_get_exec_deps [exec_path]
bundle_get_exec_deps() {
DEPS_RAW=$(otool -L $1 | tail -n +2)
# Iterate over all lines
echo "$DEPS_RAW" | while read -r DEP; do
echo $(bundle_get_first_element $DEP)
done
}
# bundle_get_exec_rpaths [exec_path]
bundle_get_exec_rpaths() {
RPATHS_RAW=$(otool -l $1 | grep "path\ ")
# Iterate over all lines
echo "$RPATHS_RAW" | while read -r RPATH; do
echo $(bundle_get_second_element $RPATH)
done
}
# ========================= Public Functions =========================
bundle_create_struct() {
if [ $# -ne 1 ]; then
echo "bundle_create_struct [bundle_path]";
return
fi
mkdir -p $1
mkdir -p $1/Contents
mkdir -p $1/Contents/MacOS
mkdir -p $1/Contents/Frameworks
mkdir -p $1/Contents/Resources
mkdir -p $1/Contents/Plugins
}
bundle_install_binary() {
if [ $# -ne 3 ]; then
echo "bundle_install_binary [bundle_path] [exec_path] [install_path]";
return
fi
local EXEC_NAME=$(basename $3)
local EXEC_DEST=$2/$EXEC_NAME
# Check if file exists
if [ ! -f $3 ]; then
echo "==NOT== Installing" $EXEC_NAME
return
fi
echo "Installing" $EXEC_NAME
# Copy it to its install location
cp $3 $EXEC_DEST
# Install dependencies and change path
local DEPS=$(bundle_get_exec_deps $EXEC_DEST)
echo "$DEPS" | while read -r DEP; do
local DEP_NAME=$(basename $DEP)
# Skip if this dep is blacklisted
local NOT_TO_BE_INSTALLED=$(bundle_is_not_to_be_installed $DEP_NAME)
if [ "$NOT_TO_BE_INSTALLED" = "1" ]; then
continue
fi
# Skip if this dep is itself
if [ "$DEP_NAME" = "$EXEC_NAME" ]; then
continue
fi
# If the dependency is not installed, install it
if [ ! -f $1/Contents/Frameworks/$DEP_NAME ]; then
bundle_install_binary $1 $1/Contents/Frameworks $DEP
fi
# Fix path
install_name_tool -change $DEP @rpath/$DEP_NAME $EXEC_DEST
done
# Remove all its rpaths
local RPATHS=$(bundle_get_exec_rpaths $EXEC_DEST)
if [ "$RPATHS" != "" ]; then
echo "$RPATHS" | while read -r RPATH; do
install_name_tool -delete_rpath $RPATH $EXEC_DEST
done
fi
# Add new single rpath
install_name_tool -add_rpath @loader_path/../Frameworks $EXEC_DEST
}
bundle_create_icns() {
if [ $# -ne 2 ]; then
echo "bundle_create_icns [image_path] [icns_file]";
return
fi
mkdir $2.iconset
sips -z 16 16 $1 --out $2.iconset/icon_16x16.png
sips -z 32 32 $1 --out $2.iconset/icon_16x16@2x.png
sips -z 32 32 $1 --out $2.iconset/icon_32x32.png
sips -z 64 64 $1 --out $2.iconset/icon_32x32@2x.png
sips -z 128 128 $1 --out $2.iconset/icon_128x128.png
sips -z 256 256 $1 --out $2.iconset/icon_128x128@2x.png
sips -z 256 256 $1 --out $2.iconset/icon_256x256.png
sips -z 512 512 $1 --out $2.iconset/icon_256x256@2x.png
sips -z 512 512 $1 --out $2.iconset/icon_512x512.png
iconutil -c icns $2.iconset
rm -R $2.iconset
}
bundle_create_plist() {
if [ $# -ne 8 ]; then
echo "bundle_create_plist [bundle_name] [display_name] [identifier] [version] [signature] [exec] [icon] [plist]";
return
fi
echo '<?xml version="1.0" encoding="UTF-8"?>' >> $8
echo '<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">' >> $8
echo '' >> $8
echo '<plist version="1.0">' >> $8
echo ' <dict>' >> $8
echo ' <key>CFBundleName</key><string>'$1'</string>' >> $8
echo ' <key>CFBundleDisplayName</key><string>'$2'</string>' >> $8
echo ' <key>CFBundleIdentifier</key><string>o'$3'</string>' >> $8
echo ' <key>CFBundleVersion</key><string>'$4'</string>' >> $8
echo ' <key>CFBundlePackageType</key><string>APPL</string>' >> $8
echo ' <key>CFBundleSignature</key><string>'$5'</string>' >> $8
echo ' <key>CFBundleExecutable</key><string>'$6'</string>' >> $8
echo ' <key>CFBundleIconFile</key><string>'$7'</string>' >> $8
echo ' </dict>' >> $8
echo '</plist>' >> $8
}
bundle_sign() {
if [ $# -ne 1 ]; then
echo "bundle_sign [bundle_dir]";
return
fi
codesign --force --deep -s - $1
}

View File

@ -1,18 +0,0 @@
#!/bin/sh
set -e
# Options
RPATH_NAME=$1
EXEC=$2
# Function to keep only the second arg
get_second_arg() {
echo $2
}
# Get current rpath
WANTED_RPATH=$(get_second_arg $(otool -l $EXEC | grep $RPATH_NAME | grep path))
if [ ! -z "$WANTED_RPATH" ]; then
install_name_tool -delete_rpath $WANTED_RPATH $EXEC
fi

View File

@ -1,14 +0,0 @@
#!/bin/sh
set -e
# Options
WANTED_LIB=$1
EXEC=$2
# Function to extract the first element of a space seperated list
get_first_arg() {
echo $1
}
# Get current path
echo $(get_first_arg $(otool -L $EXEC | grep $WANTED_LIB))

View File

@ -1,14 +0,0 @@
#!/bin/sh
set -e
# Options
RPATH_NAME=$1
EXEC=$2
# Function to keep only the second arg
get_second_arg() {
echo $2
}
# Get current rpath
echo $(get_second_arg $(otool -l $EXEC | grep $RPATH_NAME | grep path))

View File

@ -1,20 +0,0 @@
#!/bin/sh
set -e
# Options
WANTED_LIB=$1
NEW_PATH=$2
EXEC=$3
# Function to extract the first element of a space seperated list
get_first_arg() {
echo $1
}
# Get current path
CURRENT_PATH=$(get_first_arg $(otool -L $EXEC | grep $WANTED_LIB))
# Change to the new path if found
if [ ! -z "$CURRENT_PATH" ]; then
install_name_tool -change $CURRENT_PATH $NEW_PATH $EXEC
fi

65
make_macos_bundle.sh Normal file
View File

@ -0,0 +1,65 @@
#!/bin/sh
set -e
# ========================= Boilerplate =========================
BUILD_DIR=$1
BUNDLE=$2
source macos/bundle_utils.sh
# ========================= Prepare dotapp structure =========================
# Clear .app
rm -rf $BUNDLE
# Create .app structure
bundle_create_struct $BUNDLE
# Add resources
cp -R root/res/* $BUNDLE/Contents/Resources/
# Create the icon file
bundle_create_icns root/res/icons/sdrpp.png $BUNDLE/Contents/Resources/sdrpp
# Create the property list
bundle_create_plist sdrpp SDR++ org.sdrpp.sdrpp 1.0.5 sdrp sdrpp sdrpp $BUNDLE/Contents/Info.plist
# ========================= Install binaries =========================
# Core
bundle_install_binary $BUNDLE $BUNDLE/Contents/MacOS $BUILD_DIR/sdrpp
bundle_install_binary $BUNDLE $BUNDLE/Contents/Frameworks $BUILD_DIR/core/libsdrpp_core.dylib
# Source modules
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/source_modules/airspy_source/airspy_source.dylib
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/source_modules/airspyhf_source/airspyhf_source.dylib
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/source_modules/bladerf_source/bladerf_source.dylib
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/source_modules/file_source/file_source.dylib
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/source_modules/hackrf_source/hackrf_source.dylib
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/source_modules/limesdr_source/limesdr_source.dylib
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/source_modules/plutosdr_source/plutosdr_source.dylib
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/source_modules/rtl_sdr_source/rtl_sdr_source.dylib
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/source_modules/rtl_tcp_source/rtl_tcp_source.dylib
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/source_modules/sdrplay_source/sdrplay_source.dylib
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/source_modules/soapy_source/soapy_source.dylib
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/source_modules/spyserver_source/spyserver_source.dylib
# Sink modules
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/sink_modules/portaudio_sink/audio_sink.dylib
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/sink_modules/network_sink/network_sink.dylib
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/sink_modules/new_portaudio_sink/new_portaudio_sink.dylib
# Decoder modules
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/decoder_modules/m17_decoder/m17_decoder.dylib
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/decoder_modules/meteor_demodulator/meteor_demodulator.dylib
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/decoder_modules/radio/radio.dylib
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/misc_modules/discord_integration/discord_integration.dylib
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/misc_modules/frequency_manager/frequency_manager.dylib
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/misc_modules/recorder/recorder.dylib
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/misc_modules/rigctl_server/rigctl_server.dylib
# ========================= Finalize =========================
# Sign the app
bundle_sign $BUNDLE

View File

@ -1,225 +0,0 @@
#!/bin/sh
set -e
# Options
BUILD_DIR=$1
DOTAPP=$2
# Remove existing .app
rm -rf $DOTAPP
# Create .app structure
mkdir $DOTAPP
mkdir $DOTAPP/Contents
mkdir $DOTAPP/Contents/MacOS
mkdir $DOTAPP/Contents/Frameworks
mkdir $DOTAPP/Contents/Resources
mkdir $DOTAPP/Contents/Plugins
# ========================= Boilerplate =========================
delete_common_rpath() {
# TODO: Also remove build/core if present
sh macos/delete_rpath.sh /usr/local/lib $1
sh macos/delete_rpath.sh glew $1
sh macos/delete_rpath.sh fftw $1
sh macos/delete_rpath.sh glfw $1
}
set_common_rpath() {
sh macos/set_library_path.sh libGLEW @rpath/libGLEW.dylib $1
sh macos/set_library_path.sh libfftw3f @rpath/libfftw3f.dylib $1
sh macos/set_library_path.sh libglfw @rpath/libglfw.dylib $1
sh macos/set_library_path.sh libvolk @rpath/libvolk.dylib $1
install_name_tool -add_rpath @loader_path/../Frameworks $1
}
update_common_rpath() {
delete_common_rpath $1
set_common_rpath $1
}
install_module() {
if [ -f $1 ]; then
BNAME=$(basename $1)
cp $1 $DOTAPP/Contents/Plugins/
update_common_rpath $DOTAPP/Contents/Plugins/$BNAME
fi
}
# ========================= CORE =========================
# Copy files
cp $BUILD_DIR/sdrpp $DOTAPP/Contents/MacOS/
cp $BUILD_DIR/core/libsdrpp_core.dylib $DOTAPP/Contents/Frameworks/
# Get dep paths
LIBGLEW_PATH=$(sh macos/get_library_path.sh libGLEW $DOTAPP/Contents/MacOS/sdrpp)
LIBFFTW3F_PATH=$(sh macos/get_library_path.sh libfftw3f $DOTAPP/Contents/MacOS/sdrpp)
LIBGCC_PATH=$(sh macos/get_library_path.sh libgcc $LIBFFTW3F_PATH)
LIBGLFW_PATH=$(sh macos/get_library_path.sh libglfw $DOTAPP/Contents/MacOS/sdrpp)
LIBVOLK_PATH=$(sh macos/get_library_path.sh libvolk $DOTAPP/Contents/MacOS/sdrpp)
# Copy libfftw3f in advance
cp $LIBFFTW3F_PATH $DOTAPP/Contents/Frameworks/libfftw3f.dylib
cp $LIBGCC_PATH $DOTAPP/Contents/Frameworks/libgcc.dylib
# Udpate old RPATH for sdrpp
update_common_rpath $DOTAPP/Contents/MacOS/sdrpp
sh macos/delete_rpath.sh build/core $DOTAPP/Contents/MacOS/sdrpp
# Udpate old RPATH for libsdrpp_core
update_common_rpath $DOTAPP/Contents/Frameworks/libsdrpp_core.dylib
# Remove libfftw3f signature
codesign --remove-signature $DOTAPP/Contents/Frameworks/libfftw3f.dylib
# Udpate old RPATH for libfftw3f and set new one (do it twice since it has two rpaths for some reason)
sh macos/delete_rpath.sh gcc $DOTAPP/Contents/Frameworks/libfftw3f.dylib
sh macos/delete_rpath.sh gcc $DOTAPP/Contents/Frameworks/libfftw3f.dylib
install_name_tool -add_rpath @loader_path/../Frameworks $DOTAPP/Contents/Frameworks/libfftw3f.dylib
sh macos/set_library_path.sh libgcc @rpath/libgcc.dylib $DOTAPP/Contents/Frameworks/libfftw3f.dylib
# Add back libfftw3f's signature
codesign -s - $DOTAPP/Contents/Frameworks/libfftw3f.dylib
# Copy deps
cp $LIBGLEW_PATH $DOTAPP/Contents/Frameworks/libGLEW.dylib
cp $LIBGLFW_PATH $DOTAPP/Contents/Frameworks/libglfw.dylib
cp $LIBVOLK_PATH $DOTAPP/Contents/Frameworks/libvolk.dylib
# ========================= Resources =========================
cp -R root/res/* $DOTAPP/Contents/Resources/
# ========================= Icon =========================
mkdir $DOTAPP/Contents/Resources/sdrpp.iconset
sips -z 16 16 root/res/icons/sdrpp.png --out $DOTAPP/Contents/Resources/sdrpp.iconset/icon_16x16.png
sips -z 32 32 root/res/icons/sdrpp.png --out $DOTAPP/Contents/Resources/sdrpp.iconset/icon_16x16@2x.png
sips -z 32 32 root/res/icons/sdrpp.png --out $DOTAPP/Contents/Resources/sdrpp.iconset/icon_32x32.png
sips -z 64 64 root/res/icons/sdrpp.png --out $DOTAPP/Contents/Resources/sdrpp.iconset/icon_32x32@2x.png
sips -z 128 128 root/res/icons/sdrpp.png --out $DOTAPP/Contents/Resources/sdrpp.iconset/icon_128x128.png
sips -z 256 256 root/res/icons/sdrpp.png --out $DOTAPP/Contents/Resources/sdrpp.iconset/icon_128x128@2x.png
sips -z 256 256 root/res/icons/sdrpp.png --out $DOTAPP/Contents/Resources/sdrpp.iconset/icon_256x256.png
sips -z 512 512 root/res/icons/sdrpp.png --out $DOTAPP/Contents/Resources/sdrpp.iconset/icon_256x256@2x.png
sips -z 512 512 root/res/icons/sdrpp.png --out $DOTAPP/Contents/Resources/sdrpp.iconset/icon_512x512.png
iconutil -c icns $DOTAPP/Contents/Resources/sdrpp.iconset
rm -R $DOTAPP/Contents/Resources/sdrpp.iconset
# ========================= Source Modules =========================
install_module $BUILD_DIR/source_modules/airspy_source/airspy_source.dylib
LIBAIRSPY_PATH=$(sh macos/get_library_path.sh libairspy $BUILD_DIR/source_modules/airspy_source/airspy_source.dylib)
LIBUSB_PATH=$(sh macos/get_library_path.sh libusb $LIBAIRSPY_PATH)
cp $LIBAIRSPY_PATH $DOTAPP/Contents/Frameworks/libairspy.dylib
cp $LIBUSB_PATH $DOTAPP/Contents/Frameworks/libusb.dylib
sh macos/delete_rpath.sh /airspy/ $DOTAPP/Contents/Plugins/airspy_source.dylib
# sh macos/delete_rpath.sh libusb $DOTAPP/Contents/Frameworks/libairspy.dylib # NOT NEEDED????
sh macos/set_library_path.sh libairspy @rpath/libairspy.dylib $DOTAPP/Contents/Plugins/airspy_source.dylib
sh macos/set_library_path.sh libusb @rpath/libusb.dylib $DOTAPP/Contents/Frameworks/libairspy.dylib
install_name_tool -add_rpath @loader_path/../Frameworks $DOTAPP/Contents/Frameworks/libairspy.dylib
codesign --remove-signature $DOTAPP/Contents/Frameworks/libairspy.dylib
codesign -s - $DOTAPP/Contents/Frameworks/libairspy.dylib
install_module $BUILD_DIR/source_modules/airspyhf_source/airspyhf_source.dylib
LIBAIRSPYHF_PATH=$(sh macos/get_library_path.sh libairspyhf $BUILD_DIR/source_modules/airspyhf_source/airspyhf_source.dylib)
cp $LIBAIRSPYHF_PATH $DOTAPP/Contents/Frameworks/libairspyhf.dylib
sh macos/delete_rpath.sh /airspyhf/ $DOTAPP/Contents/Plugins/airspyhf_source.dylib
# sh macos/delete_rpath.sh libusb $DOTAPP/Contents/Frameworks/libairspyhf.dylib # NOT NEEDED????
sh macos/set_library_path.sh libairspy @rpath/libairspyhf.dylib $DOTAPP/Contents/Plugins/airspyhf_source.dylib
sh macos/set_library_path.sh libusb @rpath/libusb.dylib $DOTAPP/Contents/Frameworks/libairspyhf.dylib
install_name_tool -add_rpath @loader_path/../Frameworks $DOTAPP/Contents/Frameworks/libairspyhf.dylib
codesign --remove-signature $DOTAPP/Contents/Frameworks/libairspyhf.dylib
codesign -s - $DOTAPP/Contents/Frameworks/libairspyhf.dylib
install_module $BUILD_DIR/source_modules/bladerf_source/bladerf_source.dylib
LIBBLADERF_PATH=$(sh macos/get_library_path.sh libbladeRF $BUILD_DIR/source_modules/bladerf_source/bladerf_source.dylib)
cp $LIBBLADERF_PATH $DOTAPP/Contents/Frameworks/libbladeRF.dylib
sh macos/delete_rpath.sh libbladerf $DOTAPP/Contents/Plugins/bladerf_source.dylib
# sh macos/delete_rpath.sh libusb $DOTAPP/Contents/Frameworks/libbladeRF.dylib # NOT NEEDED????
sh macos/set_library_path.sh libbladeRF @rpath/libbladeRF.dylib $DOTAPP/Contents/Plugins/bladerf_source.dylib
sh macos/set_library_path.sh libusb @rpath/libusb.dylib $DOTAPP/Contents/Frameworks/libbladeRF.dylib
install_name_tool -add_rpath @loader_path/../Frameworks $DOTAPP/Contents/Frameworks/libbladeRF.dylib
codesign --remove-signature $DOTAPP/Contents/Frameworks/libbladeRF.dylib
codesign -s - $DOTAPP/Contents/Frameworks/libbladeRF.dylib
install_module $BUILD_DIR/source_modules/file_source/file_source.dylib
install_module $BUILD_DIR/source_modules/hackrf_source/hackrf_source.dylib
LIBHACKRF_PATH=$(sh macos/get_library_path.sh libhackrf $BUILD_DIR/source_modules/hackrf_source/hackrf_source.dylib)
cp $LIBHACKRF_PATH $DOTAPP/Contents/Frameworks/libhackrf.dylib
sh macos/delete_rpath.sh /hackrf/ $DOTAPP/Contents/Plugins/hackrf_source.dylib
# sh macos/delete_rpath.sh libusb $DOTAPP/Contents/Frameworks/libhackrf.dylib # NOT NEEDED????
sh macos/set_library_path.sh libhackrf @rpath/libhackrf.dylib $DOTAPP/Contents/Plugins/hackrf_source.dylib
sh macos/set_library_path.sh libusb @rpath/libusb.dylib $DOTAPP/Contents/Frameworks/libhackrf.dylib
install_name_tool -add_rpath @loader_path/../Frameworks $DOTAPP/Contents/Frameworks/libhackrf.dylib
codesign --remove-signature $DOTAPP/Contents/Frameworks/libhackrf.dylib
codesign -s - $DOTAPP/Contents/Frameworks/libhackrf.dylib
install_module $BUILD_DIR/source_modules/rtl_sdr_source/rtl_sdr_source.dylib
LIBRTLSDR_PATH=$(sh macos/get_library_path.sh librtlsdr $BUILD_DIR/source_modules/rtl_sdr_source/rtl_sdr_source.dylib)
cp $LIBRTLSDR_PATH $DOTAPP/Contents/Frameworks/librtlsdr.dylib
sh macos/delete_rpath.sh librtlsdr $DOTAPP/Contents/Plugins/rtl_sdr_source.dylib
# sh macos/delete_rpath.sh libusb $DOTAPP/Contents/Frameworks/librtlsdr.dylib # NOT NEEDED????
sh macos/set_library_path.sh librtlsdr @rpath/librtlsdr.dylib $DOTAPP/Contents/Plugins/rtl_sdr_source.dylib
sh macos/set_library_path.sh libusb @rpath/libusb.dylib $DOTAPP/Contents/Plugins/rtl_sdr_source.dylib # On intel needed too apparently
sh macos/set_library_path.sh libusb @rpath/libusb.dylib $DOTAPP/Contents/Frameworks/librtlsdr.dylib
install_name_tool -add_rpath @loader_path/../Frameworks $DOTAPP/Contents/Frameworks/librtlsdr.dylib
codesign --remove-signature $DOTAPP/Contents/Frameworks/librtlsdr.dylib
codesign -s - $DOTAPP/Contents/Frameworks/librtlsdr.dylib
install_module $BUILD_DIR/source_modules/rtl_tcp_source/rtl_tcp_source.dylib
install_module $BUILD_DIR/source_modules/sdrplay_source/sdrplay_source.dylib
install_module $BUILD_DIR/source_modules/spyserver_source/spyserver_source.dylib
# ========================= Sink Modules =========================
install_module $BUILD_DIR/sink_modules/network_sink/network_sink.dylib
install_module $BUILD_DIR/sink_modules/portaudio_sink/audio_sink.dylib
LIBPORTAUDIO_PATH=$(sh macos/get_library_path.sh libportaudio $BUILD_DIR/sink_modules/portaudio_sink/audio_sink.dylib)
cp $LIBPORTAUDIO_PATH $DOTAPP/Contents/Frameworks/libportaudio.dylib
sh macos/delete_rpath.sh /portaudio/ $DOTAPP/Contents/Plugins/audio_sink.dylib
sh macos/set_library_path.sh libportaudio @rpath/libportaudio.dylib $DOTAPP/Contents/Plugins/audio_sink.dylib
install_module $BUILD_DIR/sink_modules/new_portaudio_sink/new_portaudio_sink.dylib
sh macos/delete_rpath.sh /portaudio/ $DOTAPP/Contents/Plugins/new_portaudio_sink.dylib
sh macos/set_library_path.sh libportaudio @rpath/libportaudio.dylib $DOTAPP/Contents/Plugins/new_portaudio_sink.dylib
# ========================= Decoder Modules =========================
install_module $BUILD_DIR/decoder_modules/m17_decoder/m17_decoder.dylib
# TODO: Add codec2
install_module $BUILD_DIR/decoder_modules/meteor_demodulator/meteor_demodulator.dylib
install_module $BUILD_DIR/decoder_modules/radio/radio.dylib
# ========================= Misc Modules =========================
install_module $BUILD_DIR/misc_modules/discord_integration/discord_integration.dylib
install_module $BUILD_DIR/misc_modules/frequency_manager/frequency_manager.dylib
install_module $BUILD_DIR/misc_modules/recorder/recorder.dylib
install_module $BUILD_DIR/misc_modules/rigctl_server/rigctl_server.dylib
# ========================= Create PList =========================
echo '<?xml version="1.0" encoding="UTF-8"?>' >> $DOTAPP/Contents/Info.plist
echo '<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">' >> $DOTAPP/Contents/Info.plist
echo '' >> $DOTAPP/Contents/Info.plist
echo '<plist version="1.0">' >> $DOTAPP/Contents/Info.plist
echo ' <dict>' >> $DOTAPP/Contents/Info.plist
echo ' <key>CFBundleName</key><string>sdrpp</string>' >> $DOTAPP/Contents/Info.plist
echo ' <key>CFBundleDisplayName</key><string>SDR++</string>' >> $DOTAPP/Contents/Info.plist
echo ' <key>CFBundleIdentifier</key><string>org.sdrpp.sdrpp</string>' >> $DOTAPP/Contents/Info.plist
echo ' <key>CFBundleVersion</key><string>1.0.5</string>' >> $DOTAPP/Contents/Info.plist
echo ' <key>CFBundlePackageType</key><string>APPL</string>' >> $DOTAPP/Contents/Info.plist
echo ' <key>CFBundleSignature</key><string>sdrp</string>' >> $DOTAPP/Contents/Info.plist
echo ' <key>CFBundleExecutable</key><string>sdrpp</string>' >> $DOTAPP/Contents/Info.plist
echo ' <key>CFBundleIconFile</key><string>sdrpp</string>' >> $DOTAPP/Contents/Info.plist
echo ' </dict>' >> $DOTAPP/Contents/Info.plist
echo '</plist>' >> $DOTAPP/Contents/Info.plist

View File

@ -1,199 +0,0 @@
#!/bin/sh
set -e
# ========================= Prepare dotapp structure =========================
# Options
BUILD_DIR=$1
DOTAPP=$2
# Remove existing .app
rm -rf $DOTAPP
# Create .app structure
mkdir $DOTAPP
mkdir $DOTAPP/Contents
mkdir $DOTAPP/Contents/MacOS
mkdir $DOTAPP/Contents/Frameworks
mkdir $DOTAPP/Contents/Resources
mkdir $DOTAPP/Contents/Plugins
# ========================= Boilerplate =========================
# get_first_element [elem0] [elem1] [elem2] ...
get_first_element() {
echo $1
}
# get_second_element [elem0] [elem1] [elem2] ...
get_second_element() {
echo $2
}
# is_not_to_be_installed [dylib_name]
is_not_to_be_installed() {
if [ "$1" = "libsdrpp_core.dylib" ]; then echo 1; fi
if [ "$1" = "OpenGL" ]; then echo 1; fi
if [ "$1" = "libc++.1.dylib" ]; then echo 1; fi
if [ "$1" = "libSystem.B.dylib" ]; then echo 1; fi
if [ "$1" = "Cocoa" ]; then echo 1; fi
if [ "$1" = "IOKit" ]; then echo 1; fi
if [ "$1" = "CoreFoundation" ]; then echo 1; fi
if [ "$1" = "AppKit" ]; then echo 1; fi
if [ "$1" = "CoreGraphics" ]; then echo 1; fi
if [ "$1" = "CoreServices" ]; then echo 1; fi
if [ "$1" = "Foundation" ]; then echo 1; fi
if [ "$1" = "CoreAudio" ]; then echo 1; fi
if [ "$1" = "AudioToolbox" ]; then echo 1; fi
if [ "$1" = "AudioUnit" ]; then echo 1; fi
if [ "$1" = "libobjc.A.dylib" ]; then echo 1; fi
}
# get_exec_deps [exec_path]
get_exec_deps() {
DEPS_RAW=$(otool -L $1 | tail -n +2)
# Iterate over all lines
echo "$DEPS_RAW" | while read -r DEP; do
echo $(get_first_element $DEP)
done
}
# get_exec_rpaths [exec_path]
get_exec_rpaths() {
RPATHS_RAW=$(otool -l $1 | grep "path\ ")
# Iterate over all lines
echo "$RPATHS_RAW" | while read -r RPATH; do
echo $(get_second_element $RPATH)
done
}
# install_exec [exec_path] [install_path]
install_exec() {
local EXEC_NAME=$(basename $2)
local EXEC_DEST=$1/$EXEC_NAME
# Check if file exists
if [ ! -f $2 ]; then
echo "==NOT== Installing" $EXEC_NAME
return
fi
echo "Installing" $EXEC_NAME
# Copy it to its install location
cp $2 $EXEC_DEST
# Install dependencies and change path
local DEPS=$(get_exec_deps $EXEC_DEST)
echo "$DEPS" | while read -r DEP; do
local DEP_NAME=$(basename $DEP)
# Skip if this dep is blacklisted
local NOT_TO_BE_INSTALLED=$(is_not_to_be_installed $DEP_NAME)
if [ "$NOT_TO_BE_INSTALLED" = "1" ]; then
continue
fi
# Skip if this dep is itself
if [ "$DEP_NAME" = "$EXEC_NAME" ]; then
continue
fi
# If the dependency is not installed, install it
if [ ! -f $DOTAPP/Contents/Frameworks/$DEP_NAME ]; then
install_exec $DOTAPP/Contents/Frameworks $DEP
fi
# Fix path
install_name_tool -change $DEP @rpath/$DEP_NAME $EXEC_DEST
done
# Remove all its rpaths
local RPATHS=$(get_exec_rpaths $EXEC_DEST)
if [ "$RPATHS" != "" ]; then
echo "$RPATHS" | while read -r RPATH; do
install_name_tool -delete_rpath $RPATH $EXEC_DEST
done
fi
# Add new single rpath
install_name_tool -add_rpath @loader_path/../Frameworks $EXEC_DEST
}
# ========================= Install binaries =========================
# Core
install_exec $DOTAPP/Contents/MacOS $BUILD_DIR/sdrpp
install_exec $DOTAPP/Contents/Frameworks $BUILD_DIR/core/libsdrpp_core.dylib
# Source modules
install_exec $DOTAPP/Contents/Plugins $BUILD_DIR/source_modules/airspy_source/airspy_source.dylib
install_exec $DOTAPP/Contents/Plugins $BUILD_DIR/source_modules/airspyhf_source/airspyhf_source.dylib
install_exec $DOTAPP/Contents/Plugins $BUILD_DIR/source_modules/bladerf_source/bladerf_source.dylib
install_exec $DOTAPP/Contents/Plugins $BUILD_DIR/source_modules/file_source/file_source.dylib
install_exec $DOTAPP/Contents/Plugins $BUILD_DIR/source_modules/hackrf_source/hackrf_source.dylib
install_exec $DOTAPP/Contents/Plugins $BUILD_DIR/source_modules/limesdr_source/limesdr_source.dylib
install_exec $DOTAPP/Contents/Plugins $BUILD_DIR/source_modules/plutosdr_source/plutosdr_source.dylib
install_exec $DOTAPP/Contents/Plugins $BUILD_DIR/source_modules/rtl_sdr_source/rtl_sdr_source.dylib
install_exec $DOTAPP/Contents/Plugins $BUILD_DIR/source_modules/rtl_tcp_source/rtl_tcp_source.dylib
install_exec $DOTAPP/Contents/Plugins $BUILD_DIR/source_modules/sdrplay_source/sdrplay_source.dylib
install_exec $DOTAPP/Contents/Plugins $BUILD_DIR/source_modules/soapy_source/soapy_source.dylib
install_exec $DOTAPP/Contents/Plugins $BUILD_DIR/source_modules/spyserver_source/spyserver_source.dylib
# Sink modules
install_exec $DOTAPP/Contents/Plugins $BUILD_DIR/sink_modules/portaudio_sink/audio_sink.dylib
install_exec $DOTAPP/Contents/Plugins $BUILD_DIR/sink_modules/network_sink/network_sink.dylib
install_exec $DOTAPP/Contents/Plugins $BUILD_DIR/sink_modules/new_portaudio_sink/new_portaudio_sink.dylib
# Decoder modules
install_exec $DOTAPP/Contents/Plugins $BUILD_DIR/decoder_modules/m17_decoder/m17_decoder.dylib
install_exec $DOTAPP/Contents/Plugins $BUILD_DIR/decoder_modules/meteor_demodulator/meteor_demodulator.dylib
install_exec $DOTAPP/Contents/Plugins $BUILD_DIR/decoder_modules/radio/radio.dylib
install_exec $DOTAPP/Contents/Plugins $BUILD_DIR/misc_modules/discord_integration/discord_integration.dylib
install_exec $DOTAPP/Contents/Plugins $BUILD_DIR/misc_modules/frequency_manager/frequency_manager.dylib
install_exec $DOTAPP/Contents/Plugins $BUILD_DIR/misc_modules/recorder/recorder.dylib
install_exec $DOTAPP/Contents/Plugins $BUILD_DIR/misc_modules/rigctl_server/rigctl_server.dylib
# ========================= Install resources =========================
# Copy resource folder
cp -R root/res/* $DOTAPP/Contents/Resources/
# Generate icon
mkdir $DOTAPP/Contents/Resources/sdrpp.iconset
sips -z 16 16 root/res/icons/sdrpp.png --out $DOTAPP/Contents/Resources/sdrpp.iconset/icon_16x16.png
sips -z 32 32 root/res/icons/sdrpp.png --out $DOTAPP/Contents/Resources/sdrpp.iconset/icon_16x16@2x.png
sips -z 32 32 root/res/icons/sdrpp.png --out $DOTAPP/Contents/Resources/sdrpp.iconset/icon_32x32.png
sips -z 64 64 root/res/icons/sdrpp.png --out $DOTAPP/Contents/Resources/sdrpp.iconset/icon_32x32@2x.png
sips -z 128 128 root/res/icons/sdrpp.png --out $DOTAPP/Contents/Resources/sdrpp.iconset/icon_128x128.png
sips -z 256 256 root/res/icons/sdrpp.png --out $DOTAPP/Contents/Resources/sdrpp.iconset/icon_128x128@2x.png
sips -z 256 256 root/res/icons/sdrpp.png --out $DOTAPP/Contents/Resources/sdrpp.iconset/icon_256x256.png
sips -z 512 512 root/res/icons/sdrpp.png --out $DOTAPP/Contents/Resources/sdrpp.iconset/icon_256x256@2x.png
sips -z 512 512 root/res/icons/sdrpp.png --out $DOTAPP/Contents/Resources/sdrpp.iconset/icon_512x512.png
iconutil -c icns $DOTAPP/Contents/Resources/sdrpp.iconset
rm -R $DOTAPP/Contents/Resources/sdrpp.iconset
# ========================= Generate the plist =========================
echo '<?xml version="1.0" encoding="UTF-8"?>' >> $DOTAPP/Contents/Info.plist
echo '<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">' >> $DOTAPP/Contents/Info.plist
echo '' >> $DOTAPP/Contents/Info.plist
echo '<plist version="1.0">' >> $DOTAPP/Contents/Info.plist
echo ' <dict>' >> $DOTAPP/Contents/Info.plist
echo ' <key>CFBundleName</key><string>sdrpp</string>' >> $DOTAPP/Contents/Info.plist
echo ' <key>CFBundleDisplayName</key><string>SDR++</string>' >> $DOTAPP/Contents/Info.plist
echo ' <key>CFBundleIdentifier</key><string>org.sdrpp.sdrpp</string>' >> $DOTAPP/Contents/Info.plist
echo ' <key>CFBundleVersion</key><string>1.0.5</string>' >> $DOTAPP/Contents/Info.plist
echo ' <key>CFBundlePackageType</key><string>APPL</string>' >> $DOTAPP/Contents/Info.plist
echo ' <key>CFBundleSignature</key><string>sdrp</string>' >> $DOTAPP/Contents/Info.plist
echo ' <key>CFBundleExecutable</key><string>sdrpp</string>' >> $DOTAPP/Contents/Info.plist
echo ' <key>CFBundleIconFile</key><string>sdrpp</string>' >> $DOTAPP/Contents/Info.plist
echo ' </dict>' >> $DOTAPP/Contents/Info.plist
echo '</plist>' >> $DOTAPP/Contents/Info.plist
# ========================= Sign the dotapp =========================
codesign --force --deep -s - $DOTAPP