Skip to content

Commit

Permalink
Merge branch 'master' into anilm3/v2
Browse files Browse the repository at this point in the history
  • Loading branch information
Anilm3 authored Oct 15, 2024
2 parents 7eb2ea7 + cd93e86 commit 556c411
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 42 deletions.
58 changes: 21 additions & 37 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,24 @@ jobs:
${{ github.workspace }}/packages/*.sha256
macos-build:
runs-on: macos-12
runs-on: macos-14
strategy:
fail-fast: false
matrix:
arch:
- x86_64
- arm64
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Create Build Directory
run: cmake -E make_directory ${{ github.workspace }}/build ${{ github.workspace }}/packages
- name: Generating Build Scripts
run: cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DMACOSX_DEPLOYMENT_TARGET=10.9 -DCMAKE_INSTALL_PREFIX=${{ github.workspace }} -DCPACK_PACKAGE_DIRECTORY=${{ github.workspace }}/packages ${{ github.workspace }}
run: cmake -DCMAKE_OSX_ARCHITECTURES=${{ matrix.arch }} -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=${{ github.workspace }} -DCPACK_PACKAGE_DIRECTORY=${{ github.workspace }}/packages ${{ github.workspace }}
working-directory: ${{ github.workspace }}/build
- name: Build Binaries
run: cmake --build . --config RelWithDebInfo --verbose --target all --target waf_test -j
run: cmake --build . --config RelWithDebInfo --verbose --target all --target waf_test -j $(getconf _NPROCESSORS_ONLN)
working-directory: ${{ github.workspace }}/build
- name: Test
run: ${{ github.workspace }}/build/tests/waf_test
Expand All @@ -81,44 +87,14 @@ jobs:
run: for file in *.tar.gz; do shasum -a 256 "$file" > "$file.sha256"; done
- uses: actions/upload-artifact@v4
with:
name: libddwaf-macos-x86_64
path: |
${{ github.workspace }}/packages/*.tar.gz
${{ github.workspace }}/packages/*.sha256
macos-cross-build:
runs-on: macos-12
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Create Build Directory
run: cmake -E make_directory ${{ github.workspace }}/build ${{ github.workspace }}/packages
- name: Generating Build Scripts
run: cmake -DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_BUILD_TYPE=RelWithDebInfo -DMACOSX_DEPLOYMENT_TARGET=10.9 -DCMAKE_INSTALL_PREFIX=${{ github.workspace }} -DCPACK_PACKAGE_DIRECTORY=${{ github.workspace }}/packages ${{ github.workspace }}
working-directory: ${{ github.workspace }}/build
- name: Build Binaries
run: cmake --build . --config RelWithDebInfo --verbose --target all -j
working-directory: ${{ github.workspace }}/build
- name: Build Packages
run: cmake --build . --target package --config RelWithDebInfo --verbose
working-directory: ${{ github.workspace }}/build
- name: Remove Temporary Files
run: cmake -E remove_directory _CPack_Packages
working-directory: ${{ github.workspace }}/packages
- name: Generate Package sha256
working-directory: ${{ github.workspace }}/packages
run: for file in *.tar.gz; do shasum -a 256 "$file" > "$file.sha256"; done
- uses: actions/upload-artifact@v4
with:
name: libddwaf-macos-arm64
name: libddwaf-macos-${{ matrix.arch }}
path: |
${{ github.workspace }}/packages/*.tar.gz
${{ github.workspace }}/packages/*.sha256
macos-universal-package:
runs-on: macos-12
needs: [macos-build, macos-cross-build]
runs-on: macos-14
needs: [macos-build]
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
Expand Down Expand Up @@ -147,6 +123,14 @@ jobs:
# Change the current folder name with the universal name
mv ./pack-temp/osx/libddwaf-*-darwin-* ./pack-temp/osx/$universalName
echo "--- x86_64 target ---"
file ./pack-temp/osx-x64/$x64Name/lib/libddwaf.dylib
otool -l ./pack-temp/osx-x64/$x64Name/lib/libddwaf.dylib | egrep "(minos|sdk)"
echo "--- arm64 target ---"
file ./pack-temp/osx-arm64/$arm64Name/lib/libddwaf.dylib
otool -l ./pack-temp/osx-arm64/$arm64Name/lib/libddwaf.dylib | egrep "(minos|sdk)"
# Create the universal binary for the shared library: libddwaf.dylib
lipo ./pack-temp/osx-x64/$x64Name/lib/libddwaf.dylib ./pack-temp/osx-arm64/$arm64Name/lib/libddwaf.dylib -create -output ./pack-temp/osx/$universalName/lib/libddwaf.dylib
# Check the universal binary
Expand Down Expand Up @@ -317,7 +301,7 @@ jobs:
path: ${{ github.workspace }}/output-packages

release:
needs: [ windows-builds, macos-build, macos-cross-build, docker-builds, linux-musl-build, package-nuget]
needs: [ windows-builds, macos-build, docker-builds, linux-musl-build, package-nuget]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
permissions:
Expand Down
20 changes: 16 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ file(READ "version" version)

string(REGEX REPLACE "-(alpha|beta)[0-9]*$" "" mmp_version ${version})

if (APPLE)
set(CMAKE_OSX_DEPLOYMENT_TARGET "12.7" CACHE STRING "Minimum OS X deployment version")
endif()

project(libddwaf VERSION "${mmp_version}")

# Resetting the version allows for alpha and beta suffix releases
Expand Down Expand Up @@ -35,10 +39,6 @@ option(LIBDDWAF_VECTORIZED_TRANSFORMERS "Enable vectorization for transformers"
option(LIBDDWAF_ENABLE_LTO "Enable link-time optimisation" OFF)

if(NOT MSVC)
if (APPLE)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.12" CACHE STRING "Minimum OS X deployment version")
endif()

add_compile_options(-Wall -Wextra -Wno-narrowing)
if (CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)
add_compile_options(-ggdb)
Expand All @@ -65,6 +65,18 @@ try_compile(STDLIB_MAP_RECURSIVE ${CMAKE_CURRENT_BINARY_DIR}
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/try_rec_map.cpp
CXX_STANDARD 20)

try_compile(STDLIB_MEMORY_RESOURCE_FTM ${CMAKE_CURRENT_BINARY_DIR}
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/try_mem_resource_ftm.cpp
CXX_STANDARD 20)

try_compile(STDLIB_MONOTONIC_RESOURCE ${CMAKE_CURRENT_BINARY_DIR}
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/try_monotonic_resource.cpp
CXX_STANDARD 20)

message(STATUS "Has recursive unordered_map : ${STDLIB_MAP_RECURSIVE}")
message(STATUS "Has memory_resource test macro : ${STDLIB_MEMORY_RESOURCE_FTM}")
message(STATUS "Has monotonic_resource : ${STDLIB_MONOTONIC_RESOURCE}")

# System dependencies
set(LIBDDWAF_INTERFACE_LIBRARIES "")
if(LINUX)
Expand Down
6 changes: 6 additions & 0 deletions cmake/objects.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ function(gen_objects target_name)
target_compile_definitions(${target_name} PRIVATE HAS_NONRECURSIVE_UNORDERED_MAP)
endif()

if (NOT STDLIB_MEMORY_RESOURCE_FTM AND STDLIB_MONOTONIC_RESOURCE)
# For some reason __cpp_lib_memory_resource seems to be missing in macos-14 when
# using the correct CMAKE_OSX_DEPLOYMENT_TARGET
target_compile_definitions(${target_name} PRIVATE __cpp_lib_memory_resource)
endif()

if (LIBDDWAF_VECTORIZED_TRANSFORMERS)
target_compile_definitions(${target_name} PRIVATE LIBDDWAF_VECTORIZED_TRANSFORMERS)
endif()
Expand Down
2 changes: 1 addition & 1 deletion cmake/package.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
install(FILES ${libddwaf_SOURCE_DIR}/include/ddwaf.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(EXPORT libddwaf-config DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cmake/libddwaf)

if(APPLE AND CMAKE_OSX_ARCHITECTURES MATCHES "arm64")
if(APPLE AND CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
set(LIBDDWAF_PACKAGE_PROCESSOR ${CMAKE_OSX_ARCHITECTURES} CACHE STRING "Alternative processor for packaging purposes")
else()
set(LIBDDWAF_PACKAGE_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR} CACHE STRING "Alternative processor for packaging purposes")
Expand Down
8 changes: 8 additions & 0 deletions cmake/try_mem_resource_ftm.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <memory_resource>
#include <version>

#if !defined(__cpp_lib_memory_resource)
# error "No memory resource available"
#endif

int main() {}
7 changes: 7 additions & 0 deletions cmake/try_monotonic_resource.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <memory_resource>

int main()
{
std::pmr::monotonic_buffer_resource mr;
return 0;
}
2 changes: 2 additions & 0 deletions cmake/try_rec_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ struct X {
std::unordered_map<int, X> x{};
};
static X x{};

int main() {}
6 changes: 6 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ if(NOT STDLIB_MAP_RECURSIVE)
target_compile_definitions(waf_test PRIVATE HAS_NONRECURSIVE_UNORDERED_MAP)
endif()

if (NOT STDLIB_MEMORY_RESOURCE_FTM AND STDLIB_MONOTONIC_RESOURCE)
# For some reason __cpp_lib_memory_resource seems to be missing in macos-14 when
# using the correct CMAKE_OSX_DEPLOYMENT_TARGET
target_compile_definitions(waf_test PRIVATE __cpp_lib_memory_resource)
endif()

if (LIBDDWAF_VECTORIZED_TRANSFORMERS)
target_compile_definitions(waf_test PRIVATE LIBDDWAF_VECTORIZED_TRANSFORMERS)
endif()
Expand Down

0 comments on commit 556c411

Please sign in to comment.