我想为 IMAP 消息创建一个 mime / multipart 解析器。我有几个链接说mimetic可以做到这一点,但我无法为 iOS 编译它。任何帮助将不胜感激。
问问题
510 次
2 回答
2
请查找适用于 iOS 的模拟 C++ 库的更新构建脚本。
#!/bin/bash
echo "$(tput setaf 2)"
echo "###################################################################"
echo "# Preparing to build libmimetic"
echo "###################################################################"
echo "$(tput sgr0)"
JOBS=$(sysctl -n hw.logicalcpu)
# The results will be stored relative to the location
# where you stored this script, **not** relative to
# the location of the protobuf git repo.
PREFIX=`pwd`/libmimetic
if [ -d ${PREFIX} ]
then
rm -rf "${PREFIX}"
fi
mkdir -p "${PREFIX}/platform"
# A "YES" value will build the latest code from GitHub on the master branch.
# A "NO" value will use the tarball downloaded from ...
USE_GIT_MASTER=NO
MIMETIC_GIT_DIRNAME=mimetic
MIMETIC_VERSION=0.9.8
MIMETIC_RELEASE_URL=http://www.codesink.org/download/mimetic-${MIMETIC_VERSION}.tar.gz
MIMETIC_RELEASE_DIRNAME=mimetic-${MIMETIC_VERSION}
LIBMIMETIC=libmimetic
BUILD_MACOSX_X86_64=YES
BUILD_I386_IOSSIM=YES
BUILD_X86_64_IOSSIM=YES
BUILD_IOS_ARMV7=YES
BUILD_IOS_ARMV7S=YES
BUILD_IOS_ARM64=YES
MIMETIC_SRC_DIR=/tmp/mimetic
DARWIN=darwin`uname -r`
XCODEDIR=`xcode-select --print-path`
IOS_SDK_VERSION=`xcrun --sdk iphoneos --show-sdk-version`
MIN_SDK_VERSION=6.0
MACOSX_PLATFORM=${XCODEDIR}/Platforms/MacOSX.platform
MACOSX_SYSROOT=${MACOSX_PLATFORM}/Developer/SDKs/MacOSX10.10.sdk
IPHONEOS_PLATFORM=`xcrun --sdk iphoneos --show-sdk-platform-path`
IPHONEOS_SYSROOT=`xcrun --sdk iphoneos --show-sdk-path`
IPHONESIMULATOR_PLATFORM=`xcrun --sdk iphonesimulator --show-sdk-platform-path`
IPHONESIMULATOR_SYSROOT=`xcrun --sdk iphonesimulator --show-sdk-path`
# Uncomment if you want to see more information about each invocation
# of clang as the builds proceed.
# CLANG_VERBOSE="--verbose"
CC="xcrun clang"
CXX="xcrun clang"
CFLAGS="${CLANG_VERBOSE} -DNDEBUG -g -O0 -pipe -fPIC -fcxx-exceptions"
CXXFLAGS="${CLANG_VERBOSE} ${CFLAGS} -std=c++11 -stdlib=libc++"
LDFLAGS="-stdlib=libc++"
LIBS="-lc++ -lc++abi"
echo "PREFIX ..................... ${PREFIX}"
echo "USE_GIT_MASTER ............. ${USE_GIT_MASTER}"
echo "MIMETIC_GIT_DIRNAME ....... ${MIMETIC_GIT_DIRNAME}"
echo "MIMETIC_VERSION ........... ${MIMETIC_VERSION}"
echo "MIMETIC_RELEASE_URL ....... ${MIMETIC_RELEASE_URL}"
echo "MIMETIC_RELEASE_DIRNAME ... ${MIMETIC_RELEASE_DIRNAME}"
echo "BUILD_MACOSX_X86_64 ........ ${BUILD_MACOSX_X86_64}"
echo "BUILD_I386_IOSSIM .......... ${BUILD_I386_IOSSIM}"
echo "BUILD_X86_64_IOSSIM ........ ${BUILD_X86_64_IOSSIM}"
echo "BUILD_IOS_ARMV7 ............ ${BUILD_IOS_ARMV7}"
echo "BUILD_IOS_ARMV7S ........... ${BUILD_IOS_ARMV7S}"
echo "BUILD_IOS_ARM64 ............ ${BUILD_IOS_ARM64}"
echo "MIMETIC_SRC_DIR ........... ${MIMETIC_SRC_DIR}"
echo "DARWIN ..................... ${DARWIN}"
echo "XCODEDIR ................... ${XCODEDIR}"
echo "IOS_SDK_VERSION ............ ${IOS_SDK_VERSION}"
echo "MIN_SDK_VERSION ............ ${MIN_SDK_VERSION}"
echo "MACOSX_PLATFORM ............ ${MACOSX_PLATFORM}"
echo "MACOSX_SYSROOT ............. ${MACOSX_SYSROOT}"
echo "IPHONEOS_PLATFORM .......... ${IPHONEOS_PLATFORM}"
echo "IPHONEOS_SYSROOT ........... ${IPHONEOS_SYSROOT}"
echo "IPHONESIMULATOR_PLATFORM ... ${IPHONESIMULATOR_PLATFORM}"
echo "IPHONESIMULATOR_SYSROOT .... ${IPHONESIMULATOR_SYSROOT}"
echo "CC ......................... ${CC}"
echo "CFLAGS ..................... ${CFLAGS}"
echo "CXX ........................ ${CXX}"
echo "CXXFLAGS ................... ${CXXFLAGS}"
echo "LDFLAGS .................... ${LDFLAGS}"
echo "LIBS ....................... ${LIBS}"
while true; do
read -p "Proceed with build? (y/n) " yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
echo "$(tput setaf 2)"
echo "###################################################################"
echo "# Fetch Mimetic"
echo "###################################################################"
echo "$(tput sgr0)"
(
if [ -d ${MIMETIC_SRC_DIR} ]
then
rm -rf ${MIMETIC_SRC_DIR}
fi
cd `dirname ${MIMETIC_SRC_DIR}`
if [ -d ${MIMETIC_RELEASE_DIRNAME} ]
then
rm -rf "${MIMETIC_RELEASE_DIRNAME}"
fi
curl --location ${MIMETIC_RELEASE_URL} --output ${MIMETIC_RELEASE_DIRNAME}.tar.gz
tar xvf ${MIMETIC_RELEASE_DIRNAME}.tar.gz
mv "${MIMETIC_RELEASE_DIRNAME}" "${MIMETIC_SRC_DIR}"
rm ${MIMETIC_RELEASE_DIRNAME}.tar.gz
cd ${MIMETIC_SRC_DIR}
sed -i '' '/test\/Makefile/d' configure.in
sed -i '' '/test win32/ c\
SUBDIRS = mimetic
' /tmp/mimetic/Makefile.in
)
echo "$(tput setaf 2)"
echo "###################################################################"
echo "# x86_64 for Mac OS X"
echo "###################################################################"
echo "$(tput sgr0)"
if [ "${BUILD_MACOSX_X86_64}" == "YES" ]
then
(
cd ${MIMETIC_SRC_DIR}
make distclean
./configure --disable-shared --prefix=${PREFIX} --exec-prefix=${PREFIX}/platform/x86_64-mac "CC=${CC}" "CFLAGS=${CFLAGS} -arch x86_64" "CXX=${CXX}" "CXXFLAGS=${CXXFLAGS} -arch x86_64" "LDFLAGS=${LDFLAGS}" "LIBS=${LIBS}"
make -j${JOBS}
# make check
make install
)
fi
MIMETICC=${PREFIX}/platform/x86_64-mac/bin/mimetic
###################################################################
# This section contains the build commands for each of the
# architectures that will be included in the universal binaries.
###################################################################
echo "$(tput setaf 2)"
echo "###########################"
echo "# i386 for iPhone Simulator"
echo "###########################"
echo "$(tput sgr0)"
if [ "${BUILD_I386_IOSSIM}" == "YES" ]
then
(
cd ${MIMETIC_SRC_DIR}
make distclean
./configure --build=x86_64-apple-${DARWIN} --host=i386-apple-${DARWIN} --disable-shared --prefix=${PREFIX} --exec-prefix=${PREFIX}/platform/i386-sim "CC=${CC}" "CFLAGS=${CFLAGS} -miphoneos-version-min=${MIN_SDK_VERSION} -arch i386 -isysroot ${IPHONESIMULATOR_SYSROOT}" "CXX=${CXX}" "CXXFLAGS=${CXXFLAGS} -arch i386 -isysroot ${IPHONESIMULATOR_SYSROOT}" LDFLAGS="-arch i386 -miphoneos-version-min=${MIN_SDK_VERSION} ${LDFLAGS}" "LIBS=${LIBS}"
make -j${JOBS}
make install
)
fi
echo "$(tput setaf 2)"
echo "#############################"
echo "# x86_64 for iPhone Simulator"
echo "#############################"
echo "$(tput sgr0)"
if [ "${BUILD_X86_64_IOSSIM}" == "YES" ]
then
(
cd ${MIMETIC_SRC_DIR}
make distclean
./configure --build=x86_64-apple-${DARWIN} --host=x86_64-apple-${DARWIN} --disable-shared --prefix=${PREFIX} --exec-prefix=${PREFIX}/platform/x86_64-sim "CC=${CC}" "CFLAGS=${CFLAGS} -miphoneos-version-min=${MIN_SDK_VERSION} -arch x86_64 -isysroot ${IPHONESIMULATOR_SYSROOT}" "CXX=${CXX}" "CXXFLAGS=${CXXFLAGS} -arch x86_64 -isysroot ${IPHONESIMULATOR_SYSROOT}" LDFLAGS="-arch x86_64 -miphoneos-version-min=${MIN_SDK_VERSION} ${LDFLAGS}" "LIBS=${LIBS}"
make -j${JOBS}
make install
)
fi
echo "$(tput setaf 2)"
echo "##################"
echo "# armv7 for iPhone"
echo "##################"
echo "$(tput sgr0)"
if [ "${BUILD_IOS_ARMV7}" == "YES" ]
then
(
cd ${MIMETIC_SRC_DIR}
make distclean
./configure --build=x86_64-apple-${DARWIN} --host=armv7-apple-${DARWIN} --disable-shared --prefix=${PREFIX} --exec-prefix=${PREFIX}/platform/armv7-ios "CC=${CC}" "CFLAGS=${CFLAGS} -miphoneos-version-min=${MIN_SDK_VERSION} -arch armv7 -isysroot ${IPHONEOS_SYSROOT}" "CXX=${CXX}" "CXXFLAGS=${CXXFLAGS} -arch armv7 -isysroot ${IPHONEOS_SYSROOT}" LDFLAGS="-arch armv7 -miphoneos-version-min=${MIN_SDK_VERSION} ${LDFLAGS}" "LIBS=${LIBS}"
make -j${JOBS}
make install
)
fi
echo "$(tput setaf 2)"
echo "###################"
echo "# armv7s for iPhone"
echo "###################"
echo "$(tput sgr0)"
if [ "${BUILD_IOS_ARMV7S}" == "YES" ]
then
(
cd ${MIMETIC_SRC_DIR}
make distclean
./configure --build=x86_64-apple-${DARWIN} --host=armv7s-apple-${DARWIN} --disable-shared --prefix=${PREFIX} --exec-prefix=${PREFIX}/platform/armv7s-ios "CC=${CC}" "CFLAGS=${CFLAGS} -miphoneos-version-min=${MIN_SDK_VERSION} -arch armv7s -isysroot ${IPHONEOS_SYSROOT}" "CXX=${CXX}" "CXXFLAGS=${CXXFLAGS} -arch armv7s -isysroot ${IPHONEOS_SYSROOT}" LDFLAGS="-arch armv7s -miphoneos-version-min=${MIN_SDK_VERSION} ${LDFLAGS}" "LIBS=${LIBS}"
make -j${JOBS}
make install
)
fi
echo "$(tput setaf 2)"
echo "##################"
echo "# arm64 for iPhone"
echo "##################"
echo "$(tput sgr0)"
if [ "${BUILD_IOS_ARM64}" == "YES" ]
then
(
cd ${MIMETIC_SRC_DIR}
make distclean
./configure --build=x86_64-apple-${DARWIN} --host=arm --disable-shared --prefix=${PREFIX} --exec-prefix=${PREFIX}/platform/arm64-ios "CC=${CC}" "CFLAGS=${CFLAGS} -miphoneos-version-min=${MIN_SDK_VERSION} -arch arm64 -isysroot ${IPHONEOS_SYSROOT}" "CXX=${CXX}" "CXXFLAGS=${CXXFLAGS} -arch arm64 -isysroot ${IPHONEOS_SYSROOT}" LDFLAGS="-arch arm64 -miphoneos-version-min=${MIN_SDK_VERSION} ${LDFLAGS}" "LIBS=${LIBS}"
make -j${JOBS}
make install
)
fi
echo "$(tput setaf 2)"
echo "###################################################################"
echo "# Create Universal Libraries and Finalize the packaging"
echo "###################################################################"
echo "$(tput sgr0)"
(
cd ${PREFIX}/platform
mkdir universal
lipo x86_64-sim/lib/${LIBMIMETIC}.a i386-sim/lib/${LIBMIMETIC}.a arm64-ios/lib/${LIBMIMETIC}.a armv7s-ios/lib/${LIBMIMETIC}.a armv7-ios/lib/${LIBMIMETIC}.a -create -output universal/${LIBMIMETIC}.a
)
(
cd ${PREFIX}
mkdir bin
mkdir lib
cp -r platform/x86_64-mac/lib/* lib
cp -r platform/universal/* lib
rm -rf platform
lipo -info lib/${LIBMIMETIC}.a
)
if [ -d "${PREFIX}-${MIMETIC_VERSION}" ]
then
rm -rf "${PREFIX}-${MIMETIC_VERSION}"
fi
mv "${PREFIX}" "${PREFIX}-${MIMETIC_VERSION}"
echo Done!
由 freenode irc 中#iphonedev 的 ytain 提供。
于 2015-02-16T21:45:01.393 回答
2
这是旧帖子。但也许它会帮助某人
我如何在我的项目(shell 脚本)中构建 mimetic。
# Building mimetic
pushd mimetic
# i368
export CC="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc"
export CXX="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-g++"
export AR="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/ar"
export CFLAGS="-pipe -miphoneos-version-min=4.0 -fpascal-strings -fmessage-length=0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.0.sdk -arch i386 -O2 -fPIC -DDARWIN_NO_CARBON -Wall -W"
export CXXFLAGS="-pipe -miphoneos-version-min=4.0 -fpascal-strings -fmessage-length=0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.0.sdk -arch i386 -O2 -fPIC -DDARWIN_NO_CARBON -Wall -W"
mkdir build_i386
pushd build_i386
../configure -prefix=`pwd`
make clean
pushd mimetic
make || exit 1
make install
popd
popd
# armv7
export CC="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-gcc"
export CXX="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-g++"
export AR="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ar"
export CFLAGS="-pipe -miphoneos-version-min=4.0 -fpascal-strings -fmessage-length=0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk -arch armv7 -mthumb -O2 -fPIC -Wall -W -DDARWIN_NO_CARBON -D__ARM_ARCH_7__ -D__MARM_THUMB__ -D__ARM_NEON__"
export CXXFLAGS="-pipe -miphoneos-version-min=4.0 -fpascal-strings -fmessage-length=0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk -arch armv7 -mthumb -O2 -fPIC -Wall -W -DDARWIN_NO_CARBON -D__ARM_ARCH_7__ -D__MARM_THUMB__ -D__ARM_NEON__"
mkdir build_armv7
pushd build_armv7
../configure --host=i386 --prefix=`pwd`
make clean
pushd mimetic
make || exit 1
make install
popd
popd
# bundle
lipo build_i386/lib/libmimetic.a build_armv7/lib/libmimetic.a -create -output libmimetic.a
popd
于 2013-06-01T21:26:16.887 回答