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