SCRIPT_FILE=$(readlink -f $0)
SCRIPT_DIR=$(dirname $SCRIPT_FILE)
-# Properties
OUTDIR=$SCRIPT_DIR/Artifacts
+RUN_BUILD="dotnet msbuild $SCRIPT_DIR/build/build.proj /nologo"
+VERSION_PREFIX=4.0.1
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. The module should be added in pkg/Tizen.NET.Private.sln"
- echo " -d, --dummy Build dummy modules"
- echo " -c, --clean Clean all artifacts"
-}
-
-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
+ 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() {
echo "No module specified."
exit 1
fi
- dotnet build $SCRIPT_DIR/src/$1 --configuration=Release --output=$OUTDIR/bin
+ 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() {
- dotnet build $SCRIPT_DIR/pkg/Tizen.NET.Private.sln --configuration=Release --output=$OUTDIR/bin
- nuget pack $SCRIPT_DIR/pkg/Tizen.NET.Private.nuspec -Symbols -NoPackageAnalysis -BasePath $OUTDIR -OutputDirectory $OUTDIR
- nuget pack $SCRIPT_DIR/pkg/Tizen.NET.nuspec -Symbols -NoPackageAnalysis -BasePath $OUTDIR -OutputDirectory $OUTDIR
+ 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() {
- dotnet build $SCRIPT_DIR/pkg/Tizen.NET.Dummy.csproj --configuration=Release
+ $RUN_BUILD /t:dummy
}
-OPTS=`getopt -o hcbfd --long help,clean,build,full,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
+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
-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 ;;
- -c|--clean) FLAG_CLEAN=true; shift ;;
- --) shift; break ;;
- *) break ;;
- esac
-done
+ $RUN_BUILD /t:pack /p:Version=$VERSION
+}
-if $FLAG_HELP; then usage; exit 1; fi
-if $FLAG_CLEAN; then cmd_clean; exit 1; fi
-if $FLAG_FULL; then cmd_full_build; exit 1; fi
-if $FLAG_BUILD; then cmd_build $@; exit 1; fi
-if $FLAG_DUMMY; then cmd_dummy_build; exit 1; fi
+cmd_clean() {
+ $RUN_BUILD /t:clean
+}
-usage;
\ No newline at end of file
+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