Assuming you want to build multiple apks for multiple resolutions on android or just have faster apk upload time to your android device during development.
Considering you want to copy from /myapp/resources/ to /myapp/android/assets/ for several resolutions and you want only to click once for each resolution build.
To accomplish this i recommend using rsycn/ and cygwin.
You might have these script files in:
/myapp/scripts/320x_CopyAssets.bat
/myapp/scripts/480x_CopyAssets.bat
/myapp/scripts/540x_CopyAssets.bat
/myapp/scripts/600x_CopyAssets.bat
/myapp/scripts/720x_CopyAssets.bat
/myapp/scripts/768x_CopyAssets.bat
/myapp/scripts/800x_CopyAssets.bat
/myapp/scripts/1080x_CopyAssets.bat
/myapp/scripts/copy_assets.sh
/myapp/IgnoreCopyAssets/IgnoreCopyAssets.txt
/myapp/IgnoreCopyAssets/320x_IgnoreCopyAssets.txt
/myapp/IgnoreCopyAssets/480x_IgnoreCopyAssets.txt
/myapp/IgnoreCopyAssets/540x_IgnoreCopyAssets.txt
/myapp/IgnoreCopyAssets/600x_IgnoreCopyAssets.txt
/myapp/IgnoreCopyAssets/720x_IgnoreCopyAssets.txt
/myapp/IgnoreCopyAssets/768x_IgnoreCopyAssets.txt
/myapp/IgnoreCopyAssets/800x_IgnoreCopyAssets.txt
/myapp/IgnoreCopyAssets/1080x_IgnoreCopyAssets.txt
Where you merely send the desired resolution at to the actually copy_assets shell script. (e.g the 768x_CopyAssets.bat)
1 2 3 4 | @echo off set PATH=%~dp0msys\bin;%~dp0win-rsync;%PATH% sh copy_assets.sh WIN 768 PAUSE |
The copy_assets.sh would look like:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | SCRIPT_PATH=$( (cd -P $(dirname $0) && pwd) ) RSYNC_CMD="rsync -aCx --progress --exclude-from 'IgnoreCopyAssets/IgnoreCopyAssets.txt'" if [ $# -ge 1 ];then if [ $# -ge 2 ];then case "$2" in 320) RSYNC_CMD="$RSYNC_CMD --exclude-from 'IgnoreCopyAssets/320x_IgnoreCopyAssets.txt'" ;; 480) RSYNC_CMD="$RSYNC_CMD --exclude-from 'IgnoreCopyAssets/480x_IgnoreCopyAssets.txt'" ;; 540) RSYNC_CMD="$RSYNC_CMD --exclude-from 'IgnoreCopyAssets/540x_IgnoreCopyAssets.txt'" ;; 600) RSYNC_CMD="$RSYNC_CMD --exclude-from 'IgnoreCopyAssets/600x_IgnoreCopyAssets.txt'" ;; 720) RSYNC_CMD="$RSYNC_CMD --exclude-from 'IgnoreCopyAssets/720x_IgnoreCopyAssets.txt'" ;; 768) RSYNC_CMD="$RSYNC_CMD --exclude-from 'IgnoreCopyAssets/768x_IgnoreCopyAssets.txt'" ;; 800) RSYNC_CMD="$RSYNC_CMD --exclude-from 'IgnoreCopyAssets/800x_IgnoreCopyAssets.txt'" ;; 1080) RSYNC_CMD="$RSYNC_CMD --exclude-from 'IgnoreCopyAssets/1080x_IgnoreCopyAssets.txt'" ;; esac fi if [ $1 = "WIN" ];then SCRIPT_PATH=$(dirname $0) # Otherwise rsync will think it's remote RSYNC_CMD="$RSYNC_CMD --chmod=ugo=rwX" # Otherwise permissions are screwed up fi fi RSYNC_CMD_W_DELETE="$RSYNC_CMD --delete" ############################################################################### echo RUN ASSETS SYNCING SHELL SCRIPT asset_source_path=$SCRIPT_PATH/../resources asset_destination_path=$SCRIPT_PATH/../android/assets $RSYNC_CMD_W_DELETE $asset_source_path/* $asset_destination_path # The wildcard in rsync leads missing deletion in the top-level directory so let's fix that diff -arq $asset_source_path $asset_destination_path | grep "Only in $asset_destination_path" | cut -d" " -f4 | xargs -I{} rm -r -f $asset_destination_path/{} |
And in case you want to ignore files or dirs you can use IgnoreCopyAssets.txt
1 2 3 | .svn .git/ HelloWorld.png |
Or the other resolutions (e.g the 768x_IgnoreCopyAssets.txt) Note: you can use # to comment files or directories out. ;)
1 2 3 4 5 6 7 8 | graphics/320x graphics/480x graphics/540x graphics/600x graphics/720x #graphics/768x graphics/800x graphics/1080x |
Conclusion
Easy to use scripts to copy assets and remove all unwanted ones from your assets folder plus the posibility to ignore files and dirs on demand. Enjoy :)
Leave a Reply