3 SCRIPT_DIR=$(dirname $(readlink -f $0))
7 SLN_FILE=$SCRIPT_DIR/$SLN_NAME.sln
8 OUTDIR=$SCRIPT_DIR/Artifacts
10 PROFILES=(mobile tv wearable)
11 TARGET_ASSEMBLY_DIR=/usr/share/dotnet.tizen/framework
12 TARGET_PRELOAD_DIR=/usr/share/dotnet.tizen/preload
14 source $SCRIPT_DIR/packaging/version.txt
15 VERSION_PREFIX=$(expr $NUGET_VERSION : '\([0-9]\+\.[0-9]\+\.[0-9]\+\)')
18 echo "Usage: $0 [command] [args]"
20 echo " build [module] Build a specific module"
21 echo " full Build all modules in src/ directory"
22 echo " dummy Generate dummy assemblies of all modules"
23 echo " pack [version] Make a NuGet package with build artifacts"
24 echo " install [target] Install assemblies to the target device"
25 echo " clean Clean all artifacts"
29 target=$1; [ -z "$target" ] && target="full"
31 dotnet new sln -n $SLN_NAME -o $SCRIPT_DIR --force
32 if [ "$target" == "public" -o "$target" == "full" ]; then
33 dotnet sln $SLN_FILE add $SCRIPT_DIR/src/*/*.csproj
35 if [ "$target" == "internal" -o "$target" == "full" ]; then
36 dotnet sln $SLN_FILE add $SCRIPT_DIR/internals/src/*/*.csproj
38 if [ "$target" == "design" ]; then
39 dotnet sln $SLN_FILE add $SCRIPT_DIR/src/*/*.Design.csproj
41 dotnet sln $SLN_FILE remove $SCRIPT_DIR/src/*/*.Design.csproj
49 remove_intermediates() {
51 \( -name obj -o -name bin \) -print0 | xargs -0 -I {} rm -fr "{}"
55 remove_intermediates $SCRIPT_DIR/build/
56 remove_intermediates $SCRIPT_DIR/src/
57 remove_intermediates $SCRIPT_DIR/internals/src/
64 if [ -d /nuget ]; then
65 dotnet restore -s /nuget $@
72 dotnet build --no-restore -c $CONFIGURATION /fl $@
77 for proj in $(ls -d1 $1/*/); do
78 if [ -d $proj/bin/$CONFIGURATION ]; then
79 cp -fr $proj/bin/$CONFIGURATION/*/* $2
85 copy_artifacts $SCRIPT_DIR/src $OUTDIR/bin/public
86 copy_artifacts $SCRIPT_DIR/internals/src $OUTDIR/bin/internal
89 mkdir -p $OUTDIR/preload
90 mv $OUTDIR/bin/public/*.preload $OUTDIR/preload 2>/dev/null || :
91 mv $OUTDIR/bin/internal/*.preload $OUTDIR/preload 2>/dev/null || :
94 for profile in ${PROFILES[@]}; do
95 list=$(cat $OUTDIR/bin/public/*.$profile.filelist \
96 $OUTDIR/bin/internal/*.$profile.filelist \
98 rm -f $OUTDIR/$profile.filelist
100 if [[ "$item" == *.preload ]]; then
101 echo $TARGET_PRELOAD_DIR/$item >> $OUTDIR/$profile.filelist
103 echo $TARGET_ASSEMBLY_DIR/$item >> $OUTDIR/$profile.filelist
111 echo "No module specified."
115 sources=(src internals/src)
116 for src in $sources; do
117 project=$SCRIPT_DIR/$src/$module/$module.csproj
119 if [ -f "$project" ]; then
128 prepare_solution full
137 prepare_solution design
140 projects=$(dirname $(ls -1 $SCRIPT_DIR/src/*/*.Design.csproj))
141 for proj in $projects; do
142 if [ -d $proj/bin/$CONFIGURATION ]; then
143 cp -f $proj/bin/$CONFIGURATION/*/*.Design.dll $SCRIPT_DIR/pkg/Tizen.NET.API*/design/
150 if [ ! -d $OUTDIR/bin/public/ref ]; then
151 echo "No assemblies to read. Build TizenFX first."
154 mkdir -p $OUTDIR/bin/dummy
155 dotnet $SCRIPT_DIR/tools/bin/APITool.dll \
156 dummy $OUTDIR/bin/public/ref $OUTDIR/bin/dummy
161 if [ -z "$VERSION" ]; then
162 pushd $SCRIPT_DIR > /dev/null
163 VERSION=$VERSION_PREFIX.$((10000+$(git rev-list --count HEAD)))
167 restore $SCRIPT_DIR/build/pack.csproj
168 nuspecs=$(find $SCRIPT_DIR/pkg/ -name "*.nuspec")
169 for nuspec in $nuspecs; do
170 dotnet pack --no-restore --no-build --nologo -o $OUTDIR \
171 $SCRIPT_DIR/build/pack.csproj \
172 /p:Version=$VERSION \
173 /p:NuspecFile=$(readlink -f $nuspec)
180 RUNTIME_ASSEMBLIES="$OUTDIR/bin/public/*.dll $OUTDIR/bin/internal/*.dll"
182 device_cnt=$(sdb devices | grep -v "List" | wc -l)
184 if [ $device_cnt -eq 0 ]; then
185 echo "No connected devices"
189 if [ $device_cnt -gt 1 ] && [ -z "$DEVICE_ID" ]; then
190 echo "Multiple devices are connected. Specify the device. (ex: ./build.sh install [device-id])"
196 if [ -n "$DEVICE_ID" ]; then
197 SDB_OPTIONS="-s $DEVICE_ID"
200 sdb $SDB_OPTIONS root on
201 sdb $SDB_OPTIONS shell mount -o remount,rw /
202 sdb $SDB_OPTIONS push $RUNTIME_ASSEMBLIES $TARGET_ASSEMBLY_DIR
204 nifile_cnt=$(sdb $SDB_OPTIONS shell find $TARGET_ASSEMBLY_DIR -name '*.ni.dll' | wc -l)
205 if [ $nifile_cnt -gt 0 ]; then
206 sdb $SDB_OPTIONS shell "rm -f $TARGET_ASSEMBLY_DIR/*.ni.dll"
207 sdb $SDB_OPTIONS shell nitool --system
208 sdb $SDB_OPTIONS shell nitool --regen-all-app
211 sdb $SDB_OPTIONS shell chsmack -a '_' $TARGET_ASSEMBLY_DIR/*
214 cmd=$1; [ $# -gt 0 ] && shift;
216 build|--build|-b) cmd_module_build $@ ;;
217 full |--full |-f) cmd_full_build $@ ;;
218 design|--design) cmd_design_build $@ ;;
219 dummy|--dummy|-d) cmd_dummy_build $@ ;;
220 pack |--pack |-p) cmd_pack $@ ;;
221 install |--install |-i) cmd_install $@ ;;
222 clean|--clean|-c) clean ;;