Skip to content

Commit

Permalink
Fix: homebrew CI build, macOS ARM64 with Xcode 16, Boost.JSON build v…
Browse files Browse the repository at this point in the history
…ia CMake (#444)

- fixed CI homebrew build
- fixed Boost.JSON build via CMake
- fixed macOS ARM64 with Xcode 16
  • Loading branch information
dnzbk authored Nov 27, 2024
1 parent 184834d commit 00e50a5
Show file tree
Hide file tree
Showing 19 changed files with 123 additions and 34 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ jobs:
fi
bash linux/build-nzbget.sh $BUILD_PARAMS
- name: Upload full build log on failure
uses: actions/upload-artifact@v4
if: failure()
with:
name: nzbget-android-build-log
path: build/*/build.log
retention-days: 5

- name: Rename build artifacts
if: github.ref_name != 'main' && github.ref_name != 'develop'
run: |
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/freebsd.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: freebsd build
name: freebsd build

on:
workflow_call:
Expand All @@ -9,7 +9,7 @@ jobs:
runs-on: [self-hosted, nzbget-freebsd]

steps:

- name: Checkout
uses: actions/checkout@v4
with:
Expand All @@ -28,6 +28,14 @@ jobs:
fi
bash linux/build-nzbget.sh $BUILD_PARAMS
- name: Upload full build log on failure
uses: actions/upload-artifact@v4
if: failure()
with:
name: nzbget-freebsd-build-log
path: build/*/build.log
retention-days: 5

- name: Rename build artifacts
if: github.ref_name != 'main' && github.ref_name != 'develop'
run: |
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ jobs:
fi
bash linux/build-nzbget.sh $BUILD_PARAMS
- name: Upload full build log on failure
uses: actions/upload-artifact@v4
if: failure()
with:
name: nzbget-linux-build-log
path: build/*/build.log
retention-days: 5

- name: Rename build artifacts
if: github.ref_name != 'main' && github.ref_name != 'develop'
run: |
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/osx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ jobs:
bash osx/build-nzbget.sh x64
fi
- name: Upload full build log on failure
uses: actions/upload-artifact@v4
if: failure()
with:
name: nzbget-osx-x64-build-log
path: build/*/build.log
retention-days: 5

- name: Rename build artifacts
if: github.ref_name != 'main' && github.ref_name != 'develop'
run: |
Expand Down Expand Up @@ -59,6 +67,14 @@ jobs:
bash osx/build-nzbget.sh universal
fi
- name: Upload full build log on failure
uses: actions/upload-artifact@v4
if: failure()
with:
name: nzbget-osx-universal-build-log
path: build/*/build.log
retention-days: 5

- name: Rename build artifacts
if: github.ref_name != 'main' && github.ref_name != 'develop'
run: |
Expand Down
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ else()
endif()
endif()

include(lib/sources.cmake)

configure_file(
${CMAKE_SOURCE_DIR}/cmake/config.h.in
${CMAKE_BINARY_DIR}/config.h
Expand Down
4 changes: 2 additions & 2 deletions cmake/common.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang")
add_compile_options(-Weverything)
add_compile_options(-Weverything -Wno-c++98-compat)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options(-Wall -Wextra)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
Expand All @@ -21,4 +21,4 @@ elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
endif()
endif()

include(FetchContent)
include(ExternalProject)
61 changes: 49 additions & 12 deletions cmake/par2-turbo.cmake
Original file line number Diff line number Diff line change
@@ -1,17 +1,54 @@
set(FETCHCONTENT_QUIET FALSE)
FetchContent_Declare(
set(PAR2_ROOT ${CMAKE_BINARY_DIR}/par2-turbo/src)

add_compile_definitions(HAVE_CONFIG_H PARPAR_ENABLE_HASHER_MD5CRC)

set(CMAKE_ARGS
-DBUILD_TOOL=OFF
-DBUILD_LIB=ON
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_SYSTEM_PROCESSOR=${CMAKE_SYSTEM_PROCESSOR}
-DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}
)

if(APPLE)
set(CMAKE_ARGS ${CMAKE_ARGS}
-DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}
)
endif()

if(CMAKE_SYSROOT)
set(CMAKE_ARGS ${CMAKE_ARGS}
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
-DCMAKE_SYSROOT=${CMAKE_SYSROOT}
-DCMAKE_CXX_FLAGS=-I${CMAKE_SYSROOT}/usr/include/c++/v1
)
endif()

ExternalProject_add(
par2-turbo
GIT_REPOSITORY https://github.com/nzbgetcom/par2cmdline-turbo.git
GIT_TAG v1.1.1-nzbget
TLS_VERIFY TRUE
GIT_SHALLOW TRUE
PREFIX par2-turbo
GIT_REPOSITORY https://github.com/nzbgetcom/par2cmdline-turbo.git
GIT_TAG v1.1.1-nzbget
TLS_VERIFY TRUE
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
CMAKE_ARGS ${CMAKE_ARGS}
INSTALL_COMMAND ""
)

add_compile_definitions(HAVE_CONFIG_H PARPAR_ENABLE_HASHER_MD5CRC)
set(BUILD_TOOL OFF CACHE BOOL "")
set(BUILD_LIB ON CACHE BOOL "")
FetchContent_MakeAvailable(par2-turbo)
if(WIN32)
set(LIBS ${LIBS}
${PAR2_ROOT}/par2-turbo-build/${CMAKE_BUILD_TYPE}/par2-turbo.lib
${PAR2_ROOT}/par2-turbo-build/${CMAKE_BUILD_TYPE}/gf16.lib
${PAR2_ROOT}/par2-turbo-build/${CMAKE_BUILD_TYPE}/hasher.lib
)
else()
set(LIBS ${LIBS}
${PAR2_ROOT}/par2-turbo-build/libpar2-turbo.a
${PAR2_ROOT}/par2-turbo-build/libgf16.a
${PAR2_ROOT}/par2-turbo-build/libhasher.a
)
endif()

set(LIBS ${LIBS} par2-turbo gf16 hasher)
set(INCLUDES ${INCLUDES} ${par2_SOURCE_DIR}/include)
set(INCLUDES ${INCLUDES} ${PAR2_ROOT}/par2-turbo/include)
11 changes: 8 additions & 3 deletions cmake/posix.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ else()

if(NOT DISABLE_CURSES)
set(CURSES_NEED_NCURSES TRUE)
set(CURSES_NEED_WIDE TRUE)
if(NOT APPLE)
set(CURSES_NEED_WIDE TRUE)
endif()
find_package(Curses REQUIRED)
set(INCLUDES ${INCLUDES} ${CURSES_INCLUDE_DIRS})
set(LIBS ${LIBS} ${CURSES_LIBRARIES})
Expand All @@ -113,16 +115,19 @@ else()
include(${CMAKE_SOURCE_DIR}/cmake/boost.cmake)

add_dependencies(${PACKAGE} boost)
add_dependencies(yencode boost)
add_dependencies(regex boost)
else()
set(LIBS ${LIBS} Boost::json)
set(INCLUDES ${INCLUDES} ${Boost_INCLUDE_DIR})
endif()
endif()

include(${CMAKE_SOURCE_DIR}/lib/sources.cmake)

if(NOT DISABLE_PARCHECK)
include(${CMAKE_SOURCE_DIR}/cmake/par2-turbo.cmake)
add_dependencies(${PACKAGE} par2-turbo)
add_dependencies(yencode par2-turbo)
add_dependencies(regex par2-turbo)
endif()

include(CheckIncludeFiles)
Expand Down
8 changes: 6 additions & 2 deletions cmake/windows.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ find_package(Threads REQUIRED)
find_package(LibXml2 REQUIRED)
find_package(Boost REQUIRED COMPONENTS json)

include(${CMAKE_SOURCE_DIR}/cmake/par2-turbo.cmake)

set(LIBS ${LIBS} Threads::Threads Boost::json LibXml2::LibXml2 winmm.lib)
set(INCLUDES ${INCLUDES} ${Boost_INCLUDE_DIR} ${LIBXML2_INCLUDE_DIR})

Expand All @@ -37,6 +35,12 @@ set(INCLUDES ${INCLUDES}
${CMAKE_SOURCE_DIR}/windows/resources
)

include(${CMAKE_SOURCE_DIR}/lib/sources.cmake)

include(${CMAKE_SOURCE_DIR}/cmake/par2-turbo.cmake)
add_dependencies(yencode par2-turbo)
add_dependencies(regex par2-turbo)

set(FUNCTION_MACRO_NAME __FUNCTION__)
set(HAVE_CTIME_R_3 1)
set(HAVE_VARIADIC_MACROS 1)
Expand Down
3 changes: 3 additions & 0 deletions daemon/main/nzbget.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@
#include <libxml/tree.h>

#include <boost/asio.hpp>
#if !defined(DISABLE_TLS) && defined(HAVE_OPENSSL)
#include <boost/asio/ssl.hpp>
#endif

// NOTE: do not include <iostream> in "nzbget.h". <iostream> contains objects requiring
// intialization, causing every unit in nzbget to have initialization routine. This in particular
Expand Down
10 changes: 5 additions & 5 deletions lib/sources.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "i?86|x86_64")
set(SSE2_CXXFLAGS "-msse2")
set(SSSE3_CXXFLAGS "-mssse3")
set(PCLMUL_CXXFLAGS "-msse4.1 -mpclmul")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm.*")
set(NEON_CXXFLAGS "-mfpu=neon")
set(ACLECRC_CXXFLAGS "-march=armv8-a+crc -fpermissive")
elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
set(ACLECRC_CXXFLAGS "-march=armv8-a+crc -fpermissive")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64" OR CMAKE_SYSTEM_PROCESSOR MATCHES "arm64")
set(ACLECRC_CXXFLAGS "-march=armv8-a+crc -fpermissive")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm.*")
set(NEON_CXXFLAGS "-mfpu=neon")
set(ACLECRC_CXXFLAGS "-march=armv8-a+crc -fpermissive")
endif()

add_library(regex STATIC
Expand Down
1 change: 1 addition & 0 deletions lib/yencode/SimdDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "nzbget.h"

#ifdef SIMD_DECODER

Expand Down
3 changes: 2 additions & 1 deletion linux/build-nzbget.sh
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ build_bin()
export LDFLAGS=""
export NZBGET_INCLUDES="$TOOLCHAIN_PATH/$ARCH/output/staging/usr/include/;"

if [ $PLATFORM == "freebsd" ]; then
if [ "$PLATFORM" == "freebsd" ]; then
export CXXFLAGS="-Os --sysroot=$FREEBSD_SYSROOT -I$FREEBSD_SYSROOT/usr/include/c++/v1"
export CFLAGS=$CXXFLAGS
export CPPFLAGS=$CXXFLAGS
Expand Down Expand Up @@ -649,6 +649,7 @@ build_bin()
;;
esac

unset CFLAGS
unset CXXFLAGS
unset CPPFLAGS
unset LDFLAGS
Expand Down
1 change: 1 addition & 0 deletions osx/build-nzbget.sh
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ for ARCH in $ARCHS; do
cmake ../.. \
-DENABLE_STATIC=ON \
-DCMAKE_INSTALL_PREFIX="$PWD/../../$NZBGET_PATH/$DAEMON_PATH" \
-DCMAKE_SYSTEM_NAME="Darwin" \
-DVERSION_SUFFIX="$VERSION_SUFFIX" \
-DCMAKE_SYSTEM_PROCESSOR=$CMAKE_ARCH \
-DCMAKE_OSX_ARCHITECTURES=$CMAKE_ARCH
Expand Down
2 changes: 1 addition & 1 deletion tests/extension/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
file(GLOB ExtensionSrc
set(ExtensionSrc
main.cpp
ManifestFileTest.cpp
ExtensionLoaderTest.cpp
Expand Down
2 changes: 1 addition & 1 deletion tests/postprocess/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
file(GLOB PostprocessTestsSrc
set(PostprocessTestsSrc
main.cpp
# DirectUnpackTest.cpp
# DupeMatcherTest.cpp
Expand Down
3 changes: 1 addition & 2 deletions tests/system/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
file(GLOB SystemTestsSrc
set(SystemTestsSrc
main.cpp
SystemInfoTest.cpp
${CMAKE_SOURCE_DIR}/daemon/system/CPU.cpp
Expand All @@ -7,7 +7,6 @@ file(GLOB SystemTestsSrc
${CMAKE_SOURCE_DIR}/daemon/system/SystemInfo.cpp
${CMAKE_SOURCE_DIR}/daemon/connect/HttpClient.cpp
${CMAKE_SOURCE_DIR}/daemon/main/Options.cpp
${CMAKE_SOURCE_DIR}/daemon/remote/MessageBase.cpp
${CMAKE_SOURCE_DIR}/daemon/queue/DownloadInfo.cpp
${CMAKE_SOURCE_DIR}/daemon/queue/DiskState.cpp
${CMAKE_SOURCE_DIR}/daemon/feed/FeedInfo.cpp
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/util/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
file(GLOB UtilTestSrc
set(UtilTestSrc
main.cpp
FileSystemTest.cpp
UtilTest.cpp
Expand Down

0 comments on commit 00e50a5

Please sign in to comment.