Made es-pdf-convert work on macOS

This commit is contained in:
Leon Styhre 2023-06-24 23:58:33 +02:00
parent 2412193ad3
commit bb9eee2692
5 changed files with 214 additions and 9 deletions

View file

@ -263,6 +263,7 @@ elseif(APPLE)
# to compensate for this. It's a bad solution to the problem and there must surely be a
# better way to fix this.
install(TARGETS EmulationStation RUNTIME DESTINATION ../MacOS)
install(TARGETS es-pdf-convert RUNTIME DESTINATION ../MacOS)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/assets/EmulationStation-DE.icns DESTINATION ../Resources)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/assets/EmulationStation-DE_Info.plist DESTINATION .. RENAME Info.plist)
@ -288,10 +289,22 @@ elseif(APPLE)
PERMISSIONS ${APPLE_DYLIB_PERMISSIONS} DESTINATION ../MacOS)
install(FILES ${CMAKE_SOURCE_DIR}/libvorbisenc.2.0.12.dylib
PERMISSIONS ${APPLE_DYLIB_PERMISSIONS} DESTINATION ../MacOS)
install(FILES ${CMAKE_SOURCE_DIR}/libfontconfig.1.dylib
PERMISSIONS ${APPLE_DYLIB_PERMISSIONS} DESTINATION ../MacOS)
install(FILES ${CMAKE_SOURCE_DIR}/libfreetype.6.dylib
PERMISSIONS ${APPLE_DYLIB_PERMISSIONS} DESTINATION ../MacOS)
install(FILES ${CMAKE_SOURCE_DIR}/libgit2.1.6.dylib
PERMISSIONS ${APPLE_DYLIB_PERMISSIONS} DESTINATION ../MacOS)
install(FILES ${CMAKE_SOURCE_DIR}/libjpeg.62.dylib
PERMISSIONS ${APPLE_DYLIB_PERMISSIONS} DESTINATION ../MacOS)
install(FILES ${CMAKE_SOURCE_DIR}/libopenjp2.7.dylib
PERMISSIONS ${APPLE_DYLIB_PERMISSIONS} DESTINATION ../MacOS)
install(FILES ${CMAKE_SOURCE_DIR}/libpoppler-cpp.0.dylib
PERMISSIONS ${APPLE_DYLIB_PERMISSIONS} DESTINATION ../MacOS)
install(FILES ${CMAKE_SOURCE_DIR}/libpoppler.129.dylib
PERMISSIONS ${APPLE_DYLIB_PERMISSIONS} DESTINATION ../MacOS)
install(FILES ${CMAKE_SOURCE_DIR}/libtiff.6.dylib
PERMISSIONS ${APPLE_DYLIB_PERMISSIONS} DESTINATION ../MacOS)
install(FILES ${CMAKE_SOURCE_DIR}/libSDL2-2.0.0.dylib
PERMISSIONS ${APPLE_DYLIB_PERMISSIONS} DESTINATION ../MacOS)

View file

@ -16,6 +16,9 @@ if(WIN32)
set(POPPLER_CPP_LIBRARY ${CMAKE_CURRENT_SOURCE_DIR}/libpoppler-cpp-0.dll)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -municode")
endif()
elseif(APPLE)
set(POPPLER_CPP_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../external/poppler/cpp ${CMAKE_CURRENT_SOURCE_DIR}/../external/poppler/build/cpp)
set(POPPLER_CPP_LIBRARY ${CMAKE_CURRENT_SOURCE_DIR}/../libpoppler-cpp.0.dylib)
else()
find_package(Poppler REQUIRED COMPONENTS cpp)
endif()

View file

@ -87,7 +87,11 @@ int main(int argc, char* argv[])
validArguments = false;
if (!validArguments) {
#if defined(APPLE)
std::cout << "This binary is only intended to be executed by EmulationStation (ES-DE)"
#else
std::cout << "This binary is only intended to be executed by emulationstation (ES-DE)"
#endif
<< std::endl;
exit(-1);
}

View file

