Skip to content

Support using the system version of brotli #66462

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/native/external/brotli.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include_directories("${CMAKE_CURRENT_LIST_DIR}/brotli/include")
include_directories(BEFORE "${CMAKE_CURRENT_LIST_DIR}/brotli/include")

set (BROTLI_SOURCES_BASE
common/constants.c
Expand Down
31 changes: 21 additions & 10 deletions src/native/libs/System.IO.Compression.Native/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,20 @@ set(NATIVECOMPRESSION_SOURCES
)

if (NOT CLR_CMAKE_TARGET_BROWSER)
include(${CLR_SRC_NATIVE_DIR}/external/brotli.cmake)

if (CLR_CMAKE_USE_SYSTEM_BROTLI)
add_definitions(-DFEATURE_USE_SYSTEM_BROTLI)
else ()
include(${CLR_SRC_NATIVE_DIR}/external/brotli.cmake)

set (NATIVECOMPRESSION_SOURCES
${NATIVECOMPRESSION_SOURCES}
${BROTLI_SOURCES}
)
endif ()

set (NATIVECOMPRESSION_SOURCES
${NATIVECOMPRESSION_SOURCES}
${BROTLI_SOURCES}
entrypoints.c
)
endif ()
Expand Down Expand Up @@ -60,14 +69,16 @@ if (CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_BROWSER)
set_property(TARGET System.IO.Compression.Native APPEND_STRING PROPERTY LINK_FLAGS ${EXPORTS_LINKER_OPTION})
set_property(TARGET System.IO.Compression.Native APPEND_STRING PROPERTY LINK_DEPENDS ${EXPORTS_FILE})

add_custom_command(TARGET System.IO.Compression.Native POST_BUILD
COMMENT "Verifying System.IO.Compression.Native entry points against entrypoints.c "
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/../verify-entrypoints.sh
$<TARGET_FILE:System.IO.Compression.Native>
${CMAKE_CURRENT_SOURCE_DIR}/entrypoints.c
${CMAKE_NM}
VERBATIM
)
if (NOT CLR_CMAKE_USE_SYSTEM_BROTLI)
add_custom_command(TARGET System.IO.Compression.Native POST_BUILD
COMMENT "Verifying System.IO.Compression.Native entry points against entrypoints.c "
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/../verify-entrypoints.sh
$<TARGET_FILE:System.IO.Compression.Native>
${CMAKE_CURRENT_SOURCE_DIR}/entrypoints.c
${CMAKE_NM}
VERBATIM
)
endif ()
endif ()

install_with_stripped_symbols (System.IO.Compression.Native PROGRAMS .)
Expand Down
8 changes: 4 additions & 4 deletions src/native/libs/System.IO.Compression.Native/entrypoints.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

// Include System.IO.Compression.Native headers
#include "pal_zlib.h"
#include <external/brotli/include/brotli/decode.h>
#include <external/brotli/include/brotli/encode.h>
#include <external/brotli/include/brotli/port.h>
#include <external/brotli/include/brotli/types.h>
#include <brotli/decode.h>
#include <brotli/encode.h>
#include <brotli/port.h>
#include <brotli/types.h>

static const Entry s_compressionNative[] =
{
Expand Down
7 changes: 7 additions & 0 deletions src/native/libs/System.IO.Compression.Native/extra_libs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,11 @@ macro(append_extra_compression_libs NativeLibsExtra)
find_package(ZLIB REQUIRED)
endif ()
list(APPEND ${NativeLibsExtra} ${ZLIB_LIBRARIES})

if (CLR_CMAKE_USE_SYSTEM_BROTLI)
find_library(BROTLIDEC brotlidec REQUIRED)
find_library(BROTLIENC brotlienc REQUIRED)

list(APPEND ${NativeLibsExtra} ${BROTLIDEC} ${BROTLIENC})
endif ()
endmacro()