[NUI] Integreation from dalihub (#988)
[platform/core/csapi/tizenfx.git] / build.sh
index 66ecec2..0c95e74 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -3,33 +3,21 @@
 SCRIPT_FILE=$(readlink -f $0)
 SCRIPT_DIR=$(dirname $SCRIPT_FILE)
 
-# Properties
 OUTDIR=$SCRIPT_DIR/Artifacts
 
-NUGET_CMD="mono $SCRIPT_DIR/tools/NuGet.exe"
-
-RETRY_CMD="$SCRIPT_DIR/tools/retry.sh"
-TIMEOUT_CMD="$SCRIPT_DIR/tools/timeout.sh"
-
-DOTNET_CMD="$RETRY_CMD $TIMEOUT_CMD 600 dotnet"
-
-RUN_BUILD="$DOTNET_CMD msbuild $SCRIPT_DIR/build/build.proj"
-RUN_BUILD_DUMMY="$DOTNET_CMD build $SCRIPT_DIR/build/build.dummy.csproj"
+RUN_BUILD="dotnet msbuild $SCRIPT_DIR/build/build.proj /nologo"
 
+VERSION_PREFIX=6.0.0
 
 usage() {
-  echo "Usage: $0 [options] [args]"
-  echo "    Options:"
-  echo "        -h, --help            Show this usages message"
-  echo "        -b, --build [module]  Build a module"
-  echo "        -f, --full            Build all modules in src/ directory"
-  echo "        -d, --dummy           Build dummy modules"
-  echo "        -p, --pack  [version] Make nuget packages"
-  echo "        -c, --clean           Clean all artifacts"
-}
-
-cmd_clean() {
-  $RUN_BUILD /t:clean
+  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 "    install [target]   Install assemblies to the target device"
+  echo "    clean              Clean all artifacts"
 }
 
 cmd_build() {
@@ -40,61 +28,85 @@ cmd_build() {
   if [ -d /nuget ]; then
     NUGET_SOURCE_OPT="/p:RestoreSources=/nuget"
   fi
-  $RUN_BUILD /t:build /p:Project=$1 $NUGET_SOURCE_OPT
+  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
-  $RUN_BUILD /t:build $NUGET_SOURCE_OPT
+  rm -f msbuild.log
+  $RUN_BUILD /t:clean
+  $RUN_BUILD /t:restore $NUGET_SOURCE_OPT $@
+  $RUN_BUILD /t:build /fl $@
+  $RUN_BUILD /t:dummy
+}
+
+cmd_dummy_build() {
+  $RUN_BUILD /t:dummy
 }
 
 cmd_pack() {
-  if [ -n "$1" ]; then
-    NUGET_VERSION_OPT="-Version $1"
+  VERSION=$1
+  if [ -z "$VERSION" ]; then
+    pushd $SCRIPT_DIR > /dev/null
+    VERSION=$VERSION_PREFIX.$((10000+$(git rev-list --count HEAD)))
+    popd > /dev/null
   fi
 
-  $NUGET_CMD pack $SCRIPT_DIR/pkg/Tizen.NET.Private.nuspec -Symbols -NoPackageAnalysis $NUGET_VERSION_OPT -BasePath $SCRIPT_DIR -OutputDirectory $OUTDIR
-  $NUGET_CMD pack $SCRIPT_DIR/pkg/Tizen.NET.nuspec -Symbols -NoPackageAnalysis $NUGET_VERSION_OPT -BasePath $SCRIPT_DIR -OutputDirectory $OUTDIR
+  $RUN_BUILD /t:pack /p:Version=$VERSION
 }
 
-cmd_dummy_build() {
-  if [ -d /nuget ]; then
-    NUGET_SOURCE_OPT="/p:RestoreSources=/nuget"
+cmd_install() {
+  DEVICE_ID=$1
+
+  RUNTIME_ASSEMBLIES="$OUTDIR/bin/public/*.dll $OUTDIR/bin/internal/*.dll"
+  TARGET_ASSEMBLY_PATH="/usr/share/dotnet.tizen/framework"
+
+  device_cnt=$(sdb devices | grep -v "List" | wc -l)
+  if [ $device_cnt -eq 0 ]; then
+    echo "No connected devices"
+    exit 1
+  fi
+
+  if [ $device_cnt -gt 1 ] && [ -z "$DEVICE_ID" ]; then
+    echo "Multiple devices are connected. Specify the device. (ex: ./build.sh install [device-id])"
+    sdb devices
+    exit 1
+  fi
+
+  SDB_OPTIONS=""
+  if [ -n "$DEVICE_ID" ]; then
+    SDB_OPTIONS="-s $DEVICE_ID"
   fi
-  $RUN_BUILD_DUMMY $NUGET_SOURCE_OPT
+
+  sdb $SDB_OPTIONS root on
+  sdb $SDB_OPTIONS shell mount -o remount,rw /
+  sdb $SDB_OPTIONS push $RUNTIME_ASSEMBLIES $TARGET_ASSEMBLY_PATH
+
+  nifile_cnt=$(sdb $SDB_OPTIONS shell find $TARGET_ASSEMBLY_PATH -name '*.ni.dll' | wc -l)
+  if [ $nifile_cnt -gt 0 ]; then
+    sdb $SDB_OPTIONS shell "rm -f $TARGET_ASSEMBLY_PATH/*.ni.dll"
+    sdb $SDB_OPTIONS shell nitool --system
+    sdb $SDB_OPTIONS shell nitool --regen-all-app
+  fi
+
+  sdb $SDB_OPTIONS shell chsmack -a '_' $TARGET_ASSEMBLY_PATH/*
+}
+
+cmd_clean() {
+  $RUN_BUILD /t:clean
 }
 
-OPTS=`getopt -o hcbfpd --long help,clean,build,full,pack,dummy -n 'build' -- "$@"`
-if [ $? != 0 ] ; then echo "Failed parsing options." >&2 ; usage; exit 1 ; fi
-eval set -- "$OPTS"
-
-FLAG_HELP=false
-FLAG_FULL=false
-FLAG_BUILD=false
-FLAG_CLEAN=false
-FLAG_DUMMY=false
-FLAG_PACK=false
-
-while true; do
-  case "$1" in
-    -h|--help) FLAG_HELP=true; shift ;;
-    -b|--build) FLAG_BUILD=true; shift ;;
-    -f|--full) FLAG_FULL=true; shift ;;
-    -d|--dummy) FLAG_DUMMY=true; shift ;;
-    -p|--pack) FLAG_PACK=true; shift ;;
-    -c|--clean) FLAG_CLEAN=true; shift ;;
-    --) shift; break ;;
-    *) break ;;
-  esac
-done
-
-if $FLAG_HELP; then usage; exit 0; fi
-if $FLAG_CLEAN; then cmd_clean; exit 0; fi
-if $FLAG_FULL; then cmd_full_build; exit 0; fi
-if $FLAG_BUILD; then cmd_build $@; exit 0; fi
-if $FLAG_PACK; then cmd_pack $@; exit 0; fi
-if $FLAG_DUMMY; then cmd_dummy_build; exit 0; fi
-
-usage;
+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 $@ ;;
+  install |--install |-i) cmd_install $@ ;;
+  clean|--clean|-c) cmd_clean $@ ;;
+  *) usage ;;
+esac