@ -15,7 +15,7 @@
export MACOSX_DEPLOYMENT_TARGET=10.14
# How many CPU threads to use for the compilation.
JOBS=4
JOBS=8
if [ ! -f .clang-format ]; then
echo "You need to run this script from the root of the repository."
@ -52,6 +52,7 @@ make -j${JOBS}
make install
cd ..
echo
echo "\nBuilding FreeType"
if [ ! -d freetype/build ]; then
@ -64,9 +65,101 @@ rm -f CMakeCache.txt
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_DISABLE_FIND_PACKAGE_HarfBuzz=on -DBUILD_SHARED_LIBS=on -DCMAKE_MACOSX_RPATH=on -DCMAKE_INSTALL_PREFIX=$(pwd)/../../local_install -S .. -B .
make clean
make -j${JOBS}
cp libfreetype.6.18.3.dylib ../../../libfreetype.6.dylib
cp libfreetype.6.19.0.dylib ../../../libfreetype.6.dylib
cd ../..
echo
echo "Building Fontconfig"
if [ ! -d fontconfig ]; then
echo "fontconfig directory is missing, aborting."
exit
fi
cd fontconfig
rm -rf builddir
meson setup --buildtype=release --prefix $(pwd)/../local_install builddir
cd builddir
meson compile
meson install
cp src/libfontconfig.1.dylib ../../../
cd ../..
echo
echo "Building libjpeg-turbo"
if [ ! -d libjpeg-turbo ]; then
echo "libjpeg-turbo directory is missing, aborting."
exit
fi
cd libjpeg-turbo/build
rm -f CMakeCache.txt
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$(pwd)/../../local_install -B . -S ..
make clean
make -j${JOBS}
make install
cp libjpeg.62.4.0.dylib ../../../libjpeg.62.dylib
cd ../..
echo
echo "Building LibTIFF"
if [ ! -d libtiff ]; then
echo "libtiff directory is missing, aborting."
exit
fi
cd libtiff/build
rm -f CMakeCache.txt
cmake -DCMAKE_BUILD_TYPE=Release -Dtiff-tools=off -Dtiff-tests=off -Dtiff-contrib=off -Dtiff-docs=off -DCMAKE_INSTALL_PREFIX=$(pwd)/../../local_install -B . -S ..
make clean
make -j${JOBS}
make install
cp libtiff/libtiff.6.0.1.dylib ../../../libtiff.6.dylib
cd ../..
echo
echo "Building OpenJPEG"
if [ ! -d openjpeg ]; then
echo "openjpeg directory is missing, aborting."
exit
fi
cd openjpeg/build
rm -f CMakeCache.txt
PKG_CONFIG_PATH=$(pwd)/../local_install/lib/pkgconfig cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$(pwd)/../../local_install -S .. -B .
make clean
make -j${JOBS}
make install
cp bin/libopenjp2.2.5.0.dylib ../../../libopenjp2.7.dylib
cd ../..
echo
echo "Building Poppler"
if [ ! -d poppler ]; then
echo "poppler directory is missing, aborting."
exit
fi
cd poppler/build
rm -f CMakeCache.txt
PKG_CONFIG_PATH=$(pwd)/../local_install/lib/pkgconfig cmake -S .. -B . -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=$(pwd)/../../local_install -DENABLE_UTILS=off -DBUILD_CPP_TESTS=off -DENABLE_LIBCURL=off \
-DRUN_GPERF_IF_PRESENT=off -DENABLE_QT5=off -DENABLE_QT6=off -DENABLE_BOOST=off -DENABLE_GLIB=off -DENABLE_NSS3=off
make clean
make -j${JOBS}
# This will fail if there are spaces in the build path.
install_name_tool -change $(otool -L libpoppler.129.dylib | grep libfreetype | cut -f1 -d' ' | sed 's/[[:blank:]]//g') @rpath/libfreetype.6.dylib libpoppler.129.dylib
install_name_tool -change $(otool -L libpoppler.129.dylib | grep libfontconfig | cut -f1 -d' ' | sed 's/[[:blank:]]//g') @rpath/libfontconfig.1.dylib libpoppler.129.dylib
cp libpoppler.129.0.0.dylib ../../../libpoppler.129.dylib
cp cpp/libpoppler-cpp.0.11.0.dylib ../../../libpoppler-cpp.0.dylib
cd ../..
echo
echo "\nBuilding FreeImage"
if [ ! -d freeimage/FreeImage ]; then
@ -80,6 +173,7 @@ make -j${JOBS}
cp libfreeimage.a ../../..
cd ../..
echo
echo "\nBuilding libgit2"
if [ ! -d libgit2/build ]; then
@ -92,9 +186,10 @@ rm -f CMakeCache.txt
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=OFF ..
make clean
make -j${JOBS}
cp libgit2.1.6.3.dylib ../../../libgit2.1.6.dylib
cp libgit2.1.6.4.dylib ../../../libgit2.1.6.dylib
cd ../..
echo
echo "\nBuilding pugixml"
if [ ! -d pugixml ]; then
@ -110,6 +205,7 @@ make -j${JOBS}
cp libpugixml.a ../..
cd ..
echo
echo "\nBuilding SDL"
if [ ! -d SDL/build ]; then
@ -125,6 +221,7 @@ make -j${JOBS}
cp libSDL2-2.0.0.dylib ../../..
cd ../..
echo
echo "\nBuilding libvpx"
if [ ! -d libvpx ]; then
@ -133,12 +230,13 @@ if [ ! -d libvpx ]; then
fi
cd libvpx
./configure --disable-examples --disable-docs --enable-pic --enable-vp9-highbitdepth --prefix=$(pwd)/../local_install
./configure --disable-examples --disable-docs --disable-tools --disable-unit-tests --enable-pic --enable-vp9-highbitdepth --prefix=$(pwd)/../local_install
make clean
make -j${JOBS}
make install
cd ..
echo
echo "\nBuilding Ogg"
if [ ! -d ogg ]; then
@ -154,6 +252,7 @@ make -j${JOBS}
make install
cd ..
echo
echo "\nBuilding Vorbis"
if [ ! -d vorbis ]; then
@ -171,6 +270,7 @@ cp lib/libvorbisenc.2.0.12.dylib ../..
cp lib/libvorbis.0.4.9.dylib ../..
cd ..
echo
echo "\nBuilding Opus"
if [ ! -d opus ]; then
@ -186,6 +286,7 @@ make -j${JOBS}
make install
cd ..
echo
echo "\nBuilding FFmpeg"
if [ ! -d FFmpeg ]; then

