From 48880cb18dded1d95d52aec5bae55ff31dcf2ad5 Mon Sep 17 00:00:00 2001 From: cbdev Date: Wed, 30 Jun 2021 19:41:13 +0200 Subject: Add OSX CI target, fix OSX build --- assets/ci.sh | 127 +++++++++++++++++++++++++++++++++--------------------- backends/Makefile | 5 ++- backends/artnet.c | 2 +- backends/sacn.c | 2 +- backends/visca.c | 16 +++++-- midimonster.h | 2 +- 6 files changed, 97 insertions(+), 57 deletions(-) diff --git a/assets/ci.sh b/assets/ci.sh index 94b8bed..f31f385 100755 --- a/assets/ci.sh +++ b/assets/ci.sh @@ -3,20 +3,28 @@ ################################################ SETUP ################################################ dep_build_core=( - libasound2-dev - libevdev-dev - liblua5.3-dev - libola-dev - libjack-jackd2-dev - python3-dev - libssl-dev + libasound2-dev + libevdev-dev + liblua5.3-dev + libola-dev + libjack-jackd2-dev + python3-dev + libssl-dev build-essential pkg-config git ) +dep_build_osx=( + ola + lua + openssl@1.1 + jack + python3 +) + dep_build_win=( - mingw-w64 + mingw-w64 ) dep_build_debian=( @@ -68,29 +76,29 @@ print_help() { printf "Valid dependency install targets are: \t\"deps-linux\", \"deps-windows\", \"deps-debian\", \"deps-osx\" \"deps-tests\", \"deps-all\".\n\n" } -install_dependencies(){ - start_apt update -y -qq > /dev/null || error_handler "There was an error doing apt update." +deps_apt(){ + start_apt update -y -qq > /dev/null || error_handler "There was an error doing apt update." for dependency in "$@"; do if [ "$(dpkg-query -W -f='${Status}' "$dependency" 2>/dev/null | grep -c "ok installed")" -eq 0 ]; then - deps+=("$dependency") # Add not installed dependency to the "to be installed array". + deps+=("$dependency") # Add not installed dependency to the "to be installed array". else [[ -n $verbose ]] && printf "%s already installed!\n" "$dependency" # If the dependency is already installed print it. fi done -if [ ! "${#deps[@]}" -ge "1" ]; then # If nothing needs to get installed don't start apt. - [[ -n $verbose ]] && echo "All dependencies are fulfilled." # Dependency array empty! Not running apt! -else - [[ -z $verbose ]] && echo "Starting dependency installation." - [[ -n $verbose ]] && echo "Then following dependencies are going to be installed:" # Dependency array contains items. Running apt. - [[ -n $verbose ]] && echo "${deps[@]}" | sed 's/ /, /g' - start_apt install -y -qq --no-install-suggests --no-install-recommends "${deps[@]}" > /dev/null || error_handler "There was an error doing dependency installation!" -fi + if [ ! "${#deps[@]}" -ge "1" ]; then # If nothing needs to get installed don't start apt. + [[ -n $verbose ]] && echo "All dependencies are fulfilled." # Dependency array empty! Not running apt! + else + [[ -z $verbose ]] && echo "Starting dependency installation." + [[ -n $verbose ]] && echo "Then following dependencies are going to be installed:" # Dependency array contains items. Running apt. + [[ -n $verbose ]] && echo "${deps[@]}" | sed 's/ /, /g' + start_apt install -y -qq --no-install-suggests --no-install-recommends "${deps[@]}" > /dev/null || error_handler "There was an error doing dependency installation!" + fi [[ -n $verbose ]] && printf "\n" } start_apt(){ - i="0" + i="0" if command -v fuser &> /dev/null; then while fuser /var/lib/dpkg/lock >/dev/null 2>&1 ; do [ "$i" -eq "0" ] && printf "\nWaiting for other software managers to finish" @@ -103,13 +111,45 @@ start_apt(){ DEBIAN_FRONTEND=noninteractive apt-get "$@" } +deps_brew(){ + # 'brew install' sometimes returns non-zero for some arcane reason. + for dependency in "$@"; do + brew install "$dependency" + done + brew link --overwrite python +} + # Build targets and corresponding deployment. build-linux(){ - [[ -n $install_deps ]] && install_dependencies "${dep_build_core[@]}" + [[ -n $install_deps ]] && deps_apt "${dep_build_core[@]}" make full } +build-osx(){ + # OpenSSL is not a proper install due to some Apple bull, so provide additional locations via the environment... + # Additionally, newer versions of this "recipe" seem to use the name 'openssl@1.1' instead of plain 'openssl' and there seems to be + # no way to programmatically get the link and include paths. Genius! Hardcoding the new version for the time being... + export CFLAGS="$CFLAGS -I/usr/local/opt/openssl@1.1/include" + export LDFLAGS="$LDFLAGS -L/usr/local/opt/openssl@1.1/lib" + make full +} + +build-windows(){ + [[ -n $install_deps ]] && deps_apt "${dep_build_core[@]}" "${dep_build_win[@]}" + # Download libraries to link with for Windows + wget "https://downloads.sourceforge.net/project/luabinaries/5.3.5/Windows%20Libraries/Dynamic/lua-5.3.5_Win64_dllw6_lib.zip" -O lua53.zip + unzip lua53.zip lua53.dll + make windows + make -C backends lua.dll +} + +build-debian(){ + [[ -n $install_deps ]] && deps_apt "${dep_build_core[@]}" "${dep_build_debian[@]}" + git checkout debian/master + gbp buildpackage +} + build-linux-deploy(){ #printf "\nLinux Deployment started..\n" mkdir -p ./deployment/linux/backends @@ -125,11 +165,6 @@ build-linux-deploy(){ find . ! -iname "*.zip" ! -iname "*.tgz" -delete } -build-windows(){ - [[ -n $install_deps ]] && install_dependencies "${dep_build_core[@]}" "${dep_build_win[@]}" - make windows -} - build-windows-deploy(){ #printf "\nWindows Deployment started..\n" mkdir -p ./deployment/windows/backends @@ -146,12 +181,6 @@ build-windows-deploy(){ find . ! -iname "*.zip" ! -iname "*.tgz" -delete } -build-debian(){ - [[ -n $install_deps ]] && install_dependencies "${dep_build_core[@]}" "${dep_build_debian[@]}" - git checkout debian/master - gbp buildpackage -} - build-debian-deploy(){ #printf "\nDebian Package Deployment started..\n" mkdir -p ./deployment/debian/ @@ -161,7 +190,7 @@ build-debian-deploy(){ # Tests ckeck-spelling(){ # Check spelling. - [[ -n $install_deps ]] && install_dependencies "lintian" + [[ -n $install_deps ]] && deps_apt "lintian" spellcheck_files=$(find . -type f | grep -v ".git/") # Create list of files to be spellchecked. sl_results=$(xargs spellintian 2>&1 <<< "$spellcheck_files") # Run spellintian to find spelling errors sl_errors=$(wc -l <<< "$sl_results") @@ -178,7 +207,7 @@ ckeck-spelling(){ # Check spelling. } check-codespelling(){ # Check code for common misspellings. - [[ -n $install_deps ]] && install_dependencies "codespell" + [[ -n $install_deps ]] && deps_apt "codespell" spellcheck_files=$(find . -type f | grep -v ".git/") # Create list of files to be spellchecked. cs_results=$(xargs codespell --quiet 2 <<< "$spellcheck_files" 2>&1) cs_errors=$(wc -l <<< "$cs_results") @@ -192,7 +221,7 @@ check-codespelling(){ # Check code for common misspellings. } analyze-complexity(){ # code complexity analyser. - [[ -n $install_deps ]] && install_dependencies "python3" "python3-pip" + [[ -n $install_deps ]] && deps_apt "python3" "python3-pip" if [ -z "$(which ~/.local/bin/lizard)" ]; then printf "Installing lizard...\n" pip3 install lizard >/dev/null @@ -205,7 +234,7 @@ analyze-complexity(){ # code complexity analyser. } analyze-shellscript(){ # Shellscript analysis tool. - [[ -n $install_deps ]] && install_dependencies "shellcheck" + [[ -n $install_deps ]] && deps_apt "shellcheck" printf "Running shellcheck:\n" shell_files="$(find . -type f -iname \*.sh)" xargs shellcheck -Cnever -s bash <<< "$shell_files" @@ -215,7 +244,7 @@ analyze-shellscript(){ # Shellscript analysis tool. } stats(){ # Code statistics. - [[ -n $install_deps ]] && install_dependencies "cloc" + [[ -n $install_deps ]] && deps_apt "cloc" printf "Code statistics:\n" cloc ./ } @@ -243,40 +272,40 @@ target_queue(){ build-linux|10) OS="linux" build-linux - [[ -n $deploy ]] && build-linux-deploy # Deploy build artifacts if the deploy flag is set. + [[ -n $deploy ]] && build-linux-deploy ;; build-windows|build-win|11) build-windows - [[ -n $deploy ]] && build-windows-deploy # Deploy build artifacts if the deploy flag is set. + [[ -n $deploy ]] && build-windows-deploy ;; build-debian|build-deb|12) build-debian - [[ -n $deploy ]] && build-debian-deploy # Deploy build artifacts if the deploy flag is set. + [[ -n $deploy ]] && build-debian-deploy ;; build-osx|13) OS="osx" - printf "\nNot implemented yet!\n" - #build-linux - #[[ -n $deploy ]] && build-linux-deploy # Deploy build artifacts if the deploy flag is set. + build-osx + [[ -n $deploy ]] && build-linux-deploy ;; deps-linux) # Target to install all needed dependencies for linux builds. - install_dependencies "${dep_build_core[@]}" + deps_apt "${dep_build_core[@]}" ;; deps-windows|deps-win) # Target to install all needed dependencies for windows builds. - install_dependencies "${dep_build_core[@]}" "${dep_build_win[@]}" + deps_apt "${dep_build_core[@]}" "${dep_build_win[@]}" ;; deps-debian|deps-deb) # Target to install all needed dependencies for debian packaging. - install_dependencies "${dep_build_core[@]}" "${dep_build_debian[@]}" + deps_apt "${dep_build_core[@]}" "${dep_build_debian[@]}" ;; deps-osx) # Target to install all needed dependencies for osx. printf "\nNot implemented yet!\n" + deps_brew "${dep_build_osx[@]}" ;; deps-tests) - install_dependencies "lintian" "codespell" "python3" "python3-pip" "shellcheck" "cloc" + deps_apt "lintian" "codespell" "python3" "python3-pip" "shellcheck" "cloc" # Install lizard if not found. if [ -z "$(which ~/.local/bin/lizard)" ]; then pip3 install lizard >/dev/null @@ -284,7 +313,7 @@ target_queue(){ ;; deps-all) # Target to install all needed dependencies for this ci script. - install_dependencies "${dep_build_core[@]}" "${dep_build_win[@]}" "${dep_build_debian[@]}" "lintian" "codespell" "python3" "python3-pip" "shellcheck" "cloc" + deps_apt "${dep_build_core[@]}" "${dep_build_win[@]}" "${dep_build_debian[@]}" "lintian" "codespell" "python3" "python3-pip" "shellcheck" "cloc" ;; *) printf "Target '%s' not valid!\n" "$i" @@ -310,4 +339,4 @@ target_queue # Start requestet targets. # Allow failure handler. [[ -z $allow_failure ]] && exit "$exitcode" -exit "0" \ No newline at end of file +exit "0" diff --git a/backends/Makefile b/backends/Makefile index be870d6..35782ab 100644 --- a/backends/Makefile +++ b/backends/Makefile @@ -60,7 +60,10 @@ openpixelcontrol.dll: ADDITIONAL_OBJS += $(BACKEND_LIB) openpixelcontrol.dll: LDLIBS += -lws2_32 maweb.so: ADDITIONAL_OBJS += $(BACKEND_LIB) -maweb.so: LDLIBS = $(shell pkg-config --libs openssl || echo "-DBUILD_ERROR=\"Missing pkg-config data for openssl\"") +# On OSX, the system provides libressl but no pkg-config data. +# Brew provides OpenSSL v1.1, but with a mangled path and no clear way to find it +# Give up and just default to -lcrypto for the time being... +maweb.so: LDLIBS = $(shell pkg-config --libs openssl || echo "-lcrypto") maweb.dll: ADDITIONAL_OBJS += $(BACKEND_LIB) maweb.dll: LDLIBS += -lws2_32 maweb.dll: CFLAGS += -DMAWEB_NO_LIBSSL diff --git a/backends/artnet.c b/backends/artnet.c index dae9ba3..7c5f7e0 100644 --- a/backends/artnet.c +++ b/backends/artnet.c @@ -429,7 +429,7 @@ static int artnet_handle(size_t num, managed_fd* fds){ LOG("Failed to process frame"); } else if(!inst && global_cfg.detect > 1){ - LOGPF("Received data for unconfigured universe %d (net %d) on descriptor %" PRIsize_t, frame->universe, frame->net, (((uint64_t) fds[u].impl) & 0xFF)); + LOGPF("Received data for unconfigured universe %d (net %d) on descriptor %" PRIu64, frame->universe, frame->net, (((uint64_t) fds[u].impl) & 0xFF)); } } } diff --git a/backends/sacn.c b/backends/sacn.c index e395ae2..5c5b81d 100644 --- a/backends/sacn.c +++ b/backends/sacn.c @@ -613,7 +613,7 @@ static int sacn_handle(size_t num, managed_fd* fds){ } else if(!inst && global_cfg.detect > 1){ //this will only happen with unicast input - LOGPF("Received data for unconfigured universe %d on descriptor %" PRIsize_t, be16toh(data->universe), ((uint64_t) fds[u].impl) & 0xFFFF); + LOGPF("Received data for unconfigured universe %d on descriptor %" PRIu64, be16toh(data->universe), ((uint64_t) fds[u].impl) & 0xFFFF); } } } diff --git a/backends/visca.c b/backends/visca.c index a36b139..6ae14d9 100644 --- a/backends/visca.c +++ b/backends/visca.c @@ -4,9 +4,12 @@ #include #include -#ifndef _WIN32 +#ifdef __linux__ #include #include +#elif __APPLE__ + #include + #include #endif #include "visca.h" @@ -89,9 +92,6 @@ static int ptz_configure_instance(instance* inst, char* option, char* value){ LOG("Direct device connections are not possible on Windows"); return 1; #else - - struct termios2 device_config; - options = strchr(value, ' '); if(options){ //terminate port name @@ -108,6 +108,8 @@ static int ptz_configure_instance(instance* inst, char* option, char* value){ //configure baudrate if(options){ + #ifdef __linux__ + struct termios2 device_config; //get current port config if(ioctl(data->fd, TCGETS2, &device_config)){ LOGPF("Failed to get port configuration data for %s: %s", value, strerror(errno)); @@ -123,6 +125,12 @@ static int ptz_configure_instance(instance* inst, char* option, char* value){ if(ioctl(data->fd, TCSETS2, &device_config)){ LOGPF("Failed to set port configuration data for %s: %s", value, strerror(errno)); } + #elif __APPLE__ + speed_t speed = strtoul(options, NULL, 10); + if(ioctl(data->fd, IOSSIOSPEED, &speed)){ + LOGPF("Failed to set port configuration data for %s: %s", value, strerror(errno)); + } + #endif } return 0; #endif diff --git a/midimonster.h b/midimonster.h index 89688c4..64aa1e5 100644 --- a/midimonster.h +++ b/midimonster.h @@ -7,7 +7,7 @@ /* Core version unless set by the build process */ #ifndef MIDIMONSTER_VERSION - #define MIDIMONSTER_VERSION "v0.6-dist" + #define MIDIMONSTER_VERSION "v0.7-dist" #endif /* Set backend name if unset */ -- cgit v1.2.3