Release 5.0.0.14556
[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 OUTDIR=$SCRIPT_DIR/Artifacts
7
8 RETRY_CMD="$SCRIPT_DIR/tools/scripts/retry.sh"
9 TIMEOUT_CMD="$SCRIPT_DIR/tools/scripts/timeout.sh"
10 DOTNET_CMD="$RETRY_CMD $TIMEOUT_CMD 600 dotnet"
11
12 RUN_BUILD="$DOTNET_CMD msbuild $SCRIPT_DIR/build/build.proj /nologo"
13
14 VERSION_PREFIX=5.0.0
15
16 usage() {
17   echo "Usage: $0 [command] [args]"
18   echo "Commands:"
19   echo "    build [module]     Build a specific module"
20   echo "    full               Build all modules in src/ directory"
21   echo "    ext                Build external modules in externals/ directory"
22   echo "    dummy              Generate dummy assemblies of all modules"
23   echo "    pack [version]     Make a NuGet package with build artifacts"
24   echo "    clean              Clean all artifacts"
25 }
26
27 cmd_build() {
28   if [ -z "$1" ]; then
29     echo "No module specified."
30     exit 1
31   fi
32   if [ -d /nuget ]; then
33     NUGET_SOURCE_OPT="/p:RestoreSources=/nuget"
34   fi
35   PROJECT=$1; shift
36   $RUN_BUILD /t:restore /p:Project=$PROJECT $NUGET_SOURCE_OPT $@
37   $RUN_BUILD /t:build /p:Project=$PROJECT $@
38 }
39
40 cmd_full_build() {
41   if [ -d /nuget ]; then
42     NUGET_SOURCE_OPT="/p:RestoreSources=/nuget"
43   fi
44   $RUN_BUILD /t:clean
45   $RUN_BUILD /t:restore $NUGET_SOURCE_OPT $@
46   $RUN_BUILD /t:build $@
47 }
48
49 cmd_dummy_build() {
50   if [ -d /nuget ]; then
51     NUGET_SOURCE_OPT="/p:RestoreSources=/nuget"
52   fi
53   $RUN_BUILD /t:restore $NUGET_SOURCE_OPT
54   $RUN_BUILD /t:dummy $NUGET_SOURCE_OPT
55 }
56
57 cmd_ext_build() {
58   if [ -d /nuget ]; then
59     NUGET_SOURCE_OPT="/p:RestoreSources=/nuget;$SCRIPT_DIR/packages;$SCRIPT_DIR/Artifacts"
60   fi
61   PROJECTS=$(ls -1 $SCRIPT_DIR/externals/*.proj)
62   for p in $PROJECTS; do
63     $DOTNET_CMD msbuild $p /t:Build $NUGET_SOURCE_OPT /nologo
64   done
65 }
66
67 cmd_pack() {
68   VERSION=$1
69   if [ -z "$VERSION" ]; then
70     VERSION=$VERSION_PREFIX.$((10000+$(git rev-list --count HEAD)))
71   fi
72
73   $RUN_BUILD /t:pack /p:Version=$VERSION
74 }
75
76 cmd_clean() {
77   $RUN_BUILD /t:clean
78 }
79
80 cmd=$1; shift;
81 case "$cmd" in
82   build|--build|-b) cmd_build $@ ;;
83   full |--full |-f) cmd_full_build $@ ;;
84   dummy|--dummy|-d) cmd_dummy_build $@ ;;
85   ext  |--ext  |-e) cmd_ext_build $@ ;;
86   pack |--pack |-p) cmd_pack $@ ;;
87   clean|--clean|-c) cmd_clean $@ ;;
88   *) usage ;;
89 esac