View file

@ -32,9 +32,10 @@ fi
mv code libpng
cd libpng
git checkout v1.6.38
git checkout v1.6.40
cd ..
echo
echo "\nSetting up FreeType"
rm -rf freetype
git clone https://github.com/freetype/freetype.git
@ -45,10 +46,85 @@ if [ ! -d freetype ]; then
fi
cd freetype
git checkout VER-2-12-1
git checkout VER-2-13-0
mkdir build
cd ..
echo
echo "Setting up Fontconfig"
rm -rf fontconfig
git clone https://gitlab.freedesktop.org/fontconfig/fontconfig.git
if [ ! -d fontconfig ]; then
echo "fontconfig directory is missing, aborting."
exit
fi
cd fontconfig
git checkout 2.14.2
cd ..
echo
echo "Setting up libjpeg-turbo"
rm -rf libjpeg-turbo
git clone https://github.com/libjpeg-turbo/libjpeg-turbo.git
if [ ! -d libjpeg-turbo ]; then
echo "libjpeg-turbo directory is missing, aborting."
exit
fi
cd libjpeg-turbo
git checkout 2.1.91
mkdir build
cd ..
echo
echo "Setting up LibTIFF"
rm -rf libtiff
git clone https://gitlab.com/libtiff/libtiff.git
if [ ! -d libtiff ]; then
echo "libtiff directory is missing, aborting."
exit
fi
cd libtiff
git checkout v4.5.1
mkdir build
cd ..
echo
echo "Setting up OpenJPEG"
rm -rf openjpeg
git clone https://github.com/uclouvain/openjpeg.git
if [ ! -d openjpeg ]; then
echo "openjpeg directory is missing, aborting."
exit
fi
cd openjpeg
git checkout v2.5.0
mkdir build
cd ..
echo
echo "Setting up Poppler"
rm -rf poppler
git clone https://gitlab.freedesktop.org/poppler/poppler.git
if [ ! -d poppler ]; then
echo "poppler directory is missing, aborting."
exit
fi
cd poppler
git checkout poppler-23.06.0
mkdir build
cd ..
echo
echo "\nSetting up FreeImage"
rm -rf freeimage
mkdir freeimage
@ -164,6 +240,7 @@ EOF
fi
cd ../..
echo
echo "\nSetting up libgit2"
rm -rf libgit2
git clone https://github.com/libgit2/libgit2.git
@ -174,10 +251,11 @@ if [ ! -d libgit2 ]; then
fi
cd libgit2
git checkout v1.6.3
git checkout v1.6.4
mkdir build
cd ..
echo
echo "\nSetting up pugixml"
rm -rf pugixml
git clone https://github.com/zeux/pugixml.git
@ -188,9 +266,10 @@ if [ ! -d pugixml ]; then
fi
cd pugixml
git checkout v1.12.1
git checkout v1.13
cd ..
echo
echo "\nSetting up SDL"
rm -rf SDL
git clone https://github.com/libsdl-org/SDL.git
@ -206,6 +285,7 @@ ln -s include SDL2
mkdir build
cd ..
echo
echo "\nSetting up libvpx"
rm -rf libvpx
git clone https://github.com/webmproject/libvpx.git
@ -216,9 +296,10 @@ if [ ! -d libvpx ]; then
fi
cd libvpx
git checkout v1.12.0
git checkout v1.13.0
cd ..
echo
echo "\nSetting up Ogg"
rm -rf ogg
git clone https://github.com/xiph/ogg.git
@ -232,6 +313,7 @@ cd ogg
git checkout v1.3.5
cd ..
echo
echo "\nSetting up Vorbis"
rm -rf vorbis
git clone https://gitlab.xiph.org/xiph/vorbis.git
@ -245,6 +327,7 @@ cd vorbis
git checkout v1.3.7
cd ..
echo
echo "\nSetting up Opus"
rm -rf opus
git clone https://gitlab.xiph.org/xiph/opus.git
@ -258,6 +341,7 @@ cd opus
git checkout v1.3.1
cd ..
echo
echo "\nSetting up FFmpeg"
rm -rf FFmpeg
git clone https://github.com/FFmpeg/FFmpeg.git