Merge "Fix GetLocation"
[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 NUGET_CMD="mono $SCRIPT_DIR/tools/NuGet.exe"
9 RETRY_CMD="$SCRIPT_DIR/tools/retry.sh"
10 TIMEOUT_CMD="$SCRIPT_DIR/tools/timeout.sh"
11 DOTNET_CMD="$RETRY_CMD $TIMEOUT_CMD 600 dotnet"
12
13 RUN_BUILD="$DOTNET_CMD msbuild $SCRIPT_DIR/build/build.proj /nologo"
14
15 usage() {
16   echo "Usage: %0 [command] [args]"
17   echo "Commands:"
18   echo "    build [module]     Build a specific module"
19   echo "    full               Build all modules in src/ directory"
20   echo "    dummy              Generate dummy assemblies of all modules"
21   echo "    pack [version]     Make a NuGet package with build artifacts"
22   echo "    clean              Clean all artifacts"
23 }
24
25 cmd_build() {
26   if [ -z "$1" ]; then
27     echo "No module specified."
28     exit 1
29   fi
30   if [ -d /nuget ]; then
31     NUGET_SOURCE_OPT="/p:RestoreSources=/nuget"
32   fi
33   $RUN_BUILD /t:restore /p:Project=$1 $NUGET_SOURCE_OPT
34   $RUN_BUILD /t:build /p:Project=$1
35 }
36
37 cmd_full_build() {
38   if [ -d /nuget ]; then
39     NUGET_SOURCE_OPT="/p:RestoreSources=/nuget"
40   fi
41   $RUN_BUILD /t:clean
42   $RUN_BUILD /t:restore $NUGET_SOURCE_OPT
43   $RUN_BUILD /t:build
44 }
45
46 cmd_dummy_build() {
47   if [ -d /nuget ]; then
48     NUGET_SOURCE_OPT="/p:RestoreSources=/nuget"
49   fi
50   $RUN_BUILD /t:dummy $NUGET_SOURCE_OPT
51   $RUN_BUILD /t:afterdummy
52 }
53
54 cmd_pack() {
55   VERSION=$1
56   VERSION_INTERNAL=$2
57   if [ -z "$VERSION" ]; then
58     TIMESTAMP=$(date +"%s")
59     VERSION="5.0.0-local-$TIMESTAMP"
60   fi
61   if [ -z "$VERSION_INTERNAL" ]; then
62     VERSION_INTERNAL=$VERSION
63   fi
64
65   $NUGET_CMD pack $SCRIPT_DIR/pkg/Tizen.NET.nuspec -NoPackageAnalysis -Version $VERSION -BasePath $SCRIPT_DIR -OutputDirectory $OUTDIR
66   $NUGET_CMD pack $SCRIPT_DIR/pkg/Tizen.NET.API5.nuspec -NoPackageAnalysis -Version $VERSION -BasePath $SCRIPT_DIR -OutputDirectory $OUTDIR
67   $NUGET_CMD pack $SCRIPT_DIR/pkg/Tizen.NET.Internals.nuspec -NoPackageAnalysis -Version $VERSION_INTERNAL -BasePath $SCRIPT_DIR -OutputDirectory $OUTDIR
68 }
69
70 cmd_clean() {
71   $RUN_BUILD /t:clean
72 }
73
74 cmd=$1; shift;
75 case "$cmd" in
76   build|--build|-b) cmd_build $@ ;;
77   full |--full |-f) cmd_full_build $@ ;;
78   dummy|--dummy|-d) cmd_dummy_build $@ ;;
79   pack |--pack |-p) cmd_pack $@ ;;
80   clean|--clean|-c) cmd_clean $@ ;;
81   *) usage ;;
82 esac