From 20538f4abe7957541d25d13c11d77fbe14dcf6f7 Mon Sep 17 00:00:00 2001 From: Tal Regev Date: Sat, 6 May 2023 21:41:42 +0300 Subject: [PATCH] Compile osx manager with vcpkg --- .github/workflows/osx.yml | 17 ++- .../configs/manager/osx/vcpkg.json | 16 +++ .../patches/boinc_SetItemBitmap.patch | 59 ++++++++++ .../patches/boinc_SetVisibilityHidden.patch | 14 +++ 3rdParty/vcpkg_ports/patches/wxwidgets.patch | 24 +++++ 3rdParty/vcpkg_ports/ports/mac/.gitkeep | 0 .../vcpkg_ports/triplets/ci/arm64-osx.cmake | 3 + .../vcpkg_ports/triplets/ci/x64-osx.cmake | 3 + ci_tools/trailing_whitespaces_check.py | 1 + mac_build/buildMacBOINC-CI.sh | 101 +++++++++++++++++- osx/build_vcpkg_3rdparty_for_manager.sh | 55 ++++++++++ osx/update_vcpkg_manager_universal.sh | 33 ++++++ 12 files changed, 323 insertions(+), 3 deletions(-) create mode 100644 3rdParty/vcpkg_ports/configs/manager/osx/vcpkg.json create mode 100644 3rdParty/vcpkg_ports/patches/boinc_SetItemBitmap.patch create mode 100644 3rdParty/vcpkg_ports/patches/boinc_SetVisibilityHidden.patch create mode 100644 3rdParty/vcpkg_ports/patches/wxwidgets.patch create mode 100644 3rdParty/vcpkg_ports/ports/mac/.gitkeep create mode 100755 osx/build_vcpkg_3rdparty_for_manager.sh create mode 100755 osx/update_vcpkg_manager_universal.sh diff --git a/.github/workflows/osx.yml b/.github/workflows/osx.yml index a637bcfc789..076873d3784 100644 --- a/.github/workflows/osx.yml +++ b/.github/workflows/osx.yml @@ -126,8 +126,12 @@ jobs: path: deploy/macos_apps_arm64.7z cmake-build: - name: cmake-build + name: ${{matrix.type}}-build runs-on: macos-latest + strategy: + matrix: + type: [manager-vcpkg, libs-cmake] + fail-fast: false steps: - uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd with: @@ -146,8 +150,17 @@ jobs: echo "VCPKG_BINARY_SOURCES=clear;x-aws-config,no-sign-request;x-aws,s3://vcpkg.cache.boinc/,read" >> $GITHUB_ENV - name: libs cmake + if: matrix.type == 'libs-cmake' run: osx/ci_build_libs_cmake.sh + - name: install vcpkg dependencies + if: matrix.type == 'manager-vcpkg' + run: ./osx/build_vcpkg_3rdparty_for_manager.sh + + - name: vcpkg make manager + if: success() && matrix.type == 'manager-vcpkg' + run: ./mac_build/buildMacBOINC-CI.sh --no_shared_headers --cache_dir $(pwd)/3rdParty/osx/mac_vcpkg --vcpkg + - name: Prepare logs on failure if: ${{ failure() }} run: python3 ./deploy/prepare_deployment.py logs @@ -156,5 +169,5 @@ jobs: if: ${{ failure() }} uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 with: - name: osx_logs_cmake-build_${{ github.event.pull_request.head.sha }} + name: osx_logs_${{ matrix.type }}_${{ github.event.pull_request.head.sha }} path: deploy/logs.7z diff --git a/3rdParty/vcpkg_ports/configs/manager/osx/vcpkg.json b/3rdParty/vcpkg_ports/configs/manager/osx/vcpkg.json new file mode 100644 index 00000000000..b7c54da7223 --- /dev/null +++ b/3rdParty/vcpkg_ports/configs/manager/osx/vcpkg.json @@ -0,0 +1,16 @@ +{ + "name": "boinc-manager", + "dependencies": + [ + "ftgl", + { + "name": "curl", + "features": ["openssl","c-ares"], + "default-features": false + }, + { + "name": "wxwidgets", + "default-features": false + } + ] +} diff --git a/3rdParty/vcpkg_ports/patches/boinc_SetItemBitmap.patch b/3rdParty/vcpkg_ports/patches/boinc_SetItemBitmap.patch new file mode 100644 index 00000000000..e115a323fd5 --- /dev/null +++ b/3rdParty/vcpkg_ports/patches/boinc_SetItemBitmap.patch @@ -0,0 +1,59 @@ +diff --git a/include/wx/osx/choice.h b/include/wx/osx/choice.h +index 37486f8a7c..d80bf53766 100644 +--- a/include/wx/osx/choice.h ++++ b/include/wx/osx/choice.h +@@ -73,6 +73,7 @@ public: + virtual int FindString(const wxString& s, bool bCase = false) const wxOVERRIDE; + virtual wxString GetString(unsigned int n) const wxOVERRIDE; + virtual void SetString(unsigned int pos, const wxString& s) wxOVERRIDE; ++ void SetItemBitmap(unsigned int n, const wxBitmap& bitmap); + // osx specific event handling common for all osx-ports + + virtual bool OSXHandleClicked(double timestampsec) wxOVERRIDE; +diff --git a/include/wx/osx/core/private.h b/include/wx/osx/core/private.h +index 429c8f7401..cae9f9eebe 100644 +--- a/include/wx/osx/core/private.h ++++ b/include/wx/osx/core/private.h +@@ -820,6 +820,7 @@ public : + } + + virtual void SetItem(int pos, const wxString& item) = 0; ++ virtual void SetItemBitmap(unsigned int n, const wxBitmap& bitmap) = 0; + }; + + +diff --git a/src/osx/choice_osx.cpp b/src/osx/choice_osx.cpp +index 6df17b34e5..1fcb2a5fc4 100644 +--- a/src/osx/choice_osx.cpp ++++ b/src/osx/choice_osx.cpp +@@ -217,6 +217,13 @@ wxString wxChoice::GetString(unsigned int n) const + return m_strings[n] ; + } + ++void wxChoice::SetItemBitmap(unsigned int n, const wxBitmap& bitmap) ++{ ++ wxCHECK_RET( IsValid(n), wxT("wxChoice::SetItemBitmap(): invalid index") ); ++ ++ dynamic_cast(GetPeer())->SetItemBitmap(n, bitmap); ++} ++ + // ---------------------------------------------------------------------------- + // client data + // ---------------------------------------------------------------------------- +diff --git a/src/osx/cocoa/choice.mm b/src/osx/cocoa/choice.mm +index 2f0eb4ba51..52eb85c17d 100644 +--- a/src/osx/cocoa/choice.mm ++++ b/src/osx/cocoa/choice.mm +@@ -93,6 +93,12 @@ public: + m_popUpMenu->FindItemByPosition( pos )->SetItemLabel( s ) ; + } + ++ void SetItemBitmap(unsigned int n, const wxBitmap& bitmap) ++ { ++ if ( bitmap.Ok() ) ++ m_popUpMenu->FindItemByPosition( n )->SetBitmap( bitmap ); ; ++ } ++ + private: + wxMenu* m_popUpMenu; + }; diff --git a/3rdParty/vcpkg_ports/patches/boinc_SetVisibilityHidden.patch b/3rdParty/vcpkg_ports/patches/boinc_SetVisibilityHidden.patch new file mode 100644 index 00000000000..f4e1c563ccf --- /dev/null +++ b/3rdParty/vcpkg_ports/patches/boinc_SetVisibilityHidden.patch @@ -0,0 +1,14 @@ +diff --git a/build/cmake/init.cmake b/build/cmake/init.cmake +index 0584ecaeb5..3e0f5feb3e 100644 +--- a/build/cmake/init.cmake ++++ b/build/cmake/init.cmake +@@ -18,6 +18,9 @@ else() + # CMAKE_CXX_STANDARD not defined. + endif() + ++set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden") ++set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -fvisibility-inlines-hidden") ++ + if(MSVC) + # Determine MSVC runtime library flag + set(MSVC_LIB_USE "/MD") diff --git a/3rdParty/vcpkg_ports/patches/wxwidgets.patch b/3rdParty/vcpkg_ports/patches/wxwidgets.patch new file mode 100644 index 00000000000..970e43bc76a --- /dev/null +++ b/3rdParty/vcpkg_ports/patches/wxwidgets.patch @@ -0,0 +1,24 @@ +diff --git a/wxwidgets/portfile.cmake b/wxwidgets/portfile.cmake +index f812fd8c5..27e289f2b 100644 +--- a/wxwidgets/portfile.cmake ++++ b/wxwidgets/portfile.cmake +@@ -12,6 +12,8 @@ vcpkg_from_github( + fix-pcre2.patch + gtk3-link-libraries.patch + sdl2.patch ++ boinc_SetItemBitmap.patch ++ boinc_SetVisibilityHidden.patch + ) + + vcpkg_check_features( +@@ -75,6 +77,10 @@ vcpkg_cmake_configure( + -DwxUSE_UIACTIONSIMULATOR=OFF + -DCMAKE_DISABLE_FIND_PACKAGE_GSPELL=ON + -DCMAKE_DISABLE_FIND_PACKAGE_MSPACK=ON ++ -DwxBUILD_MONOLITHIC=ON ++ -DwxUSE_DIALUP_MANAGER=ON ++ -DwxUSE_UNICODE=ON ++ -DwxUSE_UNICODE_UTF8=ON + ${OPTIONS} + "-DPKG_CONFIG_EXECUTABLE=${PKGCONFIG}" + # The minimum cmake version requirement for Cotire is 2.8.12. diff --git a/3rdParty/vcpkg_ports/ports/mac/.gitkeep b/3rdParty/vcpkg_ports/ports/mac/.gitkeep new file mode 100644 index 00000000000..e69de29bb2d diff --git a/3rdParty/vcpkg_ports/triplets/ci/arm64-osx.cmake b/3rdParty/vcpkg_ports/triplets/ci/arm64-osx.cmake index b89170f9fdd..cd95aa60626 100644 --- a/3rdParty/vcpkg_ports/triplets/ci/arm64-osx.cmake +++ b/3rdParty/vcpkg_ports/triplets/ci/arm64-osx.cmake @@ -19,3 +19,6 @@ include(${CMAKE_CURRENT_LIST_DIR}/../../vcpkg_root_find.cmake) include(${VCPKG_ROOT}/triplets/arm64-osx.cmake) set(VCPKG_BUILD_TYPE release) +set(VCPKG_OSX_DEPLOYMENT_TARGET 10.13) +set(VCPKG_C_FLAGS -mmacosx-version-min=10.13) +set(VCPKG_CXX_FLAGS -mmacosx-version-min=10.13) diff --git a/3rdParty/vcpkg_ports/triplets/ci/x64-osx.cmake b/3rdParty/vcpkg_ports/triplets/ci/x64-osx.cmake index fe6419e5e1c..5b5b76f4c12 100644 --- a/3rdParty/vcpkg_ports/triplets/ci/x64-osx.cmake +++ b/3rdParty/vcpkg_ports/triplets/ci/x64-osx.cmake @@ -19,3 +19,6 @@ include(${CMAKE_CURRENT_LIST_DIR}/../../vcpkg_root_find.cmake) include(${VCPKG_ROOT}/triplets/x64-osx.cmake) set(VCPKG_BUILD_TYPE release) +set(VCPKG_OSX_DEPLOYMENT_TARGET 10.13) +set(VCPKG_C_FLAGS -mmacosx-version-min=10.13) +set(VCPKG_CXX_FLAGS -mmacosx-version-min=10.13) diff --git a/ci_tools/trailing_whitespaces_check.py b/ci_tools/trailing_whitespaces_check.py index bf1753ccb1f..45d2d634a94 100644 --- a/ci_tools/trailing_whitespaces_check.py +++ b/ci_tools/trailing_whitespaces_check.py @@ -153,6 +153,7 @@ def check(directory, exclude_dirs, exclude_extensions, exclude_files, fix_errors ".nib", ".o", ".odp", + ".patch", ".pdb", ".pdf", ".pdn", diff --git a/mac_build/buildMacBOINC-CI.sh b/mac_build/buildMacBOINC-CI.sh index d57a218d126..fd5323c640e 100755 --- a/mac_build/buildMacBOINC-CI.sh +++ b/mac_build/buildMacBOINC-CI.sh @@ -46,6 +46,7 @@ config="" doclean="-noclean" beautifier="cat" # we need a fallback if xcpretty is not available share_paths="yes" +vcpkg="no" while [[ $# -gt 0 ]]; do key="$1" case $key in @@ -63,6 +64,9 @@ while [[ $# -gt 0 ]]; do --no_shared_headers) share_paths="no" ;; + --vcpkg) + vcpkg="yes" + ;; esac shift # past argument or value done @@ -94,6 +98,7 @@ if [ "${style}" == "Development" ]; then fi if [ ${share_paths} = "yes" ]; then + echo "Building share_paths" ## all targets share the same header and library search paths ## Note: this does not build zip apps, upper case or VBoxWrapper projects. libSearchPathDbg="" @@ -143,6 +148,77 @@ target="x" rm -f /tmp/depversions.txt +if [ $vcpkg = "yes" ]; then + wx_includes_dirs_vcpkg=$(ls -d $cache_dir/include/wx-3.*/) + vcpkg_setting_pref_vcpkg="-setting OTHER_LDFLAGS" + vcpkg_setting_mgr=" \ + -framework SystemConfiguration \ + -bind_at_load \ + -D_THREAD_SAFE \ + -L. \ + -lboinc \ + -lcurl \ + -lcares \ + -lresolv \ + -lssl \ + -lcrypto \ + -lexpat \ + -ldl \ + -lz \ + -lldap \ + -lwx_osx_cocoau-3.2 \ + -lwxscintilla-3.2 \ + -lbrotlicommon \ + -lbrotlidec \ + -lbrotlienc \ + -lnanosvg \ + -lnanosvgrast \ + -lpcre2-32 \ + -lpcre2-16 \ + -lpcre2-8 \ + -lpcre2-posix \ + -lbz2 \ + -ljpeg \ + -llzma \ + -lpng \ + -lpng16 \ + -ltiff \ + -lturbojpeg \ + -liconv \ + -lpthread \ + -lm \ + " + vcpkg_setting_scr=" \ + -lresolv \ + -ljpeg \ + -lfreetype \ + -lbrotlicommon \ + -lbrotlidec \ + -lbrotlienc \ + -lpng \ + -lpng16 \ + -lm \ + -lftgl \ + -lz \ + -lbz2 \ + " + + vcpkg_setting_client=" \ + -framework SystemConfiguration \ + -L. \ + -lboinc \ + -lcurl \ + -lcares \ + -lresolv \ + -lssl \ + -lcrypto \ + -ldl \ + -lz \ + -lldap \ + " + +fi + ## This is code that builds each target individually in the main BOINC Xcode ## project, plus the zip apps, upper case and VBoxWrapper projects. for buildTarget in `xcodebuild -list -project boinc.xcodeproj` @@ -151,7 +227,28 @@ do if [ $foundTargets -eq 1 ]; then if [ "${target}" != "Build_All" ]; then echo "Building ${target}..." - source BuildMacBOINC.sh ${config} ${doclean} -target ${target} -setting HEADER_SEARCH_PATHS "../clientgui ../lib/** ../api/ ${cache_dir}/include ../samples/jpeglib ${cache_dir}/include/freetype2 \\\${HEADER_SEARCH_PATHS}" -setting USER_HEADER_SEARCH_PATHS "" -setting LIBRARY_SEARCH_PATHS "${libSearchPathDbg} ${cache_dir}/lib ../lib \\\${LIBRARY_SEARCH_PATHS}" | tee xcodebuild_${target}.log | $beautifier; retval=${PIPESTATUS[0]} + + if [[ $vcpkg = "yes" && ("${target}" = "mgr_boinc" || "${target}" = "ss_app" || "${target}" = "BOINC_Client") ]]; then + vcpkg_setting_pref=$vcpkg_setting_pref_vcpkg + if [ "${target}" = "mgr_boinc" ]; then + vcpkg_setting=$vcpkg_setting_mgr + wx_includes_dirs=$wx_includes_dirs_vcpkg + fi + if [ "${target}" = "ss_app" ]; then + vcpkg_setting=$vcpkg_setting_scr + wx_includes_dirs="" + fi + if [ "${target}" = "BOINC_Client" ]; then + vcpkg_setting=$vcpkg_setting_client + wx_includes_dirs="" + fi + else + vcpkg_setting_pref="-setting USER_HEADER_SEARCH_PATHS" + vcpkg_setting="" + wx_includes_dirs="" + fi + + source BuildMacBOINC.sh ${config} ${doclean} -target ${target} -setting HEADER_SEARCH_PATHS "../clientgui ../lib/** ../api/ ${cache_dir}/include ../samples/jpeglib ${cache_dir}/include/freetype2 \\\${HEADER_SEARCH_PATHS} $wx_includes_dirs" -setting USER_HEADER_SEARCH_PATHS "" -setting LIBRARY_SEARCH_PATHS "${libSearchPathDbg} ${cache_dir}/lib ../lib \\\${LIBRARY_SEARCH_PATHS}" $vcpkg_setting_pref "$vcpkg_setting" | tee xcodebuild_${target}.log | $beautifier; retval=${PIPESTATUS[0]} if [ ${retval} -eq 0 ]; then echo "Building ${target}...success" echo @@ -186,6 +283,7 @@ fi verify_product_archs "${rootPath}/zip/build/${style}" +if [ $vcpkg -eq 0 ]; then target="UpperCase2" echo "Building ${target}..." source BuildMacBOINC.sh ${config} ${doclean} -uc2 -setting HEADER_SEARCH_PATHS "../../ ../../api/ ../../lib/ ../../zip/ ../../clientgui/mac/ ../jpeglib/ ../samples/jpeglib/ ${cache_dir}/include ${cache_dir}/include/freetype2 \\\${HEADER_SEARCH_PATHS}" -setting LIBRARY_SEARCH_PATHS "../../mac_build/build/Deployment ${cache_dir}/lib \\\${LIBRARY_SEARCH_PATHS}" | tee xcodebuild_${target}.log | $beautifier; retval=${PIPESTATUS[0]} @@ -206,4 +304,5 @@ fi verify_product_archs "${rootPath}/samples/vboxwrapper/build/${style}" +fi cd "${rootPath}" diff --git a/osx/build_vcpkg_3rdparty_for_manager.sh b/osx/build_vcpkg_3rdparty_for_manager.sh new file mode 100755 index 00000000000..111be00d1ff --- /dev/null +++ b/osx/build_vcpkg_3rdparty_for_manager.sh @@ -0,0 +1,55 @@ +#!/bin/sh +set -e + +if [ ! -d "osx" ]; then + echo "start this script in the source root directory" + exit 1 +fi + +CACHE_DIR="$PWD/3rdParty/buildCache/mac" +BUILD_DIR="$PWD/3rdParty/osx" +VCPKG_ROOT="$BUILD_DIR/vcpkg" +VCPKG_X64="$VCPKG_ROOT/installed/x64/x64-osx" +VCPKG_ARM64="$VCPKG_ROOT/installed/arm64/arm64-osx" +MAC_VCPKG=$BUILD_DIR/mac_vcpkg + +osx/update_vcpkg_manager_universal.sh + +echo " " +echo "Copy includes" +mkdir -p "$MAC_VCPKG/lib" +cp -R $VCPKG_X64/include $MAC_VCPKG +find $VCPKG_X64/lib/* -type d -maxdepth 0 -not -name "pkgconfig" -exec cp -R {} "$MAC_VCPKG/lib" \; + +echo "Create universal libs:" + +for lib_x64 in $VCPKG_X64/lib/*.a; do + lib_full_name=$(basename $lib_x64) + lib_name=$(basename -s .a $lib_x64) + lib_arm64="" + lib_universal="$MAC_VCPKG/lib/$lib_full_name" + if [ -f "$VCPKG_ARM64/lib/$lib_full_name" ]; then + lib_arm64="$VCPKG_ARM64/lib/$lib_full_name" + elif [ -f "$VCPKG_ARM64/lib/$lib_name-Darwin.a" ]; then + lib_arm64="$VCPKG_ARM64/lib/$lib_name-Darwin.a" + fi + if [ ! -z $lib_arm64 ]; then + echo exist $lib_full_name + lipo -create "$lib_x64" "$lib_arm64" -output $lib_universal + if ! lipo "$lib_x64" -verify_arch x86_64; then + echo "Fail verify x86_64 on $lib_x64" + exit 1 + fi + if ! lipo "$lib_arm64" -verify_arch arm64; then + echo "Fail verify arm64 on $lib_arm64" + exit 1 + fi + if ! lipo "$lib_universal" -verify_arch x86_64 arm64; then + echo "Fail verify x86_64 arm64 on $lib_universal" + exit 1 + fi + else + echo Not exist $lib_full_name + exit 1 + fi +done diff --git a/osx/update_vcpkg_manager_universal.sh b/osx/update_vcpkg_manager_universal.sh new file mode 100755 index 00000000000..0cd6165ae00 --- /dev/null +++ b/osx/update_vcpkg_manager_universal.sh @@ -0,0 +1,33 @@ +#!/bin/sh +set -e + +if [ ! -d "osx" ]; then + echo "start this script in the source root directory" + exit 1 +fi + +source $PWD/3rdParty/vcpkg_ports/vcpkg_link.sh +BUILD_DIR="$PWD/3rdParty/osx" +VCPKG_PORTS="$PWD/3rdParty/vcpkg_ports" +VCPKG_ROOT="$BUILD_DIR/vcpkg" + +if [ ! -d $VCPKG_ROOT ]; then + mkdir -p $BUILD_DIR + git -C $BUILD_DIR clone $VCPKG_LINK +fi + +git -C $VCPKG_ROOT pull +$VCPKG_ROOT/bootstrap-vcpkg.sh + +# delete prev custom ports +rm -rf $VCPKG_PORTS/ports/mac/* + +# create custom ports base on latest ports with patches +cp -R $VCPKG_ROOT/ports/wxwidgets $VCPKG_PORTS/ports/mac +cp $VCPKG_PORTS/patches/boinc_SetItemBitmap.patch $VCPKG_PORTS/patches/boinc_SetVisibilityHidden.patch $VCPKG_PORTS/ports/mac/wxwidgets + +# apply patches +patch -p1 -d $VCPKG_PORTS/ports/mac -i $VCPKG_PORTS/patches/wxwidgets.patch + +$VCPKG_ROOT/vcpkg install --x-manifest-root=3rdParty/vcpkg_ports/configs/manager/osx --x-install-root=$VCPKG_ROOT/installed/arm64/ --overlay-ports=$VCPKG_PORTS/ports/mac --overlay-triplets=$VCPKG_PORTS/triplets/ci --triplet=arm64-osx --clean-after-build +$VCPKG_ROOT/vcpkg install --x-manifest-root=3rdParty/vcpkg_ports/configs/manager/osx --x-install-root=$VCPKG_ROOT/installed/x64/ --overlay-ports=$VCPKG_PORTS/ports/mac --overlay-triplets=$VCPKG_PORTS/triplets/ci --triplet=x64-osx --clean-after-build