Skip to content

Commit ebcc6a1

Browse files
committed
make: use regular install for brotli
The last released version of brotli we use, blocks the install target when building with emscripten, which is why we currently need to manually copy files of interest to their installed location. This adds complexity and is prone to failure with future changes. Upstream no longer blocks installations with emscripten since google/brotli@ce222e3 from 23.06.2021. We could just bump the brotli version to latest master, but then our already existing patch would need updating and from a quick look it appears as if other things changed as well which might not all be compatible with our baseline target out of the box. AN eventual new release with release notes will hopefully detail the changes in a more accessible form. As a safe option, just backport the upstream commit as another patch. We still need to normalise the static library names though.
1 parent 1ad1434 commit ebcc6a1

2 files changed

Lines changed: 85 additions & 21 deletions

File tree

Makefile

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -70,29 +70,22 @@ build/lib/brotli/configured: lib/brotli $(wildcard $(BASE_DIR)build/patches/brot
7070
$(foreach file, $(wildcard $(BASE_DIR)build/patches/brotli/*.patch), patch -d "$(BASE_DIR)build/lib/brotli" -Np1 -i $(file) && ) true
7171
touch build/lib/brotli/configured
7272

73-
build/lib/brotli/libbrotlidec.pc: build/lib/brotli/configured
73+
$(DIST_DIR)/lib/libbrotlidec.a: $(DIST_DIR)/lib/libbrotlicommon.a
74+
$(DIST_DIR)/lib/libbrotlicommon.a: build/lib/brotli/configured
7475
cd build/lib/brotli && \
75-
emcmake cmake \
76-
-DCMAKE_C_FLAGS=" \
77-
$(GLOBAL_CFLAGS) \
78-
" \
79-
-DCMAKE_INSTALL_PREFIX=$(DIST_DIR) \
80-
. \
81-
&& \
82-
emmake make -j8 && \
83-
cp -r ./c/include $(DIST_DIR)
84-
85-
$(DIST_DIR)/lib/libbrotlicommon.a: build/lib/brotli/libbrotlidec.pc
86-
cd build/lib/brotli && \
87-
mkdir -p $(DIST_DIR)/lib/pkgconfig && \
88-
cp libbrotlicommon.pc $(DIST_DIR)/lib/pkgconfig && \
89-
cp libbrotlicommon-static.a $(DIST_DIR)/lib/libbrotlicommon.a
76+
emcmake cmake \
77+
-DCMAKE_C_FLAGS=" \
78+
$(GLOBAL_CFLAGS) \
79+
" \
80+
-DCMAKE_INSTALL_PREFIX=$(DIST_DIR) \
81+
. \
82+
&& \
83+
emmake make -j8 && \
84+
emmake make install
85+
# Normalise static lib names
86+
cd $(DIST_DIR)/lib/ && \
87+
for lib in *-static.a ; do mv "$$lib" "$${lib%-static.a}.a" ; done
9088

91-
$(DIST_DIR)/lib/libbrotlidec.a: build/lib/brotli/libbrotlidec.pc $(DIST_DIR)/lib/libbrotlicommon.a
92-
cd build/lib/brotli && \
93-
mkdir -p $(DIST_DIR)/lib/pkgconfig && \
94-
cp libbrotlidec.pc $(DIST_DIR)/lib/pkgconfig && \
95-
cp libbrotlidec-static.a $(DIST_DIR)/lib/libbrotlidec.a
9689

9790
# Freetype without Harfbuzz
9891
build/lib/freetype/build_hb/dist_hb/lib/libfreetype.a: $(DIST_DIR)/lib/libbrotlidec.a $(wildcard $(BASE_DIR)build/patches/freetype/*.patch)
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
Backported from: https://github.com/google/brotli/commit/ce222e317e36aa362e83fc50c7a6226d238e03fd
2+
From: Dirk Lemstra <dirk@lemstra.org>
3+
Date: Wed, 23 Jun 2021 10:12:21 +0200
4+
Subject: [PATCH] Enabled install when building with emscripten. (#906)
5+
6+
* Enabled install when building with emscripten.
7+
8+
* Also install the pkg-config files.
9+
---
10+
CMakeLists.txt | 18 ++++++++----------
11+
1 file changed, 8 insertions(+), 10 deletions(-)
12+
13+
diff --git a/CMakeLists.txt b/CMakeLists.txt
14+
index 4ff3401..6999292 100644
15+
--- a/CMakeLists.txt
16+
+++ b/CMakeLists.txt
17+
@@ -219,19 +219,20 @@ add_executable(brotli ${BROTLI_CLI_C})
18+
target_link_libraries(brotli ${BROTLI_LIBRARIES_STATIC})
19+
20+
# Installation
21+
-if(NOT BROTLI_EMSCRIPTEN)
22+
if(NOT BROTLI_BUNDLED_MODE)
23+
install(
24+
TARGETS brotli
25+
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
26+
)
27+
28+
- install(
29+
- TARGETS ${BROTLI_LIBRARIES_CORE}
30+
- ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
31+
- LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
32+
- RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
33+
- )
34+
+ if(NOT BROTLI_EMSCRIPTEN)
35+
+ install(
36+
+ TARGETS ${BROTLI_LIBRARIES_CORE}
37+
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
38+
+ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
39+
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
40+
+ )
41+
+ endif() # BROTLI_EMSCRIPTEN
42+
43+
install(
44+
TARGETS ${BROTLI_LIBRARIES_CORE_STATIC}
45+
@@ -245,7 +246,6 @@ if(NOT BROTLI_BUNDLED_MODE)
46+
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
47+
)
48+
endif() # BROTLI_BUNDLED_MODE
49+
-endif() # BROTLI_EMSCRIPTEN
50+
51+
# Tests
52+
53+
@@ -405,7 +405,6 @@ transform_pc_file("scripts/libbrotlidec.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/libb
54+
55+
transform_pc_file("scripts/libbrotlienc.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/libbrotlienc.pc" "${BROTLI_VERSION}")
56+
57+
-if(NOT BROTLI_EMSCRIPTEN)
58+
if(NOT BROTLI_BUNDLED_MODE)
59+
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libbrotlicommon.pc"
60+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
61+
@@ -414,7 +413,6 @@ if(NOT BROTLI_BUNDLED_MODE)
62+
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libbrotlienc.pc"
63+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
64+
endif() # BROTLI_BUNDLED_MODE
65+
-endif() # BROTLI_EMSCRIPTEN
66+
67+
if (ENABLE_COVERAGE STREQUAL "yes")
68+
SETUP_TARGET_FOR_COVERAGE(coverage test coverage)
69+
--
70+
2.30.2
71+

0 commit comments

Comments
 (0)