Home | History | Annotate | Download | only in tools
      1 #!/bin/bash
      2 
      3 # Verbose by default. Use -q to make more silent.
      4 V="-v"
      5 if [[ "$1" == "-q" ]]; then V=""; shift; fi
      6 
      7 TEMP_SDK_DIR=$1
      8 WIN_OUT_DIR=$2
      9 TOPDIR=${TOPDIR:-$3}
     10 
     11 PLATFORMS=( $TEMP_SDK_DIR/platforms/* )
     12 if [[ ${#PLATFORMS[@]} != 1 ]]; then
     13     echo "Error: Too many platforms found in $TEMP_SDK_DIR"
     14     echo "Only one was expected."
     15     echo "Instead, found: ${PLATFORMS[@]}"
     16     exit 1
     17 fi
     18 THE_PLATFORM=${PLATFORMS[0]}
     19 PLATFORM_TOOLS=$THE_PLATFORM/tools
     20 
     21 # Package USB Driver
     22 if [[ -n "$USB_DRIVER_HOOK" ]]; then
     23     $USB_DRIVER_HOOK $V $TEMP_SDK_DIR $TOPDIR
     24 fi
     25 
     26 # Remove obsolete stuff from tools & platform
     27 TOOLS=$TEMP_SDK_DIR/tools
     28 LIB=$TEMP_SDK_DIR/tools/lib
     29 rm $V $TOOLS/{adb,android,apkbuilder,ddms,dmtracedump,draw9patch,emulator,etc1tool}
     30 rm $V $TOOLS/{hierarchyviewer,hprof-conv,layoutopt,mksdcard,sqlite3,traceview,zipalign}
     31 rm $V $LIB/*/swt.jar
     32 rm $V $PLATFORM_TOOLS/{aapt,aidl,dx,dexdump}
     33 
     34 # Copy all the new stuff in tools
     35 # Note: some tools are first copied here and then moved in platforms/<name>/tools/
     36 cp $V $WIN_OUT_DIR/host/windows-x86/bin/*.{exe,dll} $TOOLS/
     37 mkdir -pv $LIB/x86
     38 cp $V ${TOPDIR}prebuilt/windows/swt/swt.jar         $LIB/x86/
     39 mkdir -pv $LIB/x86_64
     40 cp $V ${TOPDIR}prebuilt/windows-x86_64/swt/swt.jar  $LIB/x86_64/
     41 
     42 # Copy the SDK Setup (aka sdklauncher) to the root of the SDK (it was copied in tools above)
     43 # and move it also in SDK/tools/lib (so that tools updates can update the root one too)
     44 cp $TOOLS/sdklauncher.exe $TEMP_SDK_DIR/"SDK Setup.exe"
     45 mv $TOOLS/sdklauncher.exe $LIB/"SDK Setup.exe"
     46 
     47 # Copy the emulator NOTICE in the tools dir
     48 cp $V ${TOPDIR}external/qemu/NOTICE $TOOLS/emulator_NOTICE.txt
     49 
     50 # aapt under cygwin needs to have mgwz.dll
     51 [[ -n $NEED_MGWZ ]] && cp $V $CYG_MGWZ_PATH $TOOLS/
     52 
     53 # Update a bunch of bat files
     54 cp $V ${TOPDIR}sdk/files/post_tools_install.bat            $LIB/
     55 cp $V ${TOPDIR}sdk/files/find_java.bat                     $LIB/
     56 cp $V ${TOPDIR}sdk/apkbuilder/etc/apkbuilder.bat           $TOOLS/
     57 cp $V ${TOPDIR}sdk/ddms/app/etc/ddms.bat                   $TOOLS/
     58 cp $V ${TOPDIR}sdk/traceview/etc/traceview.bat             $TOOLS/
     59 cp $V ${TOPDIR}sdk/hierarchyviewer/etc/hierarchyviewer.bat $TOOLS/
     60 cp $V ${TOPDIR}sdk/layoutopt/app/etc/layoutopt.bat         $TOOLS/
     61 cp $V ${TOPDIR}sdk/draw9patch/etc/draw9patch.bat           $TOOLS/
     62 cp $V ${TOPDIR}sdk/sdkmanager/app/etc/android.bat          $TOOLS/
     63 
     64 # Put the JetCreator tools, content and docs (not available in the linux SDK)
     65 JET=$TOOLS/Jet
     66 JETCREATOR=$JET/JetCreator
     67 JETDEMOCONTENT=$JET/demo_content
     68 JETLOGICTEMPLATES=$JET/logic_templates
     69 JETDOC=$TEMP_SDK_DIR/docs/JetCreator
     70 
     71 # need to rm these folders since a Mac SDK will have them and it might create a conflict
     72 rm -rf $V $JET
     73 rm -rf $V $JETDOC
     74 
     75 # now create fresh folders for JetCreator
     76 mkdir $V $JET
     77 mkdir $V $JETDOC
     78 
     79 cp -r $V ${TOPDIR}external/sonivox/jet_tools/JetCreator         $JETCREATOR/
     80 cp -r $V ${TOPDIR}external/sonivox/jet_tools/JetCreator_content $JETDEMOCONTENT/
     81 cp -r $V ${TOPDIR}external/sonivox/jet_tools/logic_templates    $JETLOGICTEMPLATES/
     82 chmod $V -R u+w $JETCREATOR  # fixes an issue where Cygwin might copy the above as u+rx only
     83 cp $V ${TOPDIR}prebuilt/windows/jetcreator/EASDLL.dll         $JETCREATOR/
     84 
     85 cp    $V ${TOPDIR}external/sonivox/docs/JET_Authoring_Guidelines.html  $JETDOC/
     86 cp -r $V ${TOPDIR}external/sonivox/docs/JET_Authoring_Guidelines_files $JETDOC/
     87 cp    $V ${TOPDIR}external/sonivox/docs/JET_Creator_User_Manual.html   $JETDOC/
     88 cp -r $V ${TOPDIR}external/sonivox/docs/JET_Creator_User_Manual_files  $JETDOC/
     89 
     90 # Copy or move platform specific tools to the default platform.
     91 cp $V ${TOPDIR}dalvik/dx/etc/dx.bat $PLATFORM_TOOLS/
     92 mv $V $TOOLS/{aapt.exe,aidl.exe,dexdump.exe} $PLATFORM_TOOLS/
     93 
     94 # When building under cygwin, mgwz.dll must be both in SDK/tools for zipalign
     95 # and in SDK/platform/XYZ/tools/ for aapt
     96 [[ -n $NEED_MGWZ ]] && cp $V $TOOLS/mgwz.dll $PLATFORM_TOOLS/
     97 
     98 # Fix EOL chars to make window users happy - fix all files at the top level
     99 # as well as all batch files including those in platforms/<name>/tools/
    100 find $TEMP_SDK_DIR -maxdepth 1 -name "*.[ht]*" -type f -print0 | xargs -0 unix2dos
    101 find $TEMP_SDK_DIR -maxdepth 3 -name "*.bat"   -type f -print0 | xargs -0 unix2dos
    102 
    103 # Just to make it easier on the build servers, we want fastboot and adb (and its DLLs)
    104 # next to the new SDK, so up one dir.
    105 for i in fastboot.exe adb.exe AdbWinApi.dll AdbWinUsbApi.dll; do
    106     cp -f $V $WIN_OUT_DIR/host/windows-x86/bin/$i $TEMP_SDK_DIR/../$i
    107 done
    108