从零开始设置 Mac OS 环境下的工具链(传统 GNU Make)
[English]
注解
ESP-IDF V4.0 及之后版本的默认构建系统为 CMake。本文档主要针对之前基于 GNU Make 的传统构建系统。请注意,未来,我们可能不会继续支持基于 GNU Make 的构建系统。
注解
安装工具链的标准方法请见 这里。请参考 工具链自定义设置 章节,查看可能需要从头开始设置工具链的情况。
安装准备
安装 pip:
sudo easy_install pip
从源代码编译工具链
安装依赖项:
对于 MacPorts:
sudo port install gsed gawk binutils gperf grep gettext wget libtool autoconf automake
对于 homebrew:
brew install gnu-sed gawk binutils gperftools gettext wget help2man libtool autoconf automake
创建一个文件系统镜像(区分大小写):
hdiutil create ~/esp/crosstool.dmg -volname "ctng" -size 10g -fs "Case-sensitive HFS+"
挂载:
hdiutil mount ~/esp/crosstool.dmg
创建指向您工作目录的符号链接:
mkdir -p ~/esp
ln -s /Volumes/ctng ~/esp/ctng-volume
前往新创建的目录
cd ~/esp/ctng-volume
下载并编译 crosstool-NG
:
git clone https://github.com/espressif/crosstool-NG.git
cd crosstool-NG
git checkout esp-2021r1
git submodule update --init
./bootstrap && ./configure --enable-local && make
编译工具链:
./ct-ng xtensa-esp32-elf
./ct-ng build
chmod -R u+w builds/xtensa-esp32-elf
编译得到的工具链会被保存到 ~/esp/ctng-volume/crosstool-NG/builds/xtensa-esp32-elf
。请按照 标准设置指南 的介绍,将工具链添加到 PATH
。