Initial commit

This commit is contained in:
alexpete
2021-03-05 11:26:34 -08:00
commit a10351f38d
27091 changed files with 5521199 additions and 0 deletions
@@ -0,0 +1,60 @@
#!/bin/bash
#
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
# this script modifies a single app, passed in, on the command line, to use @rpath dirs for Qt libs
# you are expected to pass in the executable name on the command line as the first argument
# you are expected to set QTDIR.
# it works by searching all frameworks in QtDir/lib and seeing if your app has a reference to it
# if it does, it replaces that reference with a relative-path reference instead.
NEWLIBPATH="@rpath"
ORIGINALLIBPATH=${QTDIR}/lib
if [ -z "$1" ]; then
echo "Please input the application file to modify"
exit 1
fi
if [ -z "${QTDIR}" ]; then
echo "QTDIR IS NOT SET. PLease set QTDIR to the root of your Qt platform install, usually Qt/VersionNumber/clang_64"
exit 1
fi
if [ ! -d "$QTDIR" ]; then
echo "QTDIR does not appear to point at a directory ,currently its set to ${QTDIR}"
exit 1
fi
echo changebinary_rpaths.sh: Remapping paths in $1 to be rpath instead.
# for each original framework, amend all frameworks in the target folder:
ORIGINAL_LIBS=${ORIGINALLIBPATH}/*.framework
for ORIGINAL_LIB in ${ORIGINAL_LIBS} ; do
BIN_BASE_NAME=$(basename "${ORIGINALLIBPATH}/${ORIGINAL_LIB}" .framework)
ORIGINAL_BINARY_NAME=`otool -DX "${ORIGINALLIBPATH}/${BIN_BASE_NAME}.framework/${BIN_BASE_NAME}"`
NEWTARGETID=${NEWLIBPATH}/${BIN_BASE_NAME}.framework/${BIN_BASE_NAME}
# uncomment to debug:
echo Remapping ${ORIGINAL_BINARY_NAME} ==\> ${NEWTARGETID}
# BIN_BASE_NAME now contains the name of the lib, like 'QtCore'
# ORIGINAL_BINARY_NAME now contains the full path to the binary inside the framework
# for example /Users/lawsonn/Qt/5.3/clang_64/lib/Qt5Core.framework/Versions/5/Qt5Core
# NEWTARGETID is the one to change it to
# for example, @rpath/QtCore.framework/QtCore
# replace it in the executable:
install_name_tool -change "${ORIGINAL_BINARY_NAME}" "${NEWTARGETID}" "$1"
done
# now, we need to rename the dylib's own ID to be @rpath<currentId>
MY_NAME=`otool -DX "$1"`
install_name_tool -id "${NEWLIBPATH}/${MY_NAME}" "$1"
@@ -0,0 +1,54 @@
#!/bin/bash
#
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
# Shell script to print out the various qt libraries that a Qt framework
# depends on. The libs that do not have @rpath in their name will need to
# either be copied into the app bundle and be updated to use rpath or be
# updated so that when an executable linking against them will pull in the
# rpath information and use that instead of the hardcoded lib id. The
# updateLibs.sh script will perform the necessary operations to update the lib
# to have an rpath ID and change the name of the dynamic Qt libs it depends on
# to use the rpath reference instead of a absolute path
DEBUG_PRINT=1
VERBOSE_DEBUG_PRINT=0
runInstallNameToolOn ()
{
pushd $1/Versions/Current > /dev/null
libs=$(find . -type f -depth 1)
for lib in $libs; do
lib=${lib:2} # Strip off the ./ from the front of the name
printf "\t$lib has these dependenices\n"
dependencies=$(otool -LX $lib | cut -d ' ' -f 1 | grep -i qt)
for qtLib in $dependencies; do
qtLibName=${qtLib##*/}
[ $qtLibName != $lib ] && printf "\t\t$qtLib\n"
done
done
popd > /dev/null
}
if [[ $1 != "" ]]; then
doPopDir=1
pushd $1 > /dev/null
fi
frameworks=$(find . -name "*.framework" -type d)
for framework in $frameworks; do
printf "$framework\n"
runInstallNameToolOn ${framework:2}
done
if [[ $doPopDir -eq 1 ]]; then
popd > /dev/null
fi
@@ -0,0 +1,48 @@
#!/bin/bash
#
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
# Shell script that updates the Qt libraries and executables that are in the
# 3rd party directory so that they contain the correct rpath references so that
# the Qt command line executables can run properly as well as executables
# linking to the libraries will automatically get the rpath versions and no
# post build processing on them will need to be done.
DEBUG_PRINT=1
qtBaseDir="$1"
# Try and guess where 3rd party is located by seeing if we can sneak our way
# through the backdoor symbolic link in the sandbox
relativePathToSandboxSDKFromScriptLocaiton="../../Sandbox/SDKs/Qt"
if [[ $qtBaseDir == "" && -e $relativePathToSandboxSDKFromScriptLocaiton ]]; then
pushd $relativePathToSandboxSDKFromScriptLocaiton > /dev/null
qtBaseDir=`pwd`
popd > /dev/null
fi
shopt -s nocasematch
if [[ $qtBaseDir != "" ]]; then
read -e -p "Use the following Qt directory: $qtBaseDir? [y/n] " useQtBaseDir
fi
if [[ $qtBaseDir == "" || $useQtBaseDir == "n" ]]; then
read -e -p "Please enter the location of the Qt directory in the 3rd party directory: " qtBaseDir
fi
[ $DEBUG_PRINT -eq 1 ] && echo "qtBaseDir = *$qtBaseDir*"
#(exec ./printQtLibDependencies.sh $qtBaseDir)
echo "Updating Qt libraries..."
(exec ./updateQtLibs.sh $qtBaseDir/lib)
echo "Updating Qt executables..."
(exec ./updateQtExecs.sh $qtBaseDir/bin)
@@ -0,0 +1,76 @@
#!/bin/bash
#
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
# Shell script to update all of the executables to use rpath to reference the
# Qt libs that are stored in 3rd party. Not doing this prevents the executables
# from running on the mac since they will have embedded in them the full
# pathname of the QtLib where it was installed on the person's maching that
# copied the libs into 3rd party. (use otool -LX [exe name] to find out the
# names)
DEBUG_PRINT=0
VERBOSE_DEBUG_PRINT=0
runInstallNameToolOn ()
{
# figure out how far back we need to go to get to the Qt/lib dir where the
# frameworks are and where rpath will be pointing to
IFS=/
backDirString=""
for dir in $1; do
[ $VERBOSE_DEBUG_PRINT -eq 1 ] && printf "testing $dir length: ${#dir}\n"
backDirString=$backDirString"/.."
done
unset IFS
[ $VERBOSE_DEBUG_PRINT -eq 1 ] && printf "backDirString = $backDirString\n"
pushd $1 > /dev/null
executables=$(find . -type f -d 1 -perm +1)
for file in $executables; do
file=${file:2} # strip ./ from the front of the file name
# Get all the Qt libraries that don't have an rpath in them
dependencies=$(otool -LX $file | cut -d ' ' -f 1 | grep -i qt | grep -v @rpath)
if [[ ${#dependencies} -gt 0 ]]; then
[ $DEBUG_PRINT -eq 1 ] && printf "\tUpdating $file to use rpath and relative qt libs\n"
cmd="chmod 777 $file"
[ $DEBUG_PRINT -eq 1 ] && printf "\tRunning $cmd\n"
`$cmd`
cmd="install_name_tool -add_rpath @executable_path$backDirString/lib $file"
[ $DEBUG_PRINT -eq 1 ] && printf "\tRunning $cmd\n"
`$cmd`
fi
for qtLib in $dependencies; do
qtLibName=${qtLib##*/}
cmd="install_name_tool -change $qtLib @rpath/$qtLibName.framework/$qtLibName $file"
[ $DEBUG_PRINT -eq 1 ] && printf "\tRunning $cmd\n"
`$cmd`
done
done
popd > /dev/null
}
if [[ $1 != "" ]]; then
doPopDir=1
pushd $1 > /dev/null
fi
directoriesToLookIn=$(find . -type d)
for dir in $directoriesToLookIn; do
printf "Looking in $dir for Qt executables...\n"
runInstallNameToolOn ${dir}
done
if [[ $doPopDir -eq 1 ]]; then
popd > /dev/null
fi
@@ -0,0 +1,71 @@
#!/bin/bash
#
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
# Shell script to update all of the libraries to use rpath to reference the
# Qt libs. This only needs to be run once for the libs in 3rd party so that
# they use the rpath references to the other libraries instead of the hardcoded
# paths when Qt installs them on a machine. This will allow different users to
# use the libraries directly from perforce instead of requiring a local version
# to be installed
DEBUG_PRINT=0
VERBOSE_DEBUG_PRINT=0
runInstallNameToolOn ()
{
pushd $1/Versions/Current > /dev/null
libs=$(find . -type f -depth 1)
for lib in $libs; do
lib=${lib:2} # Strip off the ./ from the front of the name
cmd="chmod 666 $lib"
[ $DEBUG_PRINT -eq 1 ] && printf "\tRunning $cmd\n"
`$cmd`
# Don't update the id if it already uses rpath (grep -v returns things
# that don't match the specified pattern
if [[ `otool -DX $lib | grep -v @rpath` != "" ]]; then
cmd="install_name_tool -id @rpath/$1/$lib $lib"
[ $DEBUG_PRINT -eq 1 ] && printf "\tRunning $cmd\n"
`$cmd`
fi
# only update qt dependencies that don't have an rpath in them
dependencies=$(otool -LX $lib | cut -d ' ' -f 1 | grep -i qt | grep -v @)
for qtLib in $dependencies; do
[ $VERBOSE_DEBUG_PRINT -eq 1 ] && printf "\tTrying to extract lib name from $qtLib\n"
qtLibName=${qtLib##*/}
[ $VERBOSE_DEBUG_PRINT -eq 1 ] && printf "\tComparing $qtLibName with $lib\n"
if [[ $qtLibName != $lib ]]; then
cmd="install_name_tool -change $qtLib @rpath/$qtLibName.framework/$qtLibName $lib"
[ $DEBUG_PRINT -eq 1 ] && printf "\tRunning $cmd\n"
`$cmd`
fi
done
done
popd > /dev/null
}
if [[ $1 != "" ]]; then
doPopDir=1
pushd $1 > /dev/null
fi
frameworksToModify=$(find . -name "*.framework" -type d)
for framework in $frameworksToModify; do
printf "Looking at $framework...\n"
runInstallNameToolOn ${framework:2}
done
if [[ $doPopDir -eq 1 ]]; then
popd > /dev/null
fi