Skip to content

Commit

Permalink
harfbuzz: don't compile support for unused APIs
Browse files Browse the repository at this point in the history
Example code size reduction for release builds:
- `android-arm64`: -78.7 KB
- `emu-x86_64`: -149.5 KB
- `kindlepw2`: -94.2 KB
  • Loading branch information
benoit-pierre committed Jan 12, 2025
1 parent e90843f commit d0b9334
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion thirdparty/harfbuzz/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,31 @@ list(APPEND CFG_CMD COMMAND
${SOURCE_DIR}
)

list(APPEND DEFINES
HB_DISABLE_DEPRECATED
HB_NO_BUFFER_MESSAGE
HB_NO_BUFFER_SERIALIZE
HB_NO_COLOR
HB_NO_LAYOUT_COLLECT_GLYPHS
HB_NO_LAYOUT_RARELY_USED
HB_NO_LAYOUT_UNUSED
HB_NO_META
HB_NO_PAINT
HB_NO_STYLE
)

# We've apparently hit a weird corner-case w/ XText where GCC/STL atomics *sometimes* horribly blow up on an ARM1136JF-S CPU w/ GCC 7.5 & up...
# c.f., https://github.com/koreader/koreader/issues/5780 & https://github.com/koreader/koreader/issues/6024
# NOTE: Our initial approach was to only disable atomics in a very dirty manner, which only helped with the first issue.
# This, on the other hand, appears to help with both.
if(LEGACY OR POCKETBOOK)
list(APPEND CFG_CMD COMMAND ${ISED} "$a#define HB_NO_MT" config.h)
list(APPEND DEFINES HB_NO_MT)
endif()

list(TRANSFORM DEFINES REPLACE "(.+)" "-e;$a#define \\1")

list(APPEND CFG_CMD COMMAND ${ISED} "$a/* KOReader Tweaks */" ${DEFINES} config.h)

list(APPEND BUILD_CMD COMMAND ninja)

list(APPEND INSTALL_CMD COMMAND ${MESON_INSTALL})
Expand Down

0 comments on commit d0b9334

Please sign in to comment.