6da5b287282fc67be6cc17ecdc2a826b1ea22f23
[platform/core/csapi/tizenfx.git] / build.sh
1 #!/bin/bash
2
3 SCRIPT_FILE=$(readlink -f $0)
4 SCRIPT_DIR=$(dirname $SCRIPT_FILE)
5
6 # Properties
7 OUTDIR=$SCRIPT_DIR/Artifacts
8
9
10
11 usage() {
12   echo "Usage: $0 [options] [args]"
13   echo "    Options:"
14   echo "        -h, --help            Show this usages message"
15   echo "        -b, --build [module]  Build a module"
16   echo "        -f, --full            Build all modules in src/ directory. The module should be added in pkg/Tizen.NET.Private.sln"
17   echo "        -d, --dummy           Build dummy modules"
18   echo "        -c, --clean           Clean all artifacts"
19 }
20
21 cmd_clean() {
22   rm -fr $OUTDIR
23   LIST=$(find $SCRIPT_DIR -type d -a -name bin -o -name obj)
24   for d in $LIST; do
25     rm -fr $d
26   done
27 }
28
29 cmd_build() {
30   if [ -z "$1" ]; then
31     echo "No module specified."
32     exit 1
33   fi
34   dotnet build $SCRIPT_DIR/src/$1 --configuration=Release --output=$OUTDIR/bin
35 }
36
37 cmd_full_build() {
38   dotnet build $SCRIPT_DIR/pkg/Tizen.NET.Private.sln --configuration=Release --output=$OUTDIR/bin
39   nuget pack $SCRIPT_DIR/pkg/Tizen.NET.Private.nuspec -Symbols -NoPackageAnalysis -BasePath $OUTDIR -OutputDirectory $OUTDIR
40   nuget pack $SCRIPT_DIR/pkg/Tizen.NET.nuspec -Symbols -NoPackageAnalysis -BasePath $OUTDIR -OutputDirectory $OUTDIR
41 }
42
43 cmd_dummy_build() {
44   dotnet build $SCRIPT_DIR/pkg/Tizen.NET.Dummy.csproj --configuration=Release
45 }
46
47 OPTS=`getopt -o hcbfd --long help,clean,build,full,dummy -n 'build' -- "$@"`
48 if [ $? != 0 ] ; then echo "Failed parsing options." >&2 ; usage; exit 1 ; fi
49 eval set -- "$OPTS"
50
51 FLAG_HELP=false
52 FLAG_FULL=false
53 FLAG_BUILD=false
54 FLAG_CLEAN=false
55 FLAG_DUMMY=false
56
57 while true; do
58   case "$1" in
59     -h|--help) FLAG_HELP=true; shift ;;
60     -b|--build) FLAG_BUILD=true; shift ;;
61     -f|--full) FLAG_FULL=true; shift ;;
62     -d|--dummy) FLAG_DUMMY=true; shift ;;
63     -c|--clean) FLAG_CLEAN=true; shift ;;
64     --) shift; break ;;
65     *) break ;;
66   esac
67 done
68
69 if $FLAG_HELP; then usage; exit 1; fi
70 if $FLAG_CLEAN; then cmd_clean; exit 1; fi
71 if $FLAG_FULL; then cmd_full_build; exit 1; fi
72 if $FLAG_BUILD; then cmd_build $@; exit 1; fi
73 if $FLAG_DUMMY; then cmd_dummy_build; exit 1; fi
74
75 usage;