Skip to content

Commit

Permalink
chore(cpn): Resolve Win32 Companion build issue (EdgeTX#4309)
Browse files Browse the repository at this point in the history
  • Loading branch information
pfeerick authored and MRC3742 committed Dec 22, 2023
1 parent f22acbd commit aae62d7
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// https://github.com/microsoft/vscode-dev-containers/tree/v0.187.0/containers/cpp
{
"name": "edgetx-dev",
"image": "ghcr.io/edgetx/edgetx-dev:2.9.0",
"image": "ghcr.io/edgetx/edgetx-dev:2.9.1",

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
Expand Down
13 changes: 10 additions & 3 deletions .github/workflows/win-cpn-32.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,22 @@ name: Windows Companion 32-bit
on:
push:
branches:
- 'main'
- '2.9'
tags:
- v*
paths:
- '.github/workflows/win_cpn-32.yml'
- 'companion/**'
- 'tools/build-companion.sh'

pull_request:
branches:
- '2.9'
paths:
- '.github/workflows/win_cpn-32.yml'
- 'companion/**'
- 'tools/build-companion.sh'

workflow_dispatch:

env:
Expand Down Expand Up @@ -56,6 +64,7 @@ jobs:
mingw-w64-i686-libraqm \
mingw-w64-i686-SDL2 \
mingw-w64-i686-clang \
mingw-w64-i686-openssl \
mingw-w64-i686-nsis
python -m pip install clang
Expand All @@ -66,7 +75,6 @@ jobs:
cache-key-prefix: 'install-qt-action-win32'
version: ${{ env.QT_VERSION }}
arch: ${{ env.MINGW_VERSION }}
tools: 'tools_openssl_x86'

- name: Check out the repo
uses: actions/checkout@v3
Expand All @@ -79,7 +87,6 @@ jobs:
run: |
mkdir output && \
CMAKE_PREFIX_PATH=$RUNNER_WORKSPACE/Qt/$QT_VERSION/$MINGW_PATH \
QT_TOOLS_OPENSSL_ROOT_PATH=$RUNNER_WORKSPACE/Qt/Tools/OpenSSL/Win_x86 \
tools/build-companion.sh "$(pwd)" "$(pwd)/output/"
- name: Compose release filename
# https://stackoverflow.com/questions/58033366/how-to-get-current-branch-within-github-actions
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ if(NATIVE_BUILD)
include(NativeTargets)
else()
# Prevent CMake warnings
set(IGNORE "${SDL2_LIBRARY_PATH}")
set(IGNORE "${SDL2_LIBRARY_PATH}" "${LIBSSL1_ROOT_DIR}" "${OPENSSL_ROOT_DIR}")
endif()

add_subdirectory(${RADIO_SRC_DIR})
27 changes: 27 additions & 0 deletions cmake/FindLibssl1.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# - try to find libssl-1 library

if (DEFINED ENV{LIBSSL1_ROOT_DIR})
set(LIBSSL1_ROOT_DIR "$ENV{LIBSSL1_ROOT_DIR}")
endif()

find_library(LIBSSL1_LIBRARY
NAMES
libssl.so.1.1
libssl-1_1.dll
libssl-1_1.dylib
HINTS
"${LIBSSL1_ROOT_DIR}")

get_filename_component(LIBSSL1_LIBRARY_PATH ${LIBSSL1_LIBRARY} PATH)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LIBSSL1
DEFAULT_MSG
LIBSSL1_LIBRARY_PATH)

if(LIBSSL1_FOUND)
set(LIBSSL1_LIBRARY_DIR "${LIBSSL1_LIBRARY_PATH}")
mark_as_advanced(LIBSSL1_ROOT_DIR)
endif()

mark_as_advanced(LIBSSL1_LIBRARY_PATH)
14 changes: 14 additions & 0 deletions cmake/NativeTargets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,20 @@ if(Qt5Core_FOUND OR FOX_FOUND)
endif()
endif()

if(Qt5Core_FOUND AND NOT DISABLE_COMPANION)
if(LINUX)
find_package(Libssl1)
endif()

# OpenSSL
# environment variable set in github workflows and build-edgetx Dockerfile
if (DEFINED ENV{OPENSSL_ROOT_DIR})
set(OPENSSL_ROOT_DIR "$ENV{OPENSSL_ROOT_DIR}")
endif()

find_package(OpenSSL)
endif()

# Windows-specific includes and libs shared by sub-projects
if(WIN32)
list(APPEND WIN_INCLUDE_DIRS "${RADIO_SRC_DIR}/thirdparty/windows/dirent")
Expand Down
34 changes: 26 additions & 8 deletions companion/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -354,14 +354,7 @@ if(POLICY CMP0026)
endif()

# OpenSSL
# environment variable set in github workflows and build-edgetx Dockerfile
if (DEFINED ENV{QT_TOOLS_OPENSSL_ROOT_PATH})
set(OPENSSL_ROOT_DIR "$ENV{QT_TOOLS_OPENSSL_ROOT_PATH}")
else()
message(STATUS "Environment variable QT_TOOLS_OPENSSL_ROOT_PATH not defined. Performing default OpenSSL library search.")
endif()

find_package(OpenSSL)
include(FindOpenSSL)

if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
message(STATUS "install " ${CMAKE_BINARY_DIR} " to " ${CMAKE_INSTALL_PREFIX}/bin)
Expand Down Expand Up @@ -410,6 +403,31 @@ elseif(WIN32)
install(FILES "${COMPANION_SRC_DIRECTORY}/../targets/windows/${tmpfile}" DESTINATION ${INSTALL_DESTINATION})
endforeach()

if(OPENSSL_FOUND)
if ((OPENSSL_VERSION VERSION_LESS "1.2.0" AND Qt5Core_VERSION VERSION_LESS "6.0.0") OR (OPENSSL_VERSION VERSION_GREATER "3.0.0" AND Qt5Core_VERSION VERSION_GREATER_EQUAL "6.0.0"))
get_filename_component(OPENSSL_SSL_LIBRARY_DIR ${OPENSSL_SSL_LIBRARY} DIRECTORY)
if(MINGW)
# the dlls are stored in the bin directory
set(OPENSSL_SSL_LIBRARY_DIR "${OPENSSL_SSL_LIBRARY_DIR}/../bin")
endif()
if(EXISTS "${OPENSSL_SSL_LIBRARY_DIR}")
# install only files Qt networking requires
install(DIRECTORY ${OPENSSL_SSL_LIBRARY_DIR}/ DESTINATION ${INSTALL_DESTINATION} FILES_MATCHING PATTERN "libcrypto-*.dll" PATTERN "libssl-*.dll")
endif()
endif()
endif()

if(NOT OPENSSL_FOUND OR Qt5Core_VERSION VERSION_LESS "6.0.0")
if(MINGW AND $ENV{MSYSTEM} STREQUAL "MINGW32")
install(FILES "${COMPANION_SRC_DIRECTORY}/../targets/windows/libcrypto-1_1.dll" DESTINATION ${INSTALL_DESTINATION})
install(FILES "${COMPANION_SRC_DIRECTORY}/../targets/windows/libssl-1_1.dll" DESTINATION ${INSTALL_DESTINATION})
else()
# MINGW64 or assume 64 bit native
install(FILES "${COMPANION_SRC_DIRECTORY}/../targets/windows/libcrypto-1_1-x64.dll" DESTINATION ${INSTALL_DESTINATION})
install(FILES "${COMPANION_SRC_DIRECTORY}/../targets/windows/libssl-1_1-x64.dll" DESTINATION ${INSTALL_DESTINATION})
endif()
endif()

# Qt dlls (using windeployqt)
## Qt translations are already packaged into our custom qrc. Also don't need software rendering engines.
set(wdqtopts --no-translations --no-opengl-sw --no-system-d3d-compiler --no-angle)
Expand Down
6 changes: 4 additions & 2 deletions companion/targets/windows/companion.nsi.in
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,10 @@ Section "un.EdgeTX Companion @VERSION_FAMILY@"
Delete "$INSTDIR\libusb0.dll"
Delete "$INSTDIR\libusb-1.0.dll"
; OpenSSL libs
Delete "$INSTDIR\libeay32.dll"
Delete "$INSTDIR\ssleay32.dll"
Delete "$INSTDIR\libssl-1_1.dll"
Delete "$INSTDIR\libssl-1_1-x64.dll"
Delete "$INSTDIR\libcrypto-1_1.dll"
Delete "$INSTDIR\libcrypto-1_1-x64.dll"
; MinGW libs
Delete "$INSTDIR\libgcc_s_dw2-1.dll"
Delete "$INSTDIR\libgcc_s_seh-1.dll"
Expand Down
Binary file added companion/targets/windows/libcrypto-1_1-x64.dll
Binary file not shown.
Binary file added companion/targets/windows/libcrypto-1_1.dll
Binary file not shown.
Binary file added companion/targets/windows/libssl-1_1-x64.dll
Binary file not shown.
Binary file added companion/targets/windows/libssl-1_1.dll
Binary file not shown.

0 comments on commit aae62d7

Please sign in to comment.