Release 4.0.1.14164
[platform/core/csapi/tizenfx.git] / build.sh
index bf8542a..d318b50 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -3,16 +3,70 @@
 SCRIPT_FILE=$(readlink -f $0)
 SCRIPT_DIR=$(dirname $SCRIPT_FILE)
 
-# Properties
 OUTDIR=$SCRIPT_DIR/Artifacts
 
-# clean
-rm -fr $OUTDIR
-dotnet clean $SCRIPT_DIR/pkg/Tizen.NET.Private.sln
+RUN_BUILD="dotnet msbuild $SCRIPT_DIR/build/build.proj /nologo"
 
-# build
-dotnet build $SCRIPT_DIR/pkg/Tizen.NET.Private.sln --configuration=Release --output=$OUTDIR/bin
+VERSION_PREFIX=4.0.1
 
-# pack
-nuget pack pkg/Tizen.NET.Private.nuspec -Symbols -NoPackageAnalysis -BasePath $OUTDIR -OutputDirectory $OUTDIR
-nuget pack pkg/Tizen.NET.nuspec -Symbols -NoPackageAnalysis -BasePath $OUTDIR -OutputDirectory $OUTDIR
+usage() {
+  echo "Usage: $0 [command] [args]"
+  echo "Commands:"
+  echo "    build [module]     Build a specific module"
+  echo "    full               Build all modules in src/ directory"
+  echo "    dummy              Generate dummy assemblies of all modules"
+  echo "    pack [version]     Make a NuGet package with build artifacts"
+  echo "    clean              Clean all artifacts"
+}
+
+cmd_build() {
+  if [ -z "$1" ]; then
+    echo "No module specified."
+    exit 1
+  fi
+  if [ -d /nuget ]; then
+    NUGET_SOURCE_OPT="/p:RestoreSources=/nuget"
+  fi
+  PROJECT=$1; shift
+  $RUN_BUILD /t:restore /p:Project=$PROJECT $NUGET_SOURCE_OPT $@
+  $RUN_BUILD /t:build /p:Project=$PROJECT $@
+}
+
+cmd_full_build() {
+  if [ -d /nuget ]; then
+    NUGET_SOURCE_OPT="/p:RestoreSources=/nuget"
+  fi
+  rm -f msbuild.log
+  $RUN_BUILD /t:clean
+  $RUN_BUILD /t:restore $NUGET_SOURCE_OPT $@
+  $RUN_BUILD /t:build /fl $@
+}
+
+cmd_dummy_build() {
+  $RUN_BUILD /t:dummy
+}
+
+cmd_pack() {
+  VERSION=$1
+  if [ -z "$VERSION" ]; then
+    pushd $SCRIPT_DIR > /dev/null
+    VERSION=$VERSION_PREFIX.$((10000+$(git rev-list --count HEAD)))
+    popd > /dev/null
+  fi
+
+  $RUN_BUILD /t:pack /p:Version=$VERSION
+}
+
+cmd_clean() {
+  $RUN_BUILD /t:clean
+}
+
+cmd=$1; shift;
+case "$cmd" in
+  build|--build|-b) cmd_build $@ ;;
+  full |--full |-f) cmd_full_build $@ ;;
+  dummy|--dummy|-d) cmd_dummy_build $@ ;;
+  pack |--pack |-p) cmd_pack $@ ;;
+  clean|--clean|-c) cmd_clean $@ ;;
+  *) usage ;;
+esac