macos-setup-scratch.rst 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. ***********************************************
  2. Setup Toolchain for Mac OS from Scratch (CMake)
  3. ***********************************************
  4. :link_to_translation:`zh_CN:[中文]`
  5. .. include:: ../cmake-warning.rst
  6. Package Manager
  7. ===============
  8. To set up the toolchain from scratch, rather than :doc:`downloading a pre-compiled toolchain<macos-setup>`, you will need to install either the MacPorts_ or homebrew_ package manager.
  9. MacPorts needs a full XCode installation, while homebrew only needs XCode command line tools.
  10. .. _homebrew: https://brew.sh/
  11. .. _MacPorts: https://www.macports.org/install.php
  12. See :ref:`Customized Setup of Toolchain <get-started-customized-setup>` section for some of the reasons why installing the toolchain from scratch may be necessary.
  13. Install Prerequisites
  14. =====================
  15. - install pip::
  16. sudo easy_install pip
  17. - install pyserial::
  18. pip install --user pyserial
  19. - install CMake & Ninja build:
  20. - If you have HomeBrew, you can run::
  21. brew install cmake ninja
  22. - If you have MacPorts, you can run::
  23. sudo port install cmake ninja
  24. Compile the Toolchain from Source
  25. =================================
  26. - Install dependencies:
  27. - with MacPorts::
  28. sudo port install gsed gawk binutils gperf grep gettext wget libtool autoconf automake make
  29. - with homebrew::
  30. brew install gnu-sed gawk binutils gperftools gettext wget help2man libtool autoconf automake make
  31. Create a case-sensitive filesystem image::
  32. hdiutil create ~/esp/crosstool.dmg -volname "ctng" -size 10g -fs "Case-sensitive HFS+"
  33. Mount it::
  34. hdiutil mount ~/esp/crosstool.dmg
  35. Create a symlink to your work directory::
  36. mkdir -p ~/esp
  37. ln -s /Volumes/ctng ~/esp/ctng-volume
  38. Go into the newly created directory::
  39. cd ~/esp/ctng-volume
  40. Download ``crosstool-NG`` and build it:
  41. .. include:: /_build/inc/scratch-build-code.inc
  42. Build the toolchain::
  43. ./ct-ng xtensa-esp32-elf
  44. ./ct-ng build
  45. chmod -R u+w builds/xtensa-esp32-elf
  46. Toolchain will be built in ``~/esp/ctng-volume/crosstool-NG/builds/xtensa-esp32-elf``. Follow :ref:`instructions for standard setup <setup-macos-toolchain-add-it-to-path-cmake>` to add the toolchain to your ``PATH``.
  47. Next Steps
  48. ==========
  49. To carry on with development environment setup, proceed to section :ref:`get-started-get-esp-idf-cmake`.