Setting up a Mac OS build environment

  In a default installation, Mac OS runs on a case-preserving but case-insensitive filesystem. This type of filesystem is not supported by git and will cause some git commands (such as git status) to behave abnormally. Because of this, we recommend that you always work with the AOSP source files on a case-sensitive filesystem. This can be done fairly easily using a disk image, discussed below.

  Once the proper filesystem is available, building the master branch in a modern Mac OS environment is very straightforward. Earlier branches, including ICS, require some additional tools and SDKs.

  Creating a case-sensitive disk image

  You can create a case-sensitive filesystem within your existing Mac OS environment using a disk image. To create the image, launch Disk Utility and select "New Image". A size of 25GB is the minimum to complete the build; larger numbers are more future-proof. Using sparse images saves space while allowing to grow later as the need arises. Be sure to select "case sensitive, journaled" as the volume format.

  You can also create it from a shell with the following command:

 hdiutil create -type SPARSE -fs 'Case-sensitive Journaled HFS+' -size 40g ~/android.dmg

  This will create a .dmg (or possibly a .dmg.sparsefile) file which, once mounted, acts as a drive with the required formatting for Android development.

  If you need a larger volume later, you can also resize the sparse image with the following command:

hdiutil resize -size <new-size-you-want>g ~/android.dmg.sparseimage

For a disk image named android.dmg stored in your home directory, you can add helper functions to your~/.bash_profile:

  • To mount the image when you execute mountAndroid:
    mount the android file image
    function mountAndroid { hdiutil attach ~/android.dmg -mountpoint /Volumes/android; }

    Note: If your system created a .dmg.sparsefile file, replace ~/android.dmg with~/android.dmg.sparsefile.

  • To unmount it when you execute umountAndroid:
    unmount the android file image
    function umountAndroid() { hdiutil detach /Volumes/android; }

  Once you've mounted the android volume, you'll do all your work there. You can eject it (unmount it) just like you would with an external drive.

posted @ 2015-05-26 10:35  solo_heart  阅读(281)  评论(0编辑  收藏  举报