Skip to content

Commit

Permalink
improve deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Dec 19, 2015
1 parent a185733 commit 2e06bd3
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 55 deletions.
100 changes: 56 additions & 44 deletions qtc_packaging/ifw/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


BUILD=$1
QTBIN=`grep QT_BIN $BUILD/.qmake.cache |head -n 1 |cut -d "=" -f 2 | tr -d ' '`
QTBIN=`grep QT_BIN $BUILD/.qmake.cache |head -n 1 |cut -d "=" -f 2 | tr -d ' '`
# for windows
QTBIN=`echo /$QTBIN|sed 's,:,,'`
export PATH=$QTBIN:$PWD/../../tools:$PATH
Expand Down Expand Up @@ -79,15 +79,22 @@ mkdir -p $TARGET/packages/com.qtav.product/data/
### runtime
echo "coping runtime files..."
RT_DIR=$TARGET/packages/com.qtav.product.runtime
declare -a QTMODULES=(Core Gui OpenGL Widgets Qml Quick Network Svg) #TODO: use readelf, objdump or otool to get depends
host_is Linux && QTMODULES+=(DBus)
cp -af $BUILD/bin/* $RT_DIR/data/bin
cat > $RT_DIR/data/bin/qt.conf <<EOF
[Paths]
Prefix=.
EOF
declare -a QTMODULES=(Core Gui OpenGL Widgets Qml Quick Network Svg) #TODO: use readelf, objdump or otool to get depends
host_is Linux && QTMODULES+=(DBus)
cp -af $BUILD/bin/* $RT_DIR/data/bin

QTRT=`qmake -query QT_INSTALL_LIBS`
host_is MinGW || host_is MSYS && QTRT=`$QTBIN/qmake -query QT_INSTALL_BINS`
host_is MinGW || host_is MSYS && {
QTRT=`$QTBIN/qmake -query QT_INSTALL_BINS`
test -f $QTRT/libEGL.dll && cp -af $QTRT/libEGL.dll $RT_DIR/data/bin
test -f $QTRT/libGLESv2.dll && cp -af $QTRT/libGLESv2.dll $RT_DIR/data/bin
test -f $QTRT/d3dcompiler_47.dll && cp -af $QTRT/d3dcompiler_47.dll $RT_DIR/data/bin
}

for m in ${QTMODULES[@]}; do
RT_DLL=`qt5lib_name ${m}`
test -L $RT_DLL/data/bin/$RT_DLL && rm -rf $RT_DLL/data/bin/$RT_DLL
Expand All @@ -97,15 +104,22 @@ done
QTPLUGIN=`qmake -query QT_INSTALL_PLUGINS`
QTQML=`qmake -query QT_INSTALL_QML`
cp -af $QTPLUGIN/{imageformats,platform*} $RT_DIR/data/bin/plugins
# find dir -name "*d.dll" -o -name "*.pdb" -delete fail, why?
cp -af $QTQML/{Qt,QtQml,QtQuick,QtQuick.2} $RT_DIR/data/bin/qml
rm -f $RT_DIR/data/bin/plugins/platforms/{*mini*,*offscreen*,*eglfs*,*linuxfb*,*kms*}
rm -f $RT_DIR/data/bin/plugins/imageformats/{*dds*,*icns*,*tga*,*tiff*,*wbmp*,*webp*}
find $RT_DIR/data/bin -name "*.pdb" -delete
find $RT_DIR/data/bin/qml -name "*plugind.dll" -delete
find $RT_DIR/data/bin/plugins -name "*d.dll" -delete #qml: *plugind.dll
find $RT_DIR/data/bin -name "*.exp" -delete
find $RT_DIR/data/bin -name "*.lib" -delete

##ffmpegs
## QtAV, Qt5AV
LIBQTAV=$LIBDIR/`lib_name "Qt*AV" 1`
LIBQTAV=$LIBDIR/`lib_name "Qt*AV" ${QTAV_VER_MAJOR}`
echo "LIBQTAV=$LIBQTAV"
cp -Lf $LIBQTAV $RT_DIR/data/bin
LIBQTAVWIDGETS=$LIBDIR/`lib_name "Qt*AVWidgets" 1`
LIBQTAVWIDGETS=$LIBDIR/`lib_name "Qt*AVWidgets" ${QTAV_VER_MAJOR}`
echo "LIBQTAVWIDGETS=$LIBQTAVWIDGETS"
cp -Lf $LIBQTAVWIDGETS $RT_DIR/data/bin

Expand All @@ -132,66 +146,64 @@ elif [ -d $RT_DIR/data/bin/qml/QtAV ]; then
cp -af $RT_DIR/data/bin/qml/QtAV qml
fi
cd -

pwd
echo "coping libs..."
#mingw: libQt5AV1.a
cd $TARGET/packages/com.qtav.product.dev/data/lib
pwd
cp -af $LIBDIR/*Qt*AV* .
[ -f $LIBDIR/Qt5AV${QTAV_VER_MAJOR}.lib ] && cp -af $LIBDIR/libQt5AV${QTAV_VER_MAJOR}.lib Qt5AV.lib
[ -f $LIBDIR/libQt5AV${QTAV_VER_MAJOR}.a ] && cp -af $LIBDIR/libQt5AV${QTAV_VER_MAJOR}.a libQt5AV.a
[ -f $LIBDIR/Qt5AVWidgets${QTAV_VER_MAJOR}.lib ] && cp -af $LIBDIR/libQt5AVWidgets${QTAV_VER_MAJOR}.lib Qt5AVWidgets.lib
[ -f $LIBDIR/libQt5AVWidgets${QTAV_VER_MAJOR}.a ] && cp -af $LIBDIR/libQt5AVWidgets${QTAV_VER_MAJOR}.a libQt5AVWidgets.a
rm -f {*.dll,*.so.*,*.prl}
# no copy, just link to real file in bin for linux development
if [ -f $LIBDIR/libQt5AV.so ]; then
ln -sf ../bin/libQt5AV.so.${QTAV_VER_MAJOR} libQt5AV.so
ln -sf ../bin/libQt5AVWidgets.so.${QTAV_VER_MAJOR} libQt5AVWidgets.so
elif [ -f $LIBDIR/libQtAV.so ]; then
ln -sf ../bin/libQtAV.so.${QTAV_VER_MAJOR} libQtAV.so
ln -sf ../bin/libQtAVWidgets.so.${QTAV_VER_MAJOR} libQtAVWidgets.so
[ -f Qt5AV${QTAV_VER_MAJOR}.lib ] && cp -af Qt5AV${QTAV_VER_MAJOR}.lib Qt5AV.lib
[ -f libQt5AV${QTAV_VER_MAJOR}.a ] && ln -sf libQt5AV${QTAV_VER_MAJOR}.a libQt5AV.a
[ -f Qt5AVWidgets${QTAV_VER_MAJOR}.lib ] && cp -af Qt5AVWidgets${QTAV_VER_MAJOR}.lib Qt5AVWidgets.lib
[ -f libQt5AVWidgets${QTAV_VER_MAJOR}.a ] && ln -sf libQt5AVWidgets${QTAV_VER_MAJOR}.a libQt5AVWidgets.a
[ -f QtAV${QTAV_VER_MAJOR}.lib ] && cp -af QtAV${QTAV_VER_MAJOR}.lib Qt5AV.lib
[ -f libQtAV${QTAV_VER_MAJOR}.a ] && ln -sf libQtAV${QTAV_VER_MAJOR}.a libQt5AV.a
[ -f QtAVWidgets${QTAV_VER_MAJOR}.lib ] && cp -af QtAVWidgets${QTAV_VER_MAJOR}.lib Qt5AVWidgets.lib
[ -f libQtAVWidgets${QTAV_VER_MAJOR}.a ] && ln -sf libQtAVWidgets${QTAV_VER_MAJOR}.a libQt5AVWidgets.a
rm -f {*.dll,*.prl,*.exp}
[ -f libQtAV.so ] && ln -sf libQtAV.so libQt5AV.so
[ -f libQtAVWidgets.so ] && ln -sf libQtAVWidgets.so libQt5AVWidgets.so
cd -

# link runtime qtav and overwrite the old so
cd $RT_DIR/data/bin
if host_is Linux; then
echo "linking qtav runtime so..."
ln -sf ../lib/libQt5AV.so.${QTAV_VER_MAJOR} .
ln -sf ../lib/libQt5AVWidgets.so.${QTAV_VER_MAJOR} .
ln -sf ../lib/libQtAV.so.${QTAV_VER_MAJOR} .
ln -sf ../lib/libQtAVWidgets.so.${QTAV_VER_MAJOR} .
fi
cd -

### player
echo "coping player files..."

mv $RT_DIR/data/bin/{player${EXE},QMLPlayer${EXE}} $TARGET/packages/com.qtav.product.player/data/bin

LIBCOMMON=$RT_DIR/data/bin/`lib_name common 1`
if [ -f $LIBCOMMON ]; then
echo "moving $LIBCOMMON ..."
mv $LIBCOMMON $TARGET/packages/com.qtav.product.player/data/bin
else
LIBCOMMON=$LIBDIR/`lib_name common 1`
echo "coping $LIBCOMMON ..."
cp -Lf $LIBCOMMON $TARGET/packages/com.qtav.product.player/data/bin
fi

### examples
echo "coping examples..."
EXAMPLE_DIR=$TARGET/packages/com.qtav.product.examples
mv `find $RT_DIR/data/bin/* -maxdepth 0 -type f |grep -v "\.so" |grep -v "\.dylib" |grep -v "\.conf" |grep -v "\.dll"` $EXAMPLE_DIR/data/bin

if host_is Linux; then
echo "patch elf runpath..."
patchelf.sh $TARGET/packages/com.qtav.product.runtime/data/bin
patchelf.sh $TARGET/packages/com.qtav.product.player/data/bin
patchelf.sh $TARGET/packages/com.qtav.product.examples/data/bin
patchelf.sh $TARGET/packages/com.qtav.product.runtime/data/bin
patchelf.sh $TARGET/packages/com.qtav.product.player/data/bin
patchelf.sh $TARGET/packages/com.qtav.product.examples/data/bin
fi

find $TARGET -name "log*.txt" -delete
find $TARGET -name "*.manifest" -delete

find $TARGET -name log.txt -exec rm -f {} \;
find $TARGET -name "*.manifest" -exec rm -f {} \;
# copy simpleplayer source code
mkdir -p $EXAMPLE_DIR/data/src
cp -af ../../examples/simpleplayer $EXAMPLE_DIR/data/src
cat >$EXAMPLE_DIR/data/src/simpleplayer/simpleplayer.pro<<EOF
TEMPLATE = app
CONFIG -= app_bundle
QT += avwidgets av
HEADERS = playerwindow.h
SOURCES = playerwindow.cpp main.cpp
EOF
[ -f $EXAMPLE_DIR/data/src/simpleplayer/simpleplayer_sdk.pro ] && rm -rf $EXAMPLE_DIR/data/src/simpleplayer/simpleplayer.pro

echo "creating installer..."
if host_is MinGW || host_is MSYS; then
echo "default install dir is 'C:\QtAV'"
echo cp config/config.xml $TARGET
cp config/config.xml $TARGET
else
echo "default install dir is '$HOME/QtAV'"
Expand All @@ -204,5 +216,5 @@ type -p binarycreator || {
exit 0
}
INSTALLER=QtAV${QTAV_VER}-${TARGET}
binarycreator -c $TARGET/config.xml -p $TARGET/packages --ignore-translations -v $INSTALLER
binarycreator --offline-only -c $TARGET/config.xml -p $TARGET/packages --ignore-translations -v $INSTALLER
du -h $INSTALLER
2 changes: 1 addition & 1 deletion qtc_packaging/ifw/packages/com.qtav.product.dev/data/sdk_deploy.bat
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set ACT=%errorlevel%
@echo Input your absolute Qt folder contains bin, include, lib etc.
@echo Or drag Qt folder here
@echo Then press ENTER
@echo example: C:\Qt5.4.1\5.4\mingw32_49
@echo example: C:\Qt5.6.0\5.6\mingw492_32

set /p QTDIR=

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ help() {
check_qmake() {
[ -n "$QMAKE" ] || {
echo "Input your absolute path of qmake. Make sure the major and minor version and target architecture. That path MUST have subdir bin, include, lib, mkspecs etc."
echo "example: $HOME/Qt5.4.1/5.4/gcc_64/bin/qmake"
echo "example: $HOME/Qt5.6.0/5.6/gcc_64/bin/qmake"
read QMAKE
}
[ ! -d $QMAKE -a -x $QMAKE ] || {
Expand Down
12 changes: 6 additions & 6 deletions qtc_packaging/ifw/packages/com.qtav.product.player/meta/installscript.qs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ Component.prototype.createOperations = function()

if (installer.value("os") === "win") {
component.addOperation("CreateShortcut", "@TargetDir@/bin/player.exe", "@StartMenuDir@/QtAV.Player.lnk",
"workingDirectory=@TargetDir@/bin", "iconPath=%SystemRoot%/system32/SHELL32.dll",
"iconId=2");
"workingDirectory=@TargetDir@/bin", "iconPath=@TargetDir@/bin/player.exe",
"iconId=0");
component.addOperation("CreateShortcut", "@TargetDir@/bin/QMLPlayer.exe", "@StartMenuDir@/QtAV.Player.QML.lnk",
"workingDirectory=@TargetDir@/bin", "iconPath=%SystemRoot%/system32/SHELL32.dll",
"iconId=2");
"workingDirectory=@TargetDir@/bin", "iconPath=@TargetDir@/bin/QMLPlayer.exe",
"iconId=0");
component.addOperation("CreateShortcut", "@TargetDir@/maintenancetool.exe", "@StartMenuDir@/QtAV.Uninstall.lnk",
"workingDirectory=@TargetDir@", "iconPath=%SystemRoot%/system32/SHELL32.dll",
"iconId=2");
"workingDirectory=@TargetDir@", "iconPath=@TargetDir@/maintenancetool.exe",
"iconId=0");

//component.addOperation("Settings", "formate=native", //"path=HKEY_CURRENT_USER/SOFTWARE/Classes/*/shell/OpenWithQtAV/command", "method=set", "key=Default", "value=@TargetDir@/bin/player.exe -vo gl -f %%1");

