-
Notifications
You must be signed in to change notification settings - Fork 11
/
build.sh
executable file
·75 lines (65 loc) · 2.24 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
CUR=$PWD
BUILD_DIR=$PWD/build
echo "[*] Building nmips plugin at $BUILD_DIR!"
rm -rf $BUILD_DIR || echo "No existing build dir, sadge"
mkdir $BUILD_DIR
# SDK_DOWNLOAD="https://hex-rays.com/products/ida/support/ida/idasdk76.zip"
SDK_DOWNLOAD="https://cdn.vis.ethz.ch/ctf/idasdk.zip"
echo "[*] Downloading idasdk..."
# wget --http-user=$IDA_USER --http-password=$IDA_PASS $SDK_DOWNLOAD -O $BUILD_DIR/idasdk.zip
wget $SDK_DOWNLOAD -O $BUILD_DIR/idasdk.enc.zip
echo "[*] Decrypting idasdk..."
openssl aes-256-cbc -d -md sha256 -in $BUILD_DIR/idasdk.enc.zip -out $BUILD_DIR/idasdk.zip -pass env:IDA_PASS
echo "[*] Setting up idasdk..."
cd $BUILD_DIR
unzip idasdk
cd $CUR
export IDA_SDK=$BUILD_DIR/idasdk76
echo "[*] IDA SDK at $IDA_SDK"
# echo "[*] Setting up and building binutils..."
# BINUTILS_URL="https://github.com/MediaTek-Labs/nanomips-gnu-toolchain/releases/download/nanoMIPS-2021.02-01/binutils-2021.02-01.src.tar.gz"
# wget $BINUTILS_URL -O $BUILD_DIR/binutils.tar.gz
# cd $BUILD_DIR
# echo "[*] Extracting binutils"
# tar -xzf binutils.tar.gz
# export BINUTILS_DIR=$BUILD_DIR/binutils-2021.02-01
# cd $BINUTILS_DIR
# echo "[*] configuring binutils"
# ./configure --prefix $CUR/libs --enable-shared --disable-werror --target=nanomips-gnu-elf
# echo "[*] making binutils"
# make -j `nproc`
# cd $CUR
case "$(uname -s)" in
Darwin)
echo 'Mac OS X'
;;
Linux)
echo 'Linux'
;;
CYGWIN*|MINGW32*|MSYS*|MINGW*)
echo 'MS Windows'
export CC=clang-cl
export CXX=clang-cl
;;
# Add here more strings to compare
# See correspondence table at the bottom of this answer
*)
echo 'Other OS'
;;
esac
# if [[ "$OSTYPE" == "darwin"* ]]; then
# echo "[*] We are on macOS, force clang!"
# export CC=clang
# export CXX=clang++
# fi
echo "[*] Setting up and building plugin"
GOOD_PATH=$(echo "$PATH" | sed -e 's/:\/mingw64\/bin\(:\|$\)//')
GOOD_PATH=$(echo "$GOOD_PATH" | sed -e 's/:\/usr\/bin\(:\|$\)//')
echo "[*] Fixed Path: $GOOD_PATH"
cd $CUR/plugin
# PATH=$GOOD_PATH which cl || true
# PATH=$GOOD_PATH cl -help || true
# PATH=$GOOD_PATH cl -std:c++20 -std=c++20 || true
PATH=$GOOD_PATH meson setup $BUILD_DIR/builddir -Didasdk=$IDA_SDK
echo "[*] Building plugin..."
PATH=$GOOD_PATH meson compile -C $BUILD_DIR/builddir