Skip to content

Commit

Permalink
FreeType fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
danoli3 committed Dec 9, 2024
1 parent d2a574d commit fab5acc
Showing 1 changed file with 39 additions and 49 deletions.
88 changes: 39 additions & 49 deletions apothecary/formulas/freetype/freetype.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,27 @@ FORMULA_DEPENDS=( "zlib" "libpng" "brotli" )

# define the version
VER=2.13.3
# BUILD=1
# FVER=213
# BUILD_ID=1
# DEFINES=""
BUILD_ID=1
DEFINES=""

#GIT_VER=VER-2-13-3
GIT_VER=master
GIT_VER="VER-${VER//./-}"

# tools for git use
# GIT_URL=https://git.savannah.gnu.org/r/freetype/freetype2.git
GIT_URL=https://gitlab.freedesktop.org/freetype/freetype
# GIT_TAG=VER-2-13
# URL=http://download.savannah.nongnu.org/releases/freetype
# MIRROR_URL=https://mirror.ossplanet.net/nongnu/freetype
# GIT_HUB=https://github.com/freetype/freetype/tags
# GIT_HUB_URL=https://github.com/freetype/freetype/archive/refs/tags/VER-2-13-2.tar.gz
# GIT_HUB_URL=https://gitlab.freedesktop.org/freetype/freetype/-/archive/${GIT_VER}/freetype-${GIT_VER}.tar.gz
GIT_TAG="VER-${VER%.*}"
GIT_HUB=https://github.com/freetype/freetype/tags
URL="https://github.com/freetype/freetype/archive/refs/tags/${GIT_VER}.tar.gz"
GIT_URL="https://github.com/freetype/freetype"

# download the source code and unpack it into LIB_NAME
function download() {
echo "Downloading freetype-$GIT_VER"

# git clone --branch $GIT_TAG --depth=1 $GIT_URL
git clone --depth=1 $GIT_URL

# echo "GIT_HUB_URL ${GIT_HUB_URL}"
# echo "DOWN ${DOWNLOADER_SCRIPT}"
# . "$DOWNLOADER_SCRIPT" downloader $GIT_HUB_URL

# tar -xzf freetype-$GIT_VER.tar.gz
# mv freetype-$GIT_VER freetype
# rm freetype-$GIT_VER*.tar.gz
. "$DOWNLOADER_SCRIPT"
downloader $URL

tar -xzf $GIT_VER.tar.gz
mv freetype-$GIT_VER freetype
rm $GIT_VER*.tar.gz
}

