Release 6.0.0.14578
[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=6.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 "    dummy              Generate dummy assemblies of all modules"
22   echo "    pack [version]     Make a NuGet package with build artifacts"
23   echo "    clean              Clean all artifacts"
24 }
25
26 cmd_build() {
27   if [ -z "$1" ]; then
28     echo "No module specified."
29     exit 1
30   fi
31   if [ -d /nuget ]; then
32     NUGET_SOURCE_OPT="/p:RestoreSources=/nuget"
33   fi
34   PROJECT=$1; shift
35   $RUN_BUILD /t:restore /p:Project=$PROJECT $NUGET_SOURCE_OPT $@
36   $RUN_BUILD /t:build /p:Project=$PROJECT $@
37 }
38
39 cmd_full_build() {
40   if [ -d /nuget ]; then
41     NUGET_SOURCE_OPT="/p:RestoreSources=/nuget"
42   fi
43   $RUN_BUILD /t:clean
44   $RUN_BUILD /t:restore $NUGET_SOURCE_OPT $@
45   $RUN_BUILD /t:build $@
46 }
47
48 cmd_dummy_build() {
49   if [ -d /nuget ]; then
50     NUGET_SOURCE_OPT="/p:RestoreSources=/nuget"
51   fi
52   $RUN_BUILD /t:restore $NUGET_SOURCE_OPT
53   $RUN_BUILD /t:dummy $NUGET_SOURCE_OPT
54 }
55
56 cmd_pack() {
57   VERSION=$1
58   if [ -z "$VERSION" ]; then
59     VERSION=$VERSION_PREFIX.$((10000+$(git rev-list --count HEAD)))
60   fi
61
62   $RUN_BUILD /t:pack /p:Version=$VERSION
63 }
64
65 cmd_clean() {
66   $RUN_BUILD /t:clean
67 }
68
69 cmd=$1; shift;
70 case "$cmd" in
71   build|--build|-b) cmd_build $@ ;;
72   full |--full |-f) cmd_full_build $@ ;;
73   dummy|--dummy|-d) cmd_dummy_build $@ ;;
74   pack |--pack |-p) cmd_pack $@ ;;
75   clean|--clean|-c) cmd_clean $@ ;;
76   *) usage ;;
77 esac