macos-setup-scratch.rst 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. ***********************************************
  2. 从零开始设置 macOS 环境下的工具链
  3. ***********************************************
  4. :link_to_translation:`en:[English]`
  5. 软件包管理器
  6. ===============
  7. 从零开始设置工具链,您需要安装 MacPorts_ 或 Homebrew_ 软件包管理器。或者,您也可以直接下载 :doc:`预编译的工具链 <macos-setup>`。
  8. MacPorts 需要完整的 XCode 软件,而 Homebrew 只需要安装 XCode 命令行工具即可。
  9. .. _Homebrew: https://brew.sh/
  10. .. _MacPorts: https://www.macports.org/install.php
  11. 请参考 :ref:`工具链自定义设置 <get-started-customized-setup>` 章节,查看可能需要从头开始设置工具链的情况。
  12. 安装准备
  13. =====================
  14. - 安装 pip::
  15. sudo easy_install pip
  16. - 安装 pyserial::
  17. pip install --user pyserial
  18. - 安装 CMake 和 Ninja 编译工具:
  19. - 若有 Homebrew,您可以运行::
  20. brew install cmake ninja dfu-util
  21. - 若有 MacPorts,您可以运行::
  22. sudo port install cmake ninja dfu-util
  23. 从源代码编译工具链
  24. =================================
  25. 安装依赖项:
  26. - 对于 MacPorts::
  27. sudo port install gsed gawk binutils gperf grep gettext wget libtool autoconf automake make
  28. - 对于 Homebrew::
  29. brew install gnu-sed gawk binutils gperftools gettext wget help2man libtool autoconf automake make
  30. 创建一个文件系统镜像(区分大小写)::
  31. hdiutil create ~/esp/crosstool.dmg -volname "ctng" -size 10g -fs "Case-sensitive HFS+"
  32. 挂载::
  33. hdiutil mount ~/esp/crosstool.dmg
  34. 创建指向您工作目录的符号链接::
  35. mkdir -p ~/esp
  36. ln -s /Volumes/ctng ~/esp/ctng-volume
  37. 前往新创建的目录::
  38. cd ~/esp/ctng-volume
  39. 下载并编译 ``crosstool-NG``:
  40. .. include-build-file:: inc/scratch-build-code.inc
  41. 编译工具链::
  42. ./ct-ng {IDF_TARGET_TOOLCHAIN_PREFIX}
  43. ./ct-ng build
  44. chmod -R u+w builds/{IDF_TARGET_TOOLCHAIN_PREFIX}
  45. 编译得到的工具链会被保存到 ``~/esp/ctng-volume/crosstool-NG/builds/{IDF_TARGET_TOOLCHAIN_PREFIX}``。使用工具链前,请将 ``~/esp/ctng-volume/crosstool-NG/builds/{IDF_TARGET_TOOLCHAIN_PREFIX}/bin`` 添加至 ``PATH`` 环境变量。
  46. 后续步骤
  47. ==========
  48. 请前往 :ref:`get-started-get-esp-idf` 章节继续设置开发环境。