# prepare the build environment, executed inside the lib src dir
Expand All @@ -56,15 +45,15 @@ function prepare() {
# executed inside the lib src dir
function build() {
LIBS_ROOT=$(realpath $LIBS_DIR)
DEFS="
DEFINES="
-DCMAKE_C_STANDARD=${C_STANDARD} \
-DCMAKE_CXX_STANDARD=${CPP_STANDARD} \
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
-DCMAKE_CXX_EXTENSIONS=OFF \
-DCMAKE_INCLUDE_OUTPUT_DIRECTORY=include \
-DCMAKE_INSTALL_INCLUDEDIR=include"
if [[ "$TYPE" =~ ^(osx|ios|tvos|xros|catos|watchos)$ ]]; then

mkdir -p "build_${TYPE}_${PLATFORM}"
cd "build_${TYPE}_${PLATFORM}"
rm -f CMakeCache.txt *.a *.o
Expand All @@ -75,7 +64,7 @@ function build() {

LIBPNG_ROOT="$LIBS_ROOT/libpng/"
LIBPNG_INCLUDE_DIR="$LIBS_ROOT/libpng/include"
LIBPNG_LIBRARY="$LIBS_ROOT/libpng/lib/$TYPE/$PLATFORM/libpng.a"
LIBPNG_LIBRARY="$LIBS_ROOT/libpng/lib/$TYPE/$PLATFORM/libpng.a"

LIBBROTLI_ROOT="$LIBS_ROOT/brotli/"
LIBBROTLI_INCLUDE_DIR="$LIBS_ROOT/brotli/include"
Expand Down Expand Up @@ -116,7 +105,7 @@ function build() {
-DCMAKE_INSTALL_PREFIX=Release \
-DBUILD_SHARED_LIBS=OFF"

cmake .. ${DEFS} \
cmake .. ${DEFINES} \
${EXTRA_DEFS} \
-DCMAKE_PREFIX_PATH="${LIBS_ROOT}" \
-DCMAKE_INCLUDE_PATH="$LIBBROTLI_INCLUDE_DIR;$LIBPNG_INCLUDE_DIR;$ZLIB_INCLUDE_DIR" \
Expand All @@ -131,12 +120,12 @@ function build() {
-DENABLE_VISIBILITY=OFF \
-DCMAKE_VERBOSE_MAKEFILE=${VERBOSE_MAKEFILE} \
-DCMAKE_POSITION_INDEPENDENT_CODE=TRUE

cmake --build . --config Release --target install
cd ..
cd ..

elif [ "$TYPE" == "vs" ] ; then

echo "building $TYPE | $ARCH | $VS_VER | vs: $VS_VER_GEN"
echo "--------------------"
GENERATOR_NAME="Visual Studio ${VS_VER_GEN}"
Expand All @@ -151,11 +140,11 @@ function build() {

ZLIB_ROOT="$LIBS_ROOT/zlib/"
ZLIB_INCLUDE_DIR="$LIBS_ROOT/zlib/include"
ZLIB_LIBRARY="$LIBS_ROOT/zlib/lib/$TYPE/$PLATFORM/zlib.lib"
ZLIB_LIBRARY="$LIBS_ROOT/zlib/lib/$TYPE/$PLATFORM/zlib.lib"

LIBPNG_ROOT="$LIBS_ROOT/libpng/"
LIBPNG_INCLUDE_DIR="$LIBS_ROOT/libpng/include"
LIBPNG_LIBRARY="$LIBS_ROOT/libpng/lib/$TYPE/$PLATFORM/libpng.lib"
LIBPNG_LIBRARY="$LIBS_ROOT/libpng/lib/$TYPE/$PLATFORM/libpng.lib"

LIBBROTLI_ROOT="$LIBS_ROOT/brotli/"
LIBBROTLI_INCLUDE_DIR="$LIBS_ROOT/brotli/include"
Expand All @@ -165,7 +154,7 @@ function build() {
LIBBROTLI_DEC_LIB="$LIBBROTLI_LIBRARY/brotlidec.lib"

export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:${PKG_CONFIG_PATH};${LIBPNG_ROOT}/lib/$TYPE/$PLATFORM;${ZLIB_ROOT}/lib/$TYPE/$PLATFORM;${LIBBROTLI_ROOT}/lib/$TYPE/$PLATFORM"

BROTLI="
-DFT_REQUIRE_BROTLI=ON \
-DFT_DISABLE_BROTLI=OFF"
Expand Down Expand Up @@ -199,7 +188,7 @@ function build() {
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG=lib \
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG=bin"
env CXXFLAGS="-DUSE_PTHREADS=1 ${VS_C_FLAGS} ${FLAGS_RELEASE} ${EXCEPTION_FLAGS}"
cmake .. ${DEFS} \
cmake .. ${DEFINES} \
${EXTRA_DEFS} \
-DCMAKE_VERBOSE_MAKEFILE=${VERBOSE_MAKEFILE} \
-D BUILD_SHARED_LIBS=OFF \
Expand All @@ -226,10 +215,10 @@ function build() {
-DBROTLI_INCLUDE_DIR=${LIBBROTLI_INCLUDE_DIR} \
-DBROTLI_INCLUDE_DIRS=${LIBBROTLI_INCLUDE_DIR} \
-DBROTLIDEC_LIBRARIES="${LIBBROTLI_LIBRARY};${LIBBROTLI_ENC_LIB};${LIBBROTLI_DEC_LIB}"
cmake --build . --config Release --target install
cmake --build . --config Release --target install

env CXXFLAGS="-DUSE_PTHREADS=1 ${VS_C_FLAGS} ${FLAGS_DEBUG} ${EXCEPTION_FLAGS}"
cmake .. ${DEFS} \
cmake .. ${DEFINES} \
-DCMAKE_VERBOSE_MAKEFILE=${VERBOSE_MAKEFILE} \
-D BUILD_SHARED_LIBS=OFF \
${CMAKE_WIN_SDK} \
Expand Down Expand Up @@ -274,7 +263,7 @@ function build() {
cd build_$TYPE
rm -f CMakeCache.txt *.a *.o
cmake .. \
${DEFS} \
${DEFINES} \
-DCMAKE_SYSTEM_NAME=$TYPE \
-DCMAKE_SYSTEM_PROCESSOR=$ABI \
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
Expand All @@ -299,7 +288,7 @@ function build() {
cd build_$TYPE
rm -f CMakeCache.txt *.a *.o
cmake .. \
${DEFS} \
${DEFINES} \
-D FT_REQUIRE_ZLIB=ON \
-D FT_DISABLE_BZIP2=ON \
-D FT_REQUIRE_HARFBUZZ=OFF \
Expand Down Expand Up @@ -340,9 +329,10 @@ function build() {
fi

EXTRA_DEFS="
-DFT_DISABLE_BROTLI=${NO_LINK_BROTLI}
-DFT_DISABLE_BROTLI=${NO_LINK_BROTLI}
"
cmake -D CMAKE_TOOLCHAIN_FILE=${NDK_ROOT}/build/cmake/android.toolchain.cmake \
cmake ${DEFINES} \
-D CMAKE_TOOLCHAIN_FILE=${NDK_ROOT}/build/cmake/android.toolchain.cmake \
-D CMAKE_OSX_SYSROOT:PATH=${SYSROOT} \
-D CMAKE_C_COMPILER=${CC} \
-D CMAKE_CXX_COMPILER_RANLIB=${RANLIB} \
Expand Down Expand Up @@ -392,9 +382,9 @@ function build() {
LIBPNG_ROOT="${LIBS_ROOT}/libpng/"
LIBPNG_INCLUDE_DIR="${LIBS_ROOT}/libpng/include"
LIBPNG_LIBRARY="$LIBS_ROOT/libpng/lib/${TYPE}/${PLATFORM}/libpng16.a"

export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:${PKG_CONFIG_PATH}:${LIBPNG_ROOT}/lib/$TYPE/$PLATFORM:${ZLIB_ROOT}/lib/$TYPE/$PLATFORM"

pkg-config --modversion libpng

BROTLI="
Expand All @@ -405,7 +395,7 @@ function build() {
rm -f CMakeCache.txt *.a *.o *.a
export PATH="${PATH}:${LIBPNG_INCLUDE_DIR}"
$EMSDK/upstream/emscripten/emcmake cmake .. \
${DEFS} \
${DEFINES} \
${BROTLI} \
-DCMAKE_PREFIX_PATH="${LIBS_ROOT}" \
-DZLIB_ROOT=${ZLIB_ROOT} \
Expand Down Expand Up @@ -442,7 +432,7 @@ function build() {
-DCMAKE_LIBRARY_PATH="${LIBPNG_LIBRARY}:${ZLIB_LIBRARY}" \
-DBUILD_SHARED_LIBS=OFF \
-B . \
-G 'Unix Makefiles'
-G 'Unix Makefiles'

# cat CMakeCache.txt
# cat Makefile
Expand Down Expand Up @@ -522,19 +512,19 @@ function clean() {

if [ "$TYPE" == "vs" ] ; then
if [ -d "build_${TYPE}_${ARCH}" ]; then
rm -r build_${TYPE}_${ARCH}
rm -r build_${TYPE}_${ARCH}
fi
elif [ "$TYPE" == "android" ] ; then
if [ -d "build_${TYPE}_${ABI}" ]; then
rm -r build_${TYPE}_${ABI}
rm -r build_${TYPE}_${ABI}
fi
elif [[ "$TYPE" =~ ^(osx|ios|tvos|xros|catos|watchos)$ ]]; then
if [ -d "build_${TYPE}_${PLATFORM}" ]; then
rm -r build_${TYPE}_${PLATFORM}
rm -r build_${TYPE}_${PLATFORM}
fi
elif [ "$TYPE" == "emscripten" ] ; then
if [ -d "build_${TYPE}" ]; then
rm -r build_${TYPE}
rm -r build_${TYPE}
fi
else
rm -f CMakeCache.txt *.a *.o *.lib
Expand Down

1 comment on commit fab5acc

@dimitre
Copy link
Member

@dimitre dimitre commented on fab5acc Dec 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @danoli3 I've just fixed VS2022 ARMEC issue here with the previous commit.
here is the action completing
https://github.com/openframeworks/openFrameworks/actions/runs/12218984776/job/34106802117

Please sign in to comment.