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 " design Build NUI Design module"
23 echo " xamlbuild Build NUI XamlBuild module"
24 echo " dummy Generate dummy assemblies of all modules"
25 echo " pack [version] Make a NuGet package with build artifacts"
26 echo " install [target] Install assemblies to the target device"
27 echo " clean Clean all artifacts"
31 target=$1; [ -z "$target" ] && target="full"
33 dotnet new sln -n $SLN_NAME -o $SCRIPT_DIR --force
34 if [ "$target" == "public" -o "$target" == "full" ]; then
35 dotnet sln $SLN_FILE add $SCRIPT_DIR/src/*/*.csproj
37 if [ "$target" == "internal" -o "$target" == "full" ]; then
38 dotnet sln $SLN_FILE add $SCRIPT_DIR/internals/src/*/*.csproj
40 if [ "$target" == "design" ]; then
41 dotnet sln $SLN_FILE add $SCRIPT_DIR/src/*/*.Design.csproj
43 dotnet sln $SLN_FILE remove $SCRIPT_DIR/src/*/*.Design.csproj
45 if [ "$target" == "xamlbuild" ]; then
46 dotnet sln $SLN_FILE add $SCRIPT_DIR/src/*/*.XamlBuild.csproj
48 dotnet sln $SLN_FILE remove $SCRIPT_DIR/src/*/*.XamlBuild.csproj
56 remove_intermediates() {
58 \( -name obj -o -name bin \) -print0 | xargs -0 -I {} rm -fr "{}"
62 remove_intermediates $SCRIPT_DIR/build/
63 remove_intermediates $SCRIPT_DIR/src/
64 remove_intermediates $SCRIPT_DIR/internals/src/
71 if [ -d /nuget ]; then
72 dotnet restore -s /nuget $@
79 dotnet build --no-restore -c $CONFIGURATION /fl $@
84 for proj in $(ls -d1 $1/*/); do
85 if [ -d $proj/bin/$CONFIGURATION ]; then
86 cp -fr $proj/bin/$CONFIGURATION/*/* $2
92 copy_artifacts $SCRIPT_DIR/src $OUTDIR/bin/public
93 copy_artifacts $SCRIPT_DIR/internals/src $OUTDIR/bin/internal
96 mkdir -p $OUTDIR/preload
97 mv $OUTDIR/bin/public/*.preload $OUTDIR/preload 2>/dev/null || :
98 mv $OUTDIR/bin/internal/*.preload $OUTDIR/preload 2>/dev/null || :
101 for profile in ${PROFILES[@]}; do
102 list=$(cat $OUTDIR/bin/public/*.$profile.filelist \
103 $OUTDIR/bin/internal/*.$profile.filelist \
105 rm -f $OUTDIR/$profile.filelist
106 for item in $list; do
107 if [[ "$item" == *.preload ]]; then
108 echo $TARGET_PRELOAD_DIR/$item >> $OUTDIR/$profile.filelist
110 echo $TARGET_ASSEMBLY_DIR/$item >> $OUTDIR/$profile.filelist
118 echo "No module specified."
122 sources=(src internals/src)
123 for src in $sources; do
124 project=$SCRIPT_DIR/$src/$module/$module.csproj
126 if [ -f "$project" ]; then
135 prepare_solution full
144 prepare_solution design
147 projects=$(dirname $(ls -1 $SCRIPT_DIR/src/*/*.Design.csproj))
148 for proj in $projects; do
149 if [ -d $proj/bin/$CONFIGURATION ]; then
150 cp -f $proj/bin/$CONFIGURATION/*/*.Design.dll $SCRIPT_DIR/pkg/Tizen.NET.API*/design/
156 cmd_xamlbuild_build() {
157 prepare_solution xamlbuild
160 projects=$(dirname $(ls -1 $SCRIPT_DIR/src/*/*.XamlBuild.csproj))
161 for proj in $projects; do
162 if [ -d $proj/bin/$CONFIGURATION ]; then
163 cp -f $proj/bin/$CONFIGURATION/*/*.XamlBuild.dll $SCRIPT_DIR/pkg/Tizen.NET.API*/xamlbuild/
170 if [ ! -d $OUTDIR/bin/public/ref ]; then
171 echo "No assemblies to read. Build TizenFX first."
174 mkdir -p $OUTDIR/bin/dummy
177 dotnet $SCRIPT_DIR/tools/bin/APITool.dll \
178 dummy $OUTDIR/bin/public/ref $OUTDIR/bin/dummy
184 if [ -z "$VERSION" ]; then
185 pushd $SCRIPT_DIR > /dev/null
186 VERSION=$VERSION_PREFIX.$((10000+$(git rev-list --count HEAD)))
190 restore $SCRIPT_DIR/build/pack.csproj
191 nuspecs=$(find $SCRIPT_DIR/pkg/ -name "*.nuspec")
192 for nuspec in $nuspecs; do
193 dotnet pack --no-restore --no-build --nologo -o $OUTDIR \
194 $SCRIPT_DIR/build/pack.csproj \
195 /p:Version=$VERSION \
196 /p:NuspecFile=$(readlink -f $nuspec)
203 RUNTIME_ASSEMBLIES="$OUTDIR/bin/public/*.dll $OUTDIR/bin/internal/*.dll"
205 device_cnt=$(sdb devices | grep -v "List" | wc -l)
207 if [ $device_cnt -eq 0 ]; then
208 echo "No connected devices"
212 if [ $device_cnt -gt 1 ] && [ -z "$DEVICE_ID" ]; then
213 echo "Multiple devices are connected. Specify the device. (ex: ./build.sh install [device-id])"
219 if [ -n "$DEVICE_ID" ]; then
220 SDB_OPTIONS="-s $DEVICE_ID"
223 sdb $SDB_OPTIONS root on
224 sdb $SDB_OPTIONS shell mount -o remount,rw /
225 sdb $SDB_OPTIONS push $RUNTIME_ASSEMBLIES $TARGET_ASSEMBLY_DIR
227 nifile_cnt=$(sdb $SDB_OPTIONS shell find $TARGET_ASSEMBLY_DIR -name '*.ni.dll' | wc -l)
228 if [ $nifile_cnt -gt 0 ]; then
229 sdb $SDB_OPTIONS shell "rm -f $TARGET_ASSEMBLY_DIR/*.ni.dll"
230 sdb $SDB_OPTIONS shell dotnettool --ni-system
231 sdb $SDB_OPTIONS shell dotnettool --ni-regen-all-app
234 sdb $SDB_OPTIONS shell chsmack -a '_' $TARGET_ASSEMBLY_DIR/*
237 cmd=$1; [ $# -gt 0 ] && shift;
239 build|--build|-b) cmd_module_build $@ ;;
240 full |--full |-f) cmd_full_build $@ ;;
241 design|--design) cmd_design_build $@ ;;
242 xamlbuild|--xamlbuild) cmd_xamlbuild_build $@ ;;
243 dummy|--dummy|-d) cmd_dummy_build $@ ;;
244 pack |--pack |-p) cmd_pack $@ ;;
245 install |--install |-i) cmd_install $@ ;;
246 clean|--clean|-c) clean ;;