带有依赖关系的打包软件 - 我应该走多远?

时间:2016-12-09 17:40:39

标签: macos packaging external-dependencies

我正在开发一个跨平台的软件,并希望将其作为zip包发布。

对于Linux,我不打包依赖包,对于Windows,我也在包中分发dll。

对于Mac OS X,我有一个脚本可以递归地将所有dylib文件复制到build文件夹并更改链接。

当然,这会导致我不应该打包的文件列表,例如libsystem_malloc.dyliblibremovefile.dylib

我应该选择安装在/usr/local/*中的dylib还是有其他系统的方法来不包含每个OS X安装中可用的文件?

依赖项的大多数(好的,现在都是)是Homebrew个包,如果有帮助的话。

对于任何感兴趣的人,这是用于递归复制和重新链接的bash代码:

while true; do
    INSTALLED=0
    for dylib in *.dylib; do
        LIBS=`otool -L $dylib`
        if [ "x$LIBS" != "x" ]; then
            echo "$dylib is using:"
            for lib in $LIBS{@:2}; do
                if echo $lib | grep --quiet 'dylib$'; then
                    echo "    $lib"
                    new_lib=`echo $lib | sed 's|.*/\(.*\.dylib\)|\1|'`
                    if [ -e  $PD_APP_LIB/$new_lib ]; then
                        echo "$PD_APP_LIB/$new_lib already exists, skipping copy."
                    else
                        install -vp $lib $PD_APP_LIB
                        INSTALLED=1
                    fi
                    install_name_tool -id @loader_path/$new_lib $PD_APP_LIB/$new_lib
                    install_name_tool -change $lib @loader_path/$new_lib $dylib
                fi
            done
            echo " "
        fi
    done
    if [ $INSTALLED -eq 0 ]; then
        break
    fi
done

1 个答案:

答案 0 :(得分:0)

目前,我只从/usr/local/打包库,脚本是:

while true; do
    INSTALLED=0
    for dylib in *.dylib; do
        LIBS=`otool -L $dylib`
        if [ "x$LIBS" != "x" ]; then
            echo "$dylib is using:"
            for lib in $LIBS{@:2}; do
                # The following line has been changed
                if echo $lib | grep --quiet '^/usr/local/.*dylib$'; then
                    echo "    $lib"
                    new_lib=`echo $lib | sed 's|.*/\(.*\.dylib\)|\1|'`
                    if [ -e  $PD_APP_LIB/$new_lib ]; then
                        echo "$PD_APP_LIB/$new_lib already exists, skipping copy."
                    else
                        install -vp $lib $PD_APP_LIB
                        INSTALLED=1
                    fi
                    install_name_tool -id @loader_path/$new_lib $PD_APP_LIB/$new_lib
                    install_name_tool -change $lib @loader_path/$new_lib $dylib
                fi
            done
            echo " "
        fi
    done
    if [ $INSTALLED -eq 0 ]; then
        break
    fi
done