[NUI] add NUI samples for developing
[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            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   VERSION_FILE=$OUTDIR/Version.txt
55   if [ -f $VERSION_FILE ]; then
56     NUGET_VERSION_PREFIX=$(cat $VERSION_FILE | grep Prefix | cut -d: -f2 | sed 's/\r$//')
57     NUGET_VERSION_SUFFIX=$(cat $VERSION_FILE | grep Suffix | cut -d: -f2 | sed 's/\r$//')
58           NUGET_VERSION_OPT="-Version $NUGET_VERSION_PREFIX-$NUGET_VERSION_SUFFIX"
59   fi
60   $NUGET_CMD pack $SCRIPT_DIR/pkg/Tizen.NET.Private.nuspec -Symbols -NoPackageAnalysis $NUGET_VERSION_OPT -BasePath $SCRIPT_DIR -OutputDirectory $OUTDIR
61   $NUGET_CMD pack $SCRIPT_DIR/pkg/Tizen.NET.nuspec -Symbols -NoPackageAnalysis $NUGET_VERSION_OPT -BasePath $SCRIPT_DIR -OutputDirectory $OUTDIR
62 }
63
64 cmd_dummy_build() {
65   if [ -d /nuget ]; then
66     NUGET_SOURCE_OPT="/p:RestoreSources=/nuget"
67   fi
68   $RUN_BUILD_DUMMY $NUGET_SOURCE_OPT
69 }
70
71 OPTS=`getopt -o hcbfpd --long help,clean,build,full,pack,dummy -n 'build' -- "$@"`
72 if [ $? != 0 ] ; then echo "Failed parsing options." >&2 ; usage; exit 1 ; fi
73 eval set -- "$OPTS"
74
75 FLAG_HELP=false
76 FLAG_FULL=false
77 FLAG_BUILD=false
78 FLAG_CLEAN=false
79 FLAG_DUMMY=false
80 FLAG_PACK=false
81
82 while true; do
83   case "$1" in
84     -h|--help) FLAG_HELP=true; shift ;;
85     -b|--build) FLAG_BUILD=true; shift ;;
86     -f|--full) FLAG_FULL=true; shift ;;
87     -d|--dummy) FLAG_DUMMY=true; shift ;;
88     -p|--pack) FLAG_PACK=true; shift ;;
89     -c|--clean) FLAG_CLEAN=true; shift ;;
90     --) shift; break ;;
91     *) break ;;
92   esac
93 done
94
95 if $FLAG_HELP; then usage; exit 0; fi
96 if $FLAG_CLEAN; then cmd_clean; exit 0; fi
97 if $FLAG_FULL; then cmd_full_build; exit 0; fi
98 if $FLAG_BUILD; then cmd_build $@; exit 0; fi
99 if $FLAG_PACK; then cmd_pack $@; exit 0; fi
100 if $FLAG_DUMMY; then cmd_dummy_build; exit 0; fi
101
102 usage;