Skip to content

Commit

Permalink
refactor makefiles, use boost installer, refactor cmake invocation
Browse files Browse the repository at this point in the history
  • Loading branch information
thomastrapp committed Oct 17, 2024
1 parent 639e7da commit 0bd2ba5
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 22 deletions.
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@ em_flags = -std=c++17 \
-Wno-switch-enum \
-Wno-weak-vtables \
-Wno-missing-prototypes \
-Wno-unsafe-buffer-usage \
--bind \
./wrapper/hext-emscripten.cpp \
-I./build-dep/include \
./build-dep/lib/libhext.a \
./build-dep/lib/libgumbo.a \
-I./build-dep/boost/include \
-I./build-dep/gumbo/include \
-I./build-dep/libhext/include \
./build-dep/libhext/lib/libhext.a \
./build-dep/gumbo/lib/libgumbo.a \
-s MODULARIZE=1 \
-s EXPORT_NAME="loadHext" \
-s SINGLE_FILE=1 \
Expand Down
16 changes: 11 additions & 5 deletions Makefile.boost
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ BOOST_SHA256=2575e74ffc3ef1cd0babac2c1ee8bdb5782a0ee672b1912da40e5b4b591ca01f

boost: build/boost_${BOOST_VERSION}.tar.gz \
build/boost_${BOOST_VERSION} \
build-dep/include/boost
build-dep/boost/include

build/boost_${BOOST_VERSION}.tar.gz:
cd build && \
Expand All @@ -18,11 +18,17 @@ build/boost_${BOOST_VERSION}:
echo '${BOOST_SHA256} boost_${BOOST_VERSION}.tar.gz' | sha256sum -c && \
tar xf boost_${BOOST_VERSION}.tar.gz

build-dep/include/boost:
mkdir -p build-dep/include
cp -rf build/boost_${BOOST_VERSION}/boost build-dep/include/
# Install Boost with its installer. This also creates the CMake config files, which are needed because newer
# versions of CMake no longer ship their own FindBoost module.
# Boost.System isn't actually needed. Boost.System is installed here, because Boost doesn't have an option to
# only install the header-only libraries.
build-dep/boost/include:
mkdir -p "${BASE}/build-dep/boost" && \
cd "build/boost_${BOOST_VERSION}" && \
./bootstrap.sh --prefix="${BASE}/build-dep/boost" --with-libraries=system && \
./b2 install

clean:
rm -rf build-dep/include/boost
rm -rf build-dep/boost
rm -rf build/boost_*

8 changes: 4 additions & 4 deletions Makefile.gumbo
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ BASE=${PWD}
all: build/v0.10.1.tar.gz build/gumbo-parser-0.10.1 \
build/gumbo-parser-0.10.1/configure \
build/gumbo-parser-0.10.1/Makefile \
build-dep/lib/libgumbo.a
build-dep/gumbo/lib/libgumbo.a

build/v0.10.1.tar.gz:
cd build && wget https://github.com/google/gumbo-parser/archive/v0.10.1.tar.gz
Expand All @@ -21,15 +21,15 @@ build/gumbo-parser-0.10.1/configure:
build/gumbo-parser-0.10.1/Makefile:
cd build/gumbo-parser-0.10.1 && \
emconfigure ./configure \
--prefix=${BASE}/build-dep \
--prefix=${BASE}/build-dep/gumbo \
--enable-static --disable-shared

build-dep/lib/libgumbo.a:
build-dep/gumbo/lib/libgumbo.a:
cd build/gumbo-parser-0.10.1 && \
emmake make install

clean:
rm -f build-dep/lib/libgumbo.a
rm -rf build-dep/gumbo
rm -rf build/v0.10.1.tar.gz
rm -rf build/gumbo-parser-0.10.1

22 changes: 12 additions & 10 deletions Makefile.libhext
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ BASE=${PWD}

all: build/v${VERSION}.tar.gz \
build/hext-${VERSION} \
build-dep/lib/libhext.a
build-dep/libhext/lib/libhext.a

build/v${VERSION}.tar.gz:
cd build && \
Expand All @@ -16,25 +16,27 @@ build/hext-${VERSION}:
echo '${SHA256} v${VERSION}.tar.gz' | sha256sum -c && \
tar xf v${VERSION}.tar.gz

build-dep/lib/libhext.a:
# CMAKE_PREFIX_PATH is ignored, unless CMAKE_FIND_ROOT_PATH_MODE_{LIBRARY,INCLUDE,PACKAGE}
# are set to "BOTH". If unset, the emscripten toolchain module sets them to "ONLY", breaking
# CMAKE_PREFIX_PATH.
build-dep/libhext/lib/libhext.a:
cd build/hext-${VERSION}/libhext/build && \
emcmake cmake \
CMAKE_PREFIX_PATH="${BASE}/build-dep/boost:${BASE}/build-dep/gumbo" emcmake cmake \
-DCMAKE_AR=$(shell which emar) \
-DCMAKE_RANLIB=$(shell which emranlib) \
-DCMAKE_MAKE_PROGRAM=$(shell which emmake) \
-DCMAKE_C_COMPILER=$(shell which emcc) \
-DCMAKE_CXX_COMPILER=$(shell which em++) \
-DGumbo_LIBRARY=${BASE}/build-dep/lib/libgumbo.a \
-DGumbo_INCLUDE_DIR=${BASE}/build-dep/include \
-DBoost_INCLUDE_DIR=${BASE}/build-dep/include \
-DBoost_LIBRARY_DIR=${BASE}/build-dep/lib \
-DCMAKE_FIND_ROOT_PATH=${BASE}/build-dep/lib/cmake \
-DCMAKE_INSTALL_PREFIX=${BASE}/build-dep \
-DCMAKE_INSTALL_PREFIX="${BASE}/build-dep/libhext" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=BOTH \
-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=BOTH \
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH \
.. && \
emmake make install VERBOSE=1

clean:
rm -f build-dep/lib/libhext.a
rm -rf build-dep/libhext
rm -rf build/v${VERSION}.tar.gz
rm -rf build/hext-${VERSION}

0 comments on commit 0bd2ba5

Please sign in to comment.