tools/copydlldeps: multiCall + case insensitivity

pull/1318/merge
Lars 8 years ago committed by Tony Theodore
parent 6f830ee8f2
commit 73ae658c4a

@ -10,7 +10,7 @@ It can be invoked on the command line like:
--recursivesrcdir /home/mxeuser/mxe/usr/i686-w64-mingw32.shared/ \
--srcdir /home/mxeuser/test/ \
--copy \
--enforce /home/mxeuser/mxe/usr/i686-w64-mingw32.shared/qt5/plugins/platforms/ \
--enforcedir /home/mxeuser/mxe/usr/i686-w64-mingw32.shared/qt5/plugins/platforms/ \
--objdump /home/mxeuser/mxe/usr/bin/i686-w64-mingw32.shared-objdump
```
@ -38,7 +38,7 @@ if [ ! $( echo $compiler | grep -q "shared" ) ]; then
$MXEPATH/tools/copydlldeps.sh --infile $executable \
--destdir "$sharedLibsDir" \
--recursivesrcdir "$MXEPATH/usr/$compiler/" \
--enforce "$MXEPATH/usr/$compiler/qt5/plugins/platforms/" \
--enforcedir "$MXEPATH/usr/$compiler/qt5/plugins/platforms/" \
--copy \
--objdump "$OBJDUMP" \
| tee -a $CURLOG
@ -54,11 +54,11 @@ I checked if there is a mxe objdump. If not, I took the native one on my server.
I actually do not know the difference but decided to include it in the script
in case it is important to someone.
enforce
-------
enforcedir
----------
My application is using Qt5 and objdump did not return the needed qwindows.dll -
so I enforce the platform folder. You may add multiple --enforce directories using
`--enforce /path/folder1 --enforce /path/folder2 --enforce /path/folder3`.
so I enforce the platform folder. You may add multiple --enforcedir directories using
`--enforcedir /path/folder1 --enforcedir /path/folder2 --enforcedir /path/folder3`.
They are NOT recursively copied, only flat. See:

@ -10,7 +10,7 @@ Welcome to $( basename $0)!
Authors: Lars Holger Engelhard - DL5RCW (2016)
Tiancheng "Timothy" Gu (2014)
Version: 1.0
Version: 1.1
# This file is part of the MXE Project, sponsored by the named authors
# it supports the shared build approach by providing an easy way to
@ -70,23 +70,24 @@ Operating modes:
-p, --print print dependencies (no copy action)
Operating options:
-d, --destdir Destination directory
-f, --infile The input executable file or DLL.
-F, --infiles, --indir The input directory of executable files and/or DLLs.
-d, --destdir Destination directory - a single destination folder
-f, --infile [ multiCall ] The input executable file or DLL.
-F, --infiles, --indir [ multiCall ] The input directory of executable files and/or DLLs.
-s, --srcdir [ multiCall ] The directory with DLLs that can be copied.
-S, --srcdirs [ multiCall ] List of directories with DLLs that can be copied. Put "" around them, e.g. "/dir1 /root/dir2 /root/dir3"
-R, --recursivesrcdir [ multiCall ] Target directory for recursive search of folders containing *dll files
Optional binary settings:
-o, --objdump Specify the path or name of your objdump application
-e, --enforce Enforce executable files and/or DLLs of a specific directory
-e, --enforcedir [ multiCall ] Enforce executable files and/or DLLs of a specific directory
It will be entirely copied - flat, non recursive. assumes *.dll and *.exe in the top level directory
It will copy those into a directory in DESTDIR!
e.g. <path_to_mxe>/mxe/usr/<compiler>/qt5/plugins/platforms/ - for qwindows.dll becomes
DESTDIR/platforms/ containing qwindows.dll
Other options:
-h,-H, --help Display this message and exit
-v,-V, --version Display version of this application
-l,-L, --logLevel Display more output - default is 1
-l,-L, --loglevel Display more output - default is 1
multiCall => you can specify this option multiple times!
@ -113,7 +114,7 @@ findAllSrcDirectories(){
ar_recursiveDirList=${!1}
string=""
for curPath in "${ar_recursiveDirList[@]}"; do
for element in $(find $curPath -name "*.dll"); do
for element in $(find $curPath -iname "*.dll"); do
#ar_list+="$(dirname $element) "
string+="$(dirname $element) "
done
@ -128,11 +129,11 @@ while [ $# -gt 0 ]; do
case $key in
-f|--infile)
infile="$1"
infile+=" $1"
shift
;;
-F|--indir|--infiles)
indir="$1"
indir+=" $1"
shift
;;
-s|--srcdir)
@ -155,12 +156,12 @@ while [ $# -gt 0 ]; do
OBJDUMP="$1"
shift
;;
-e|--enforce)
enforce+=" $1"
-e|--enforcedir)
enforcedir+=" $1"
shift
;;
-l|-L|--logLevel)
logLevel="$1"
-l|-L|--loglevel)
loglevel="$1"
shift
;;
-p|--print)
@ -182,8 +183,8 @@ while [ $# -gt 0 ]; do
;;
esac
done
if ! [ "$logLevel" ]; then
logLevel=0
if ! [ "$loglevel" ]; then
loglevel=0
fi
if ! [ "$opmode" ]; then
@ -191,24 +192,9 @@ if ! [ "$opmode" ]; then
#opmode="print" # used as default in development
fi
if [ "$indir" ] && [ "$infile" ]; then
die '--indir and --infile are mutually exclusive.'
elif ! [ "$indir" ] && ! [ "$infile" ]; then
die 'Neither --indir nor --infile is specified.'
fi
if ! [ "$destdir" ]; then
die '--destdir is not specified.'
fi
if ! ([ "$srcdir" ] || [ "$srcdirs" ] || [ "$recursivesrcdir" ]); then
die 'either --srcdir or --srcdirs or --recursivesrcdir must be specified.'
fi
if [ "$indir" ]; then
filelist=`find $indir -iregex '.*\(dll\|exe\)' | tr '\n' ' '`
else
filelist="$infile"
fi
if [ -n "$(ls -A $destdir 2>/dev/null)" ]; then
echo 'Warning: --destdir already exists and contains files.' >&2
@ -217,12 +203,32 @@ else
echo "info: created --destdir $destdir"
fi
if [ "$logLevel" -gt 1 ]; then
if [ "$loglevel" -gt 1 ]; then
echo "filelist=$filelist"
echo "opmode=$opmode"
fi
ar_srcDirList=()
str_inputFileList=""
if [ "$indir" ]; then
for curPath in $( echo "${indir}" | tr -s ' ' | tr ' ' '\n' ); do
curList=$( find $curPath -iregex '.*\(dll\|exe\)' | tr '\n' ' ' )
str_inputFileList+=" $curList"
done
fi
if [ "$infile" ]; then
for curFile in $( echo "${infile}" | tr -s ' ' | tr ' ' '\n' ); do
curString=$( find $curFile -iregex '.*\(dll\|exe\)' | tr '\n' ' ' )
str_inputFileList+=" $curString"
done
fi
if [ -z "$str_inputFileList" ]; then
die 'there was no input defined. use --indir and/or --infile in your command'
fi
if [ "$loglevel" -gt 1 ]; then
echo "str_inputFileList=$str_inputFileList"
echo "opmode=$opmode"
fi
str_srcDirList=""
if [ "$srcdir" ]; then
str_srcDirList+=" $srcdir"
@ -234,24 +240,28 @@ if [ "$recursivesrcdir" ]; then
result="$( findAllSrcDirectories recursivesrcdir )"
str_srcDirList+=" $result"
fi
if [ "$logLevel" -gt 1 ]; then
echo "infiles: filelist=$filelist"
if [ -z "$str_srcDirList" ]; then
die 'there was no source directory defined. use --srcdirs or --srcdir or --recursivesrcdir in your command'
fi
if [ "$loglevel" -gt 1 ]; then
#echo "infiles: filelist=$filelist"
echo "infiles: str_inputFileList=$str_inputFileList"
echo " opmode: $opmode"
fi
if [ "$logLevel" -gt 1 ]; then
if [ "$loglevel" -gt 1 ]; then
echo "list for sources: str_srcDirList=${str_srcDirList}"
echo "using OBJDUMP=$OBJDUMP in Version $( $OBJDUMP -V)"
fi
if [ "$logLevel" -gt 1 ]; then
if [ "$loglevel" -gt 1 ]; then
## during development, I like to interrupt here to check the above output and skip the rest
echo "starting in 5 seconds" && sleep 5
fi
# function to append dependencies (recursively)
append_deps() {
if [ "$logLevel" -gt 1 ]; then
if [ "$loglevel" -gt 1 ]; then
echo "\$1=$1 + \$2=$2 "
sleep 2
fi
@ -265,12 +275,12 @@ append_deps() {
path=""
for curPath in $( echo "${str_srcDirList}" | tr -s ' ' | tr ' ' '\n' ); do
counter=0
result=$(find $curPath -name "$bn" | tail -n 1)
result=$(find $curPath -iname "$bn" | tail -n 1)
if [ ! -z $result ];then
path=$result
counter=$(expr $counter + 1)
fi
if [ "$logLevel" -gt 1 ]; then
if [ "$loglevel" -gt 1 ]; then
if [ $counter == 0 ]; then
echo "could not find \$path for dll $bn, \$counter=$counter: searched $curPath"
else
@ -278,14 +288,14 @@ append_deps() {
fi
fi
done
if [ "$logLevel" -gt 1 ]; then
if [ "$loglevel" -gt 1 ]; then
echo "path for dll $bn now is $path"
sleep 2
fi
fi
echo "Processing $1" >&2
if ! [ -e "$path" ]; then
if [ "$logLevel" -gt 1 ]; then
if [ "$loglevel" -gt 1 ]; then
echo "path=$path| and we touch $tmp/$bn -> non existent in our src directories!"
sleep 4
fi
@ -304,7 +314,7 @@ process_enforced_deps(){
enforcedDirectory=$1
if [ ! -d $enforcedDirectory ]; then
echo "warning! \$enforcedDirectory=$enforcedDirectory is not valid"
if [ "$logLevel" -gt 1 ]; then
if [ "$loglevel" -gt 1 ]; then
sleep 10
fi
fi
@ -313,7 +323,7 @@ process_enforced_deps(){
str_srcDirList+=" $enforcedDirectory"
# now we search for the dll and exe files to be included
string=$( find $enforcedDirectory -maxdepth 1 -iregex '.*\(dll\|exe\)' | tr '\n' ' ' )
if [ "$logLevel" -gt 1 ]; then
if [ "$loglevel" -gt 1 ]; then
echo "enforcedDirectory=$enforcedDirectory"
echo "we found dlls and exes:$string"
sleep 4
@ -324,16 +334,17 @@ process_enforced_deps(){
# beginning of the main function
# we start with the enforced dlls and exe
if [ ! -z $enforce ]; then
for curFile in $enforce; do
echo "startig for file $curFile"
if [ ! -z "$enforcedir" ]; then
for curFile in $( echo "${enforcedir}" | tr -s ' ' | tr ' ' '\n'); do
echo "startig for file $curFile in enforce section"
append_deps "$curFile" rel
process_enforced_deps "$curFile"
done
fi
# then we start with our indir or infile list
for file in $filelist; do
#for file in $filelist; do
for file in $str_inputFileList; do
echo "starting for file $file"
#sleep 4
append_deps "$file" rel
@ -343,15 +354,15 @@ echo "I will now search for \$alldeps"
for debugOut in $( echo $alldeps | tr -s ' ' | tr '\n' ' '); do
echo "debugOut: $debugOut"
done
if [ "$logLevel" -eq 1 ]; then
if [ "$loglevel" -eq 1 ]; then
echo "waiting 10 seconds until I proceed - so you can read my debugOut"
sleep 10
tmpStr=${str_srcDirList}
echo "\$alldeps has ${#alldeps[@]} elements"
echo "and \$str_srcDirList has ${#str_srcDirList} elements"
echo "waiting another 10 seconds"
#sleep 10
#echo "waiting another 2 seconds"
#sleep 2
fi
for dll in `echo $alldeps | tr '\n' ' '`; do
@ -361,7 +372,7 @@ for dll in `echo $alldeps | tr '\n' ' '`; do
lower_dll=""
fi
for curFolder in $( echo "${str_srcDirList}" | tr -s ' ' | tr ' ' '\n'); do
if [ "$logLevel" -gt 1 ]; then
if [ "$loglevel" -gt 1 ]; then
echo "search for dll $dll in curFolder $curFolder"
sleep 1
fi

Loading…
Cancel
Save