From a293d441d7d93fa10b900301351baa254e2c2a7f Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 28 Aug 2023 14:48:06 +0300 Subject: [PATCH] Explicitly link to libcrypto and libssl to avoid error: Failed to load libssl/libcrypto. --- .cirrus.yml | 7 +- appveyor.yml | 115 ++++++++++++++++++++++++++++++-- scripts/treestate.py | 93 ++++++++++++++++++++++++++ src/app/puzzle/puzzle.qbs | 14 ++++ src/app/tape/tape.qbs | 13 ++++ src/app/valentina/valentina.qbs | 13 ++++ 6 files changed, 245 insertions(+), 10 deletions(-) create mode 100644 scripts/treestate.py diff --git a/.cirrus.yml b/.cirrus.yml index 551e70fac..fb2d1c4c2 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -167,7 +167,6 @@ macos_task_template: &MACOS_TASK_TEMPLATE PIP_CACHE_DIR: ${HOME}/.cache/pip LDFLAGS: "-L$QTDIR/lib" CPPFLAGS: "-I$QTDIR/include" - PKG_CONFIG_PATH: "/opt/homebrew/opt/qt6/lib/pkgconfig" local_homebrew_cache: folder: "$HOME/Library/Caches/Homebrew" global_conan_cache: @@ -182,12 +181,14 @@ macos_task_template: &MACOS_TASK_TEMPLATE - sudo xcode-select -p - brew update > /dev/null - brew outdated - - brew install --force qt6 coreutils ccache qbs cmake git - - brew upgrade qt6 coreutils ccache qbs cmake git + - brew install --force qt6 coreutils ccache qbs cmake git openssl@1.1 + - brew upgrade qt6 coreutils ccache qbs cmake git openssl@1.1 - echo $PATH - export PATH="${HOME}/.local/bin:`python3 -m site --user-base`/bin:$PATH" - echo $PATH - chmod -R 755 /opt/homebrew/opt/qt6/* + - chmod -R 755 /opt/homebrew/opt/openssl@1.1/* + - export PKG_CONFIG_PATH="$(brew --prefix qt6)/lib/pkgconfig:$(brew --prefix openssl@1.1)/lib/pkgconfig" - python3 --version - pip3 install --user --upgrade pip dropbox conan==1.60 - ccache --set-config=sloppiness=pch_defines,time_macros diff --git a/appveyor.yml b/appveyor.yml index 25360eb07..2ce2f8c45 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -581,6 +581,107 @@ for: only: - job_name: MacOS_12_Qt_6_4 (multibundle) - job_name: MacOS_12_Qt_6_4 (singlebundle) + + environment: + CONAN_USER_HOME: /Users/appveyor/.conan + HOMEBREW_NO_INSTALL_CLEANUP: 1 + + cache: + - /Users/appveyor/.conan/data -> conan-cache + - /Users/appveyor/cache_dir + + init: + - find /Applications -maxdepth 1 -type d -name 'Xcode*.app' + - sudo xcode-select -p + - sudo xcode-select -s /Applications/Xcode-$XCODE_VERSION.app + - sudo xcode-select -p + + before_build: + - ls ${HOME}/Qt + - export QTDIR="${HOME}/${QT}" + - export PATH="$QTDIR/bin:$HOME/.local/bin:`python3 -m site --user-base`/bin:${HOME}/Qt/Qt Creator.app/Contents/MacOS:$PATH" + - echo $PATH + - python3 --version + - |- + + ############################################################### + # Set up macOS dependencies + + sudo ln -s /usr/local /opt/local; + + cache_tag=usr_local_1 # this can be modified to rebuild deps + + cdir=$HOME/cache_dir + cache_tar=$cdir/$cache_tag.tar + cache=$cache_tar.xz + + CPUS=$(sysctl -n hw.ncpu) + + if [ -d $cdir ] && [ -f $cache ]; then + echo "=== Unpacking cached Homebrew $cache ===" + ( + cd / + tar xf $cache + ) + echo "done" + else + echo "=== Building dependencies ===" + echo "Couldn't find cache $cache" + ls -alrt "$cdir" + + echo "Recording /usr/local state" + python3 ./scripts/treestate.py scan /usr/local usrlocal.json + + brew update + brew install coreutils ccache git openssl@1.1 + + # The build environment is now ready for use. We can complete + # the rest of the process of creating the Homebrew archive + # during the rest of the build, using idle CPU time. To minimise + # the amount of space needed for the archive, we compress with + # xz, which adds only about a minute to the non-cached build. + ( + echo "=== Creating cache tarball $cache ===" + echo "Check /usr/local for updates" + python3 ./scripts/treestate.py updates usrlocal.json /usr/local | fgrep -v .git > updated_list + echo Need to record $( wc -l updated_list ) updates + + mkdir -p $cdir + rm -f $cdir/* + nice tar cf $cache_tar -T updated_list + echo nice xz -9 -T$CPUS $cache_tar + nice xz -9 -T$CPUS $cache_tar + du -h $cdir + ) 2>&1 | sed 's/^/CACHE: /' & + + fi + + export PKG_CONFIG_PATH="$(brew --prefix openssl@1.1)/lib/pkgconfig"; + - sudo python3 -m pip install --upgrade pip + - pip3 install --user --upgrade pip dropbox conan==1.60 + - conan --version + - clang --version + - qmake --version + - which qmake + - qbs --version + - cd ${APPVEYOR_BUILD_FOLDER} + + build_script: + - pwd + - conan install . -s os=Macos -s os.version=${MACOS_DEPLOYMENT_TARGET} --build=missing + - qbs setup-toolchains --detect + - qbs config --list profiles + - qbs setup-qt ${QTDIR}/bin/qmake qt6 + - qbs config defaultProfile qt6 + - qbs config profiles.qt6.baseProfile clang + - qbs build -f valentina.qbs -d ${APPVEYOR_BUILD_FOLDER}/build --jobs $(nproc) config:release modules.buildconfig.enableUnitTests:false modules.buildconfig.enableMultiBundle:${MULTI_BUNDLE} qbs.installRoot:${APPVEYOR_BUILD_FOLDER}/build/install-root profile:qt6 project.enableConan:true project.minimumMacosVersion:${MACOS_DEPLOYMENT_TARGET} modules.buildconfig.enableCcache:false + + deploy_script: + - CIRRUS_WORKING_DIR=${APPVEYOR_BUILD_FOLDER} CIRRUS_CHANGE_IN_REPO=${APPVEYOR_REPO_COMMIT} CIRRUS_BRANCH=${APPVEYOR_REPO_BRANCH} ${APPVEYOR_BUILD_FOLDER}/scripts/cirrus-deploy.sh + +- + matrix: + only: - job_name: MacOS_10_15_Qt_5_15 (qbs, multibundle) - job_name: MacOS_10_15_Qt_5_15 (qbs, singlebundle) @@ -596,6 +697,8 @@ for: - sudo xcode-select -p - sudo xcode-select -s /Applications/Xcode-$XCODE_VERSION.app - sudo xcode-select -p + + before_build: - ls ${HOME}/Qt - export QTDIR="${HOME}/${QT}" - export PATH="$QTDIR/bin:$HOME/.local/bin:`python3 -m site --user-base`/bin:${HOME}/Qt/Qt Creator.app/Contents/MacOS:$PATH" @@ -608,8 +711,6 @@ for: - qmake --version - which qmake - qbs --version - - before_build: - cd ${APPVEYOR_BUILD_FOLDER} build_script: @@ -631,18 +732,18 @@ for: - job_name: MacOS_10_15_Qt_5_15 (make) init: - - export QTDIR="${HOME}/${QT}" - - export PATH="$QTDIR/bin:$PATH" - - echo $PATH - find /Applications -maxdepth 1 -type d -name 'Xcode*.app' - sudo xcode-select -p - sudo xcode-select -s /Applications/Xcode-$XCODE_VERSION.app - sudo xcode-select -p + + before_build: + - export QTDIR="${HOME}/${QT}" + - export PATH="$QTDIR/bin:$PATH" + - echo $PATH - clang --version - qmake --version - which qmake - - before_build: - cd ${APPVEYOR_BUILD_FOLDER} - mkdir build - cd build diff --git a/scripts/treestate.py b/scripts/treestate.py new file mode 100644 index 000000000..79ea442b4 --- /dev/null +++ b/scripts/treestate.py @@ -0,0 +1,93 @@ +#!/usr/bin/env python3 +# Record the current state of a tree in the filesystem +# Original idea: https://github.com/hydrogen-music/hydrogen/blob/master/treestate.py + +import os +import sys +import json + +DIR = 1 +LINK = 2 +FILE = 3 + +# Scan filesystem +def scanTreeState(path): + if os.path.islink(path): + yield [LINK, path ] + elif os.path.isdir(path): + yield [DIR, path] + for leaf in os.listdir(path): + p = os.path.join(path, leaf) + for item in scanTreeState(p): + yield item + else: + yield [FILE, path, os.path.getmtime(path)] + +# Write the tree in JSON format +def writeTree(filename, tree): + with open(filename, 'w') as f: + json.dump(list(tree), f, indent=1) + +def readTree(filename): + with open(filename, "r") as f: + if f == None: + print("*** couldn't open {} ***".format(filename)) + return json.load(f) + +# Find updates in tree between states A and B +def findUpdates(a, b): + a_map = {} + + # Build mapping of filename -> modified time in A + for o in a: + if o[0] == FILE: + a_map[ o[1] ] = o[2] + else: + a_map[ o[1] ] = True + + # Find updated or new items in B + for o in b: + if o[1] in a_map: + if o[0] == FILE and o[2] != a_map[ o[1] ]: + print(o[1]) + + elif o[0] == FILE or o[0] == LINK: + print(o[1]) + + +def help(): + print("Syntax:") + print(" {} scan path stateFile".format(sys.argv[0])) + print(" Record the state of in ") + print(" {} updates stateFile path".format(sys.argv[0])) + print(" Print the paths of objects in which have updated since ") + exit() + + +# Process arguments +if len(sys.argv) < 2: + help() + +if sys.argv[1] == 'scan': + if len(sys.argv) != 4: + help() + + path = sys.argv[2] + stateFile = sys.argv[3] + + tree = scanTreeState(path) + writeTree(stateFile, tree) + +elif sys.argv[1] == 'updates': + if len(sys.argv) != 4: + help() + + a = sys.argv[2] + b = sys.argv[3] + + findUpdates(readTree(a), scanTreeState(b)) + +else: + print("Unknown command: {}".format(sys.argv[1])) + help() + diff --git a/src/app/puzzle/puzzle.qbs b/src/app/puzzle/puzzle.qbs index b07a5c92e..9ac09da1c 100644 --- a/src/app/puzzle/puzzle.qbs +++ b/src/app/puzzle/puzzle.qbs @@ -1,5 +1,6 @@ import qbs.FileInfo import qbs.File +import qbs.Utilities VToolApp { Depends { name: "buildconfig" } @@ -14,6 +15,19 @@ VToolApp { Depends { name: "multibundle"; } Depends { name: "VGAnalyticsLib" } + // Explicitly link to libcrypto and libssl to avoid error: Failed to load libssl/libcrypto. + // Path must be inside PKG_CONFIG_PATH variable. + // Explicit linking will help macdeployqt undertsand that we want to see them inside the bundle. + Depends { + name: "libcrypto" + condition: qbs.targetOS.contains("macos") && Utilities.versionCompare(Qt.core.version, "6") >= 0 + } + + Depends { + name: "libssl" + condition: qbs.targetOS.contains("macos") && Utilities.versionCompare(Qt.core.version, "6") >= 0 + } + name: "Puzzle" buildconfig.appTarget: qbs.targetOS.contains("macos") ? "Puzzle" : "puzzle" targetName: buildconfig.appTarget diff --git a/src/app/tape/tape.qbs b/src/app/tape/tape.qbs index 58a4809e4..3dd043ebd 100644 --- a/src/app/tape/tape.qbs +++ b/src/app/tape/tape.qbs @@ -26,6 +26,19 @@ VToolApp { condition: Utilities.versionCompare(Qt.core.version, "6") >= 0 && buildconfig.useConanPackages } + // Explicitly link to libcrypto and libssl to avoid error: Failed to load libssl/libcrypto. + // Path must be inside PKG_CONFIG_PATH variable. + // Explicit linking will help macdeployqt undertsand that we want to see them inside the bundle. + Depends { + name: "libcrypto" + condition: qbs.targetOS.contains("macos") && Utilities.versionCompare(Qt.core.version, "6") >= 0 + } + + Depends { + name: "libssl" + condition: qbs.targetOS.contains("macos") && Utilities.versionCompare(Qt.core.version, "6") >= 0 + } + name: "Tape" buildconfig.appTarget: qbs.targetOS.contains("macos") ? "Tape" : "tape" targetName: buildconfig.appTarget diff --git a/src/app/valentina/valentina.qbs b/src/app/valentina/valentina.qbs index 5c000376c..ff0fe98fc 100644 --- a/src/app/valentina/valentina.qbs +++ b/src/app/valentina/valentina.qbs @@ -28,6 +28,19 @@ VToolApp { required: false } + // Explicitly link to libcrypto and libssl to avoid error: Failed to load libssl/libcrypto. + // Path must be inside PKG_CONFIG_PATH variable. + // Explicit linking will help macdeployqt undertsand that we want to see them inside the bundle. + Depends { + name: "libcrypto" + condition: qbs.targetOS.contains("macos") && Utilities.versionCompare(Qt.core.version, "6") >= 0 + } + + Depends { + name: "libssl" + condition: qbs.targetOS.contains("macos") && Utilities.versionCompare(Qt.core.version, "6") >= 0 + } + primaryApp: true name: "Valentina"