[NUI] disable acessibilityPanGesture when scroll disabled.
[platform/core/csapi/tizenfx.git] / build.sh
1 #!/bin/bash -e
2
3 SCRIPT_DIR=$(dirname $(readlink -f $0))
4
5 CONFIGURATION=Release
6 SLN_NAME=_Build
7 SLN_FILE=$SCRIPT_DIR/$SLN_NAME.sln
8 OUTDIR=$SCRIPT_DIR/Artifacts
9
10 PROFILES=(mobile tv wearable)
11 TARGET_ASSEMBLY_DIR=/usr/share/dotnet.tizen/framework
12 TARGET_PRELOAD_DIR=/usr/share/dotnet.tizen/preload
13
14 source $SCRIPT_DIR/packaging/version.txt
15 VERSION_PREFIX=$(expr $NUGET_VERSION : '\([0-9]\+\.[0-9]\+\.[0-9]\+\)')
16
17 usage() {
18   echo "Usage: $0 [command] [args]"
19   echo "Commands:"
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"
26 }
27
28 prepare_solution() {
29   target=$1; [ -z "$target" ] && target="full"
30
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
34   fi
35   if [ "$target" == "internal" -o "$target" == "full" ]; then
36     dotnet sln $SLN_FILE add $SCRIPT_DIR/internals/src/*/*.csproj
37   fi
38   if [ "$target" == "design" ]; then
39     dotnet sln $SLN_FILE add $SCRIPT_DIR/src/*/*.Design.csproj
40   else
41     dotnet sln $SLN_FILE remove $SCRIPT_DIR/src/*/*.Design.csproj
42   fi
43 }
44
45 cleanup_solution() {
46   rm -f $SLN_FILE
47 }
48
49 remove_intermediates() {
50   find $1 -type d \
51     \( -name obj -o -name bin \) -print0 | xargs -0 -I {} rm -fr "{}"
52 }
53
54 clean() {
55   remove_intermediates $SCRIPT_DIR/build/
56   remove_intermediates $SCRIPT_DIR/src/
57   remove_intermediates $SCRIPT_DIR/internals/src/
58   rm -fr $OUTDIR
59   rm -f msbuild.log
60   cleanup_solution
61 }
62
63 restore() {
64   if [ -d /nuget ]; then
65     dotnet restore -s /nuget $@
66   else
67     dotnet restore $@
68   fi
69 }
70
71 build() {
72   dotnet build --no-restore -c $CONFIGURATION /fl $@
73 }
74
75 copy_artifacts() {
76   mkdir -p $2
77   for proj in $(ls -d1 $1/*/); do
78     if [ -d $proj/bin/$CONFIGURATION ]; then
79       cp -fr $proj/bin/$CONFIGURATION/*/* $2
80     fi
81   done
82 }
83
84 build_artifacts() {
85   copy_artifacts $SCRIPT_DIR/src $OUTDIR/bin/public
86   copy_artifacts $SCRIPT_DIR/internals/src $OUTDIR/bin/internal
87
88   # move preload
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 || :
92
93   # merge filelist
94   for profile in ${PROFILES[@]}; do
95     list=$(cat $OUTDIR/bin/public/*.$profile.filelist \
96                $OUTDIR/bin/internal/*.$profile.filelist \
97                | sort | uniq)
98     rm -f $OUTDIR/$profile.filelist
99     for item in $list; do
100       if [[ "$item" == *.preload ]]; then
101         echo $TARGET_PRELOAD_DIR/$item >> $OUTDIR/$profile.filelist
102       else
103         echo $TARGET_ASSEMBLY_DIR/$item >> $OUTDIR/$profile.filelist
104       fi
105     done
106   done
107 }
108
109 cmd_module_build() {
110   if [ -z "$1" ]; then
111     echo "No module specified."
112     exit 1
113   fi
114   module=$1; shift;
115   sources=(src internals/src)
116   for src in $sources; do
117     project=$SCRIPT_DIR/$src/$module/$module.csproj
118     echo $project
119     if [ -f "$project" ]; then
120       restore $project
121       build $project $@
122     fi
123   done
124 }
125
126 cmd_full_build() {
127   clean
128   prepare_solution full
129   restore $SLN_FILE $@
130   build $SLN_FILE $@
131   cleanup_solution
132   build_artifacts
133   cmd_dummy_build
134 }
135
136 cmd_design_build() {
137   prepare_solution design
138   restore $SLN_FILE
139   build $SLN_FILE $@
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/
144     fi
145   done
146   cleanup_solution
147 }
148
149 cmd_dummy_build() {
150   if [ ! -d $OUTDIR/bin/public/ref  ]; then
151     echo "No assemblies to read. Build TizenFX first."
152     exit 1
153   fi
154   mkdir -p $OUTDIR/bin/dummy
155   dotnet $SCRIPT_DIR/tools/bin/APITool.dll \
156          dummy $OUTDIR/bin/public/ref $OUTDIR/bin/dummy
157 }
158
159 cmd_pack() {
160   VERSION=$1
161   if [ -z "$VERSION" ]; then
162     pushd $SCRIPT_DIR > /dev/null
163     VERSION=$VERSION_PREFIX.$((10000+$(git rev-list --count HEAD)))
164     popd > /dev/null
165   fi
166
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)
174   done
175 }
176
177 cmd_install() {
178   DEVICE_ID=$1
179
180   RUNTIME_ASSEMBLIES="$OUTDIR/bin/public/*.dll $OUTDIR/bin/internal/*.dll"
181
182   device_cnt=$(sdb devices | grep -v "List" | wc -l)
183
184   if [ $device_cnt -eq 0 ]; then
185     echo "No connected devices"
186     exit 1
187   fi
188
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])"
191     sdb devices
192     exit 1
193   fi
194
195   SDB_OPTIONS=""
196   if [ -n "$DEVICE_ID" ]; then
197     SDB_OPTIONS="-s $DEVICE_ID"
198   fi
199
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
203
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 dotnettool --ni-system
208     sdb $SDB_OPTIONS shell dotnettool --ni-regen-all-app
209   fi
210
211   sdb $SDB_OPTIONS shell chsmack -a '_' $TARGET_ASSEMBLY_DIR/*
212 }
213
214 cmd=$1; [ $# -gt 0 ] && shift;
215 case "$cmd" in
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 ;;
223   *) usage ;;
224 esac