Skip to content
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

[woff2] fix for static linking and alternative compiler toolchains #16392

Merged
merged 10 commits into from
Apr 7, 2021
90 changes: 90 additions & 0 deletions ports/woff2/0001-unofficial-brotli.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ecfbb83..7fb7a15 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -34,13 +34,23 @@ endif()
# Find Brotli dependencies
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
find_package(BrotliDec)
-if (NOT BROTLIDEC_FOUND)
- message(FATAL_ERROR "librotlidec is needed to build woff2.")
-endif ()
find_package(BrotliEnc)
-if (NOT BROTLIENC_FOUND)
- message(FATAL_ERROR "librotlienc is needed to build woff2.")
-endif ()
+if(BROTLIDEC_FOUND AND BROTLIENC_FOUND)
+ include_directories("${BROTLIDEC_INCLUDE_DIRS}" "${BROTLIENC_INCLUDE_DIRS}")
+ set(WOFF2_BROTLIDEC libbrotlidec)
+ set(WOFF2_BROTLIENC libbrotlienc)
+ set(WOFF2_BORTLIDEC_LIBRARIES "${BROTLIDEC_LIBRARIES}")
+ set(WOFF2_BORTLIENC_LIBRARIES "${BROTLIENC_LIBRARIES}")
+else()
+ find_package(unofficial-brotli REQUIRED)
+ if(TARGET unofficial::brotli::brotlidec-static)
+ set(BROTLI_LINKAGE -static)
+ endif()
+ set(WOFF2_BROTLIDEC unofficial::brotli::brotlidec${BROTLI_LINKAGE})
+ set(WOFF2_BROTLIENC unofficial::brotli::brotlienc${BROTLI_LINKAGE})
+ set(WOFF2_BORTLIDEC_LIBRARIES unofficial::brotli::brotlidec${BROTLI_LINKAGE} unofficial::brotli::brotlicommon${BROTLI_LINKAGE})
+ set(WOFF2_BORTLIENC_LIBRARIES unofficial::brotli::brotlienc${BROTLI_LINKAGE} unofficial::brotli::brotlicommon${BROTLI_LINKAGE})
+endif()

# Set compiler flags
if (NOT CANONICAL_PREFIXES)
@@ -63,9 +73,8 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_FLAG}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAG}")
set(CMAKE_CXX_STANDARD 11)

-# Set search path for our private/public headers as well as Brotli headers
-include_directories("src" "include"
- "${BROTLIDEC_INCLUDE_DIRS}" "${BROTLIENC_INCLUDE_DIRS}")
+# Set search path for our private/public headers
+include_directories("src" "include")

# Common part used by decoder and encoder
add_library(woff2common
@@ -77,7 +86,7 @@ add_library(woff2common
add_library(woff2dec
src/woff2_dec.cc
src/woff2_out.cc)
-target_link_libraries(woff2dec woff2common "${BROTLIDEC_LIBRARIES}")
+target_link_libraries(woff2dec woff2common ${WOFF2_BORTLIDEC_LIBRARIES})
add_executable(woff2_decompress src/woff2_decompress.cc)
target_link_libraries(woff2_decompress woff2dec)

@@ -88,7 +97,7 @@ add_library(woff2enc
src/normalize.cc
src/transform.cc
src/woff2_enc.cc)
-target_link_libraries(woff2enc woff2common "${BROTLIENC_LIBRARIES}")
+target_link_libraries(woff2enc woff2common ${WOFF2_BORTLIENC_LIBRARIES})
add_executable(woff2_compress src/woff2_compress.cc)
target_link_libraries(woff2_compress woff2enc)

@@ -246,7 +255,7 @@ generate_pkg_config ("${CMAKE_CURRENT_BINARY_DIR}/libwoff2dec.pc"
DESCRIPTION "WOFF2 decoder library"
URL "https://github.com/google/woff2"
VERSION "${WOFF2_VERSION}"
- DEPENDS libbrotlidec
+ DEPENDS ${WOFF2_BROTLIDEC}
DEPENDS_PRIVATE libwoff2common
LIBRARIES woff2dec)

@@ -255,7 +264,7 @@ generate_pkg_config ("${CMAKE_CURRENT_BINARY_DIR}/libwoff2enc.pc"
DESCRIPTION "WOFF2 encoder library"
URL "https://github.com/google/woff2"
VERSION "${WOFF2_VERSION}"
- DEPENDS libbrotlienc
+ DEPENDS ${WOFF2_BROTLIENC}
DEPENDS_PRIVATE libwoff2common
LIBRARIES woff2enc)

@@ -264,6 +273,7 @@ if (NOT BUILD_SHARED_LIBS)
install(
TARGETS woff2_decompress woff2_compress woff2_info
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
+ BUNDLE DESTINATION "${CMAKE_INSTALL_BINDIR}"
)
endif()

1 change: 1 addition & 0 deletions ports/woff2/CONTROL
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Source: woff2
Version: 1.0.2
Build-Depends: brotli
Port-Version: 1
Description: font compression reference code
4 changes: 4 additions & 0 deletions ports/woff2/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ vcpkg_from_github(
REF v1.0.2
SHA512 c788bba1530aec463e755e901f9342f4b599e3a07f54645fef1dc388ab5d5c30625535e5dd38e9e792e04a640574baa50eeefb6b7338ab403755f4a4e0c3044d
HEAD_REF master
PATCHES
0001-unofficial-brotli.patch
)

vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS
-DCANONICAL_PREFIXES=ON
)

vcpkg_install_cmake()
Expand Down
4 changes: 0 additions & 4 deletions scripts/ci.baseline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1657,10 +1657,6 @@ wintoast:arm-uwp=fail
wintoast:x64-linux=fail
wintoast:x64-osx=fail
wintoast:x64-uwp=fail
woff2:x64-linux=fail
woff2:x64-osx=fail
woff2:x64-windows-static=fail
woff2:x64-windows-static-md=fail
wpilib:arm64-windows=fail
wpilib:x64-osx=fail
wxchartdir:x64-osx=fail
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -6214,7 +6214,7 @@
},
"woff2": {
"baseline": "1.0.2",
"port-version": 0
"port-version": 1
},
"wordnet": {
"baseline": "3.0",
Expand Down
5 changes: 5 additions & 0 deletions versions/w-/woff2.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "1a8e802f8168798c4171f8384cd2e50b97af3a9b",
"version-string": "1.0.2",
"port-version": 1
},
{
"git-tree": "c39668ee425b3e9bb5ead506876f144656acf359",
"version-string": "1.0.2",
Expand Down