./do.sh dump now helps the user when they don't have the right tools installed
This commit is contained in:
parent
47ef251c8f
commit
9501e40749
80
do.sh
80
do.sh
|
@ -31,8 +31,8 @@ readCargoVariable() {
|
|||
|
||||
while read -r name equals value _; do
|
||||
if [[ $name = "$variable" && $equals = = ]]; then
|
||||
echo "${value//\"/}"
|
||||
return
|
||||
echo "${value//\"/}"
|
||||
return
|
||||
fi
|
||||
done < <(cat "$Cargo_toml")
|
||||
echo "Unable to locate $variable in $Cargo_toml" 1>&2
|
||||
|
@ -50,20 +50,20 @@ perform_action() {
|
|||
features=
|
||||
|
||||
crateName="$(readCargoVariable name "$projectDir/Cargo.toml")"
|
||||
so_path="$targetDir/$profile"
|
||||
so_name="${crateName//\-/_}"
|
||||
so_name_unstripped="${so_name}_unstripped"
|
||||
|
||||
if [[ -f "$projectDir"/Xargo.toml ]]; then
|
||||
features="--features=program"
|
||||
features="--features=program"
|
||||
fi
|
||||
case "$1" in
|
||||
build)
|
||||
if [[ -f "$projectDir"/Xargo.toml ]]; then
|
||||
echo "build $crateName ($projectDir)"
|
||||
"$sdkDir"/rust/build.sh "$projectDir"
|
||||
|
||||
so_path="$targetDir/$profile"
|
||||
so_name="${crateName//\-/_}"
|
||||
cp "$so_path/${so_name}.so" "$so_path/${so_name}_debug.so"
|
||||
"$sdkDir"/dependencies/llvm-native/bin/llvm-objcopy --strip-all "$so_path/${so_name}.so" "$so_path/$so_name.so"
|
||||
echo "build $crateName ($projectDir)"
|
||||
"$sdkDir"/rust/build.sh "$projectDir"
|
||||
cp "$so_path/${so_name}.so" "$so_path/${so_name_unstripped}.so"
|
||||
"$sdkDir"/dependencies/llvm-native/bin/llvm-objcopy --strip-all "$so_path/${so_name}.so" "$so_path/${so_name}.so"
|
||||
else
|
||||
echo "$projectDir does not contain a program, skipping"
|
||||
fi
|
||||
|
@ -98,43 +98,49 @@ perform_action() {
|
|||
# - readelf
|
||||
# - rustfilt
|
||||
if [[ -f "$projectDir"/Xargo.toml ]]; then
|
||||
if ! which rustfilt > /dev/null; then
|
||||
echo "Error: rustfilt not found. It can be installed by running: cargo install rustfilt"
|
||||
exit 1
|
||||
fi
|
||||
if ! which readelf > /dev/null; then
|
||||
if [[ $(uname) = Darwin ]]; then
|
||||
echo "Error: readelf not found. It can be installed by running: brew install binutils"
|
||||
else
|
||||
echo "Error: readelf not found."
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
(
|
||||
cd "$CALLER_PWD"
|
||||
"$0" build "$2"
|
||||
)
|
||||
|
||||
echo "dump $crateName ($projectDir)"
|
||||
|
||||
"$0" build "$2"
|
||||
so="$so_path/${so_name}.so"
|
||||
|
||||
so_path="$targetDir/$profile"
|
||||
so_name="${crateName//\-/_}"
|
||||
so="$so_path/${so_name}_debug.so"
|
||||
if [[ ! -r "$so" ]]; then
|
||||
echo "Error: No dump created, cannot read $so"
|
||||
exit 1
|
||||
fi
|
||||
dump="$so_path/${so_name}_dump"
|
||||
|
||||
if [ -f "$so" ]; then
|
||||
ls \
|
||||
-la \
|
||||
"$so" \
|
||||
>"${dump}_mangled.txt"
|
||||
readelf \
|
||||
-aW \
|
||||
"$so" \
|
||||
>>"${dump}_mangled.txt"
|
||||
(
|
||||
set -x
|
||||
ls -la "$so" > "${dump}_mangled.txt"
|
||||
readelf -aW "$so" >>"${dump}_mangled.txt"
|
||||
"$sdkDir/dependencies/llvm-native/bin/llvm-objdump" \
|
||||
-print-imm-hex \
|
||||
--source \
|
||||
--disassemble \
|
||||
"$so" \
|
||||
>>"${dump}_mangled.txt"
|
||||
sed \
|
||||
s/://g \
|
||||
<"${dump}_mangled.txt" |
|
||||
rustfilt \
|
||||
>"${dump}.txt"
|
||||
if [ -f "$dump.txt" ]; then
|
||||
echo "Dumped: $dump.txt"
|
||||
else
|
||||
echo "Error: No dump created"
|
||||
exit 1
|
||||
fi
|
||||
>> "${dump}_mangled.txt"
|
||||
sed s/://g <"${dump}_mangled.txt" | rustfilt >"${dump}.txt"
|
||||
)
|
||||
if [[ -f "$dump.txt" ]]; then
|
||||
echo "Created $dump.txt"
|
||||
else
|
||||
echo "Error: No dump created, cannot find: $so"
|
||||
echo "Error: No dump created"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue