Add switch to disable IPv6
[platform/core/dotnet/launcher.git] / tools / Extractor / build.sh
1 #! /bin/bash
2
3 SCRIPT_DIR=$(dirname $(readlink -f $0))
4
5 CONFIGURATION=Release
6 SLN_NAME=dotnet-extractor/dotnet-extractor
7 TARGET_FRAMEWORK=netcoreapp3.1
8 SLN_FILE=$SCRIPT_DIR/$SLN_NAME.sln
9 OUTDIR=$SCRIPT_DIR/$SLN_NAME/bin/$CONFIGURATION/$TARGET_FRAMEWORK
10 TARGET_ASSEMBLY_DIR=/home/owner/share/.dotnet/tools
11
12 usage() {
13   echo "Usage: $0 [command]"
14   echo "Commands:"
15   echo " -b, --build     Build a ExtractLine module"
16   echo " -i, --install   Install assemblies to the target device"
17   echo " -c, --clean     Clean all artifacts"
18 }
19
20 remove_intermediates() {
21   find $1 -type d \( -name bin -o -name obj \) -print0 | xargs -0 -I {} rm -fr "{}"
22 }
23
24 clean() {
25   remove_intermediates $SCRIPT_DIR/$SLN_NAME
26   rm -f msbuild.log
27 }
28
29 build() {
30   clean
31   dotnet build -c $CONFIGURATION $SLN_FILE
32 }
33
34 install() {
35   DEVICE_ID=$1
36
37   RUNTIME_ASSEMBLIES="$OUTDIR/*.dll"
38
39   device_cnt=$(sdb devices | grep -v "List" | wc -l)
40
41   if [ $device_cnt -eq 0 ]; then
42     echo "No connected devices"
43     exit 1
44   fi
45
46   if [ $device_cnt -gt 1 ] && [ -z "$DEVICE_ID" ]; then
47     echo "Multiple devices are connected. Specify the device. (ex: ./build.sh --install [device-id])"
48     sdb devices
49     exit 1
50   fi
51
52   SDB_OPTIONS=""
53   if [ -n "$DEVICE_ID" ]; then
54     SDB_OPTIONS="-s $DEVICE_ID"
55   fi
56
57   sdb $SDB_OPTIONS root on
58   sdb $SDB_OPTIONS shell mount -o remount,rw /
59   sdb $SDB_OPTIONS push $RUNTIME_ASSEMBLIES $TARGET_ASSEMBLY_DIR
60
61   nifile_cnt=$(sdb $SDB_OPTIONS shell find $TARGET_ASSEMBLY_DIR -name 'Microsoft.DiaSymReader*.ni.dll' | wc -l)
62   if [ $nifile_cnt -gt 0 ]; then
63     sdb $SDB_OPTIONS shell "rm -f $TARGET_ASSEMBLY_DIR/Microsoft.DiaSymReader*.ni.dll"
64   fi
65
66   #sdb $SDB_OPTIONS shell dotnettool --ni-dll $TARGET_ASSEMBLY_DIR/Microsoft.DiaSymReader*.dll
67   sdb $SDB_OPTIONS shell chsmack -a '_' $TARGET_ASSEMBLY_DIR/*.dll
68   sdb $SDB_OPTIONS shell chown owner:users $TARGET_ASSEMBLY_DIR/*.dll
69   sdb $SDB_OPTIONS shell chmod 644 $TARGET_ASSEMBLY_DIR/*.dll
70 }
71
72 cmd=$1; [ $# -gt 0 ] && shift;
73 case "$cmd" in
74   build|--build|-b) build ;;
75   install|--install|-i) install $@ ;;
76   clean|--clean|-c) clean ;;
77   *) usage ;;
78 esac