X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=build.sh;h=27d8a498015bfd308640915496336be0dff0ff0d;hb=6bb51cb6b1cf4d7bd92a3d71fa74ac3b4c5d4da7;hp=4526258e1749778bdb6723d452b1212628946131;hpb=e11b719acca78b812f836bd8d78efdc81df064cb;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git diff --git a/build.sh b/build.sh index 4526258..27d8a49 100755 --- a/build.sh +++ b/build.sh @@ -3,36 +3,24 @@ SCRIPT_FILE=$(readlink -f $0) SCRIPT_DIR=$(dirname $SCRIPT_FILE) -# Properties OUTDIR=$SCRIPT_DIR/Artifacts -NUGET_CMD="mono $SCRIPT_DIR/tools/NuGet.exe" -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. (pkg/Tizen.NET.Private.sln)" - echo " -d, --dummy Build dummy modules" - echo " -p, --pack Make nuget packages" - echo " -c, --clean Clean all 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" -dotnet_build() { - if [ -d /nuget ]; then - NUGET_SOURCE_OPT="--source /nuget" - fi - PROJ=$1; shift - dotnet restore $PROJ $NUGET_SOURCE_OPT - dotnet build $PROJ --no-restore --configuration=Release $@ -} +RUN_BUILD="$DOTNET_CMD msbuild $SCRIPT_DIR/build/build.proj" +RUN_BUILD_DUMMY="$DOTNET_CMD build $SCRIPT_DIR/build/build.dummy.csproj" -cmd_clean() { - rm -fr $OUTDIR - LIST=$(find $SCRIPT_DIR -type d -a -name bin -o -name obj) - for d in $LIST; do - rm -fr $d - done +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() { @@ -40,57 +28,45 @@ cmd_build() { echo "No module specified." exit 1 fi - dotnet_build $SCRIPT_DIR/src/$1 --output=$OUTDIR/bin + if [ -d /nuget ]; then + NUGET_SOURCE_OPT="/p:RestoreSources=/nuget" + fi + $RUN_BUILD /t:build /p:Project=$1 $NUGET_SOURCE_OPT } cmd_full_build() { - dotnet_build $SCRIPT_DIR/pkg/Tizen.NET.Private.sln --output=$OUTDIR/bin -} - -cmd_pack() { - VERSION_FILE=$OUTDIR/Version.txt - if [ -f $VERSION_FILE ]; then - NUGET_VERSION_PREFIX=$(cat $VERSION_FILE | grep Prefix | cut -d: -f2 | sed 's/\r$//') - NUGET_VERSION_SUFFIX=$(cat $VERSION_FILE | grep Suffix | cut -d: -f2 | sed 's/\r$//') - NUGET_VERSION_OPT="-Version $NUGET_VERSION_PREFIX-$NUGET_VERSION_SUFFIX" + if [ -d /nuget ]; then + NUGET_SOURCE_OPT="/p:RestoreSources=/nuget" fi - $NUGET_CMD pack $SCRIPT_DIR/pkg/Tizen.NET.Private.nuspec -Symbols -NoPackageAnalysis $NUGET_VERSION_OPT -BasePath $OUTDIR -OutputDirectory $OUTDIR - $NUGET_CMD pack $SCRIPT_DIR/pkg/Tizen.NET.nuspec -Symbols -NoPackageAnalysis $NUGET_VERSION_OPT -BasePath $OUTDIR -OutputDirectory $OUTDIR + $RUN_BUILD /t:build $NUGET_SOURCE_OPT } cmd_dummy_build() { - dotnet_build $SCRIPT_DIR/pkg/Tizen.NET.Dummy.csproj + if [ -d /nuget ]; then + NUGET_SOURCE_OPT="/p:RestoreSources=/nuget" + fi + $RUN_BUILD_DUMMY $NUGET_SOURCE_OPT } -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 +cmd_pack() { + if [ -n "$1" ]; then + NUGET_VERSION_OPT="-Version $1" + fi -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 + $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 +} -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 +cmd_clean() { + $RUN_BUILD /t:clean +} -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 $@ ;; + clean|--clean|-c) cmd_clean $@ ;; + *) usage ;; +esac