Update widget and widget application
[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 NUGET_CMD="mono $SCRIPT_DIR/tools/NuGet.exe"
10
11 RETRY_CMD="$SCRIPT_DIR/tools/retry.sh"
12 TIMEOUT_CMD="$SCRIPT_DIR/tools/timeout.sh"
13
14 DOTNET_CMD="$RETRY_CMD $TIMEOUT_CMD 600 dotnet"
15
16 RUN_BUILD="$DOTNET_CMD msbuild $SCRIPT_DIR/build/build.proj"
17 RUN_BUILD_DUMMY="$DOTNET_CMD build $SCRIPT_DIR/build/build.dummy.csproj"
18
19
20 usage() {
21   echo "Usage: $0 [options] [args]"
22   echo "    Options:"
23   echo "        -h, --help            Show this usages message"
24   echo "        -b, --build [module]  Build a module"
25   echo "        -f, --full            Build all modules in src/ directory"
26   echo "        -d, --dummy           Build dummy modules"
27   echo "        -p, --pack  [version] Make nuget packages"
28   echo "        -c, --clean           Clean all artifacts"
29 }
30
31 cmd_clean() {
32   $RUN_BUILD /t:clean
33 }
34
35 cmd_build() {
36   if [ -z "$1" ]; then
37     echo "No module specified."
38     exit 1
39   fi
40   if [ -d /nuget ]; then
41     NUGET_SOURCE_OPT="/p:RestoreSources=/nuget"
42   fi
43   $RUN_BUILD /t:build /p:Project=$1 $NUGET_SOURCE_OPT
44 }
45
46 cmd_full_build() {
47   if [ -d /nuget ]; then
48     NUGET_SOURCE_OPT="/p:RestoreSources=/nuget"
49   fi
50   $RUN_BUILD /t:build $NUGET_SOURCE_OPT
51 }
52
53 cmd_pack() {
54   if [ -n "$1" ]; then
55     NUGET_VERSION_OPT="-Version $1"
56   fi
57
58   $NUGET_CMD pack $SCRIPT_DIR/pkg/Tizen.NET.Private.nuspec -Symbols -NoPackageAnalysis $NUGET_VERSION_OPT -BasePath $SCRIPT_DIR -OutputDirectory $OUTDIR
59   $NUGET_CMD pack $SCRIPT_DIR/pkg/Tizen.NET.nuspec -Symbols -NoPackageAnalysis $NUGET_VERSION_OPT -BasePath $SCRIPT_DIR -OutputDirectory $OUTDIR
60 }
61
62 cmd_dummy_build() {
63   if [ -d /nuget ]; then
64     NUGET_SOURCE_OPT="/p:RestoreSources=/nuget"
65   fi
66   $RUN_BUILD_DUMMY $NUGET_SOURCE_OPT
67 }
68
69 OPTS=`getopt -o hcbfpd --long help,clean,build,full,pack,dummy -n 'build' -- "$@"`
70 if [ $? != 0 ] ; then echo "Failed parsing options." >&2 ; usage; exit 1 ; fi
71 eval set -- "$OPTS"
72
73 FLAG_HELP=false
74 FLAG_FULL=false
75 FLAG_BUILD=false
76 FLAG_CLEAN=false
77 FLAG_DUMMY=false
78 FLAG_PACK=false
79
80 while true; do
81   case "$1" in
82     -h|--help) FLAG_HELP=true; shift ;;
83     -b|--build) FLAG_BUILD=true; shift ;;
84     -f|--full) FLAG_FULL=true; shift ;;
85     -d|--dummy) FLAG_DUMMY=true; shift ;;
86     -p|--pack) FLAG_PACK=true; shift ;;
87     -c|--clean) FLAG_CLEAN=true; shift ;;
88     --) shift; break ;;
89     *) break ;;
90   esac
91 done
92
93 if $FLAG_HELP; then usage; exit 0; fi
94 if $FLAG_CLEAN; then cmd_clean; exit 0; fi
95 if $FLAG_FULL; then cmd_full_build; exit 0; fi
96 if $FLAG_BUILD; then cmd_build $@; exit 0; fi
97 if $FLAG_PACK; then cmd_pack $@; exit 0; fi
98 if $FLAG_DUMMY; then cmd_dummy_build; exit 0; fi
99
100 usage;