Expand Down
22 changes: 19 additions & 3 deletions tools/patchelf.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
BINDIR=$1
echo $BINDIR

runpath() {
local exe=$1
test -n "$2" && exe=`echo $1 |sed "s,$2,,"`
[ "${exe:0:2}" = "./" ] && exe=${exe:2}
local d=`echo $exe |sed 's,[^\/],,g'`
d=`echo $d |sed 's,\/,\/..,g'`
# echo "$exe => $d"
echo "\$ORIGIN:\$ORIGIN$d/lib:\$ORIGIN$d"
}

[ -d "$BINDIR" ] || BINDIR=$PWD
qmlso=(`find $BINDIR/qml -name "*.so" -type f`)
for q in ${qmlso[@]}; do
echo patching $q
patchelf --set-rpath `runpath $q $BINDIR/` $q
done
plugins=(`find $BINDIR/plugins -name "*.so" -type f`)
for plugin in ${plugins[@]}; do
echo $plugin
patchelf --set-rpath '$ORIGIN/../../lib:$ORIGIN/../..' $plugin
for p in ${plugins[@]}; do
echo patching $p
patchelf --set-rpath `runpath $p $BINDIR/` $p
done
for qt in $BINDIR/libQt5*.so.5; do
echo patching $qt
Expand Down

0 comments on commit 2e06bd3

Please sign in to comment.