📖

ArduinoIDE に ccache 導入

2022/02/25に公開

ビルドを高速化・準備

$ brew update
$ brew install ccache

$ mkdir /var/tmp/arduino

$ ccache -M 20G
$ ccache -s

設定

  1. arduino を 立ち上げる
  2. file - preference で preference.txtをクリックして、ファイルを開く
  3. arduino を 閉じる
  4. 2のファイルにbuild.path=/var/tmp/arduinoを追加する
  5. /Users/xxxx/Library/Arduino15/packages/esp32/hardware/esp32/1.0.4/platform.txtなどを開く
## Compile c files
recipe.c.o.pattern=/usr/local/bin/ccache "{compiler.path}{compiler.c.cmd}" {compiler.cpreprocessor.flags} {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_BOARD="{build.board}" -DARDUINO_VARIANT="{build.variant}" {compiler.c.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"

## Compile c++ files
recipe.cpp.o.pattern=/usr/local/bin/ccache "{compiler.path}{compiler.cpp.cmd}" {compiler.cpreprocessor.flags} {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_BOARD="{build.board}" -DARDUINO_VARIANT="{build.variant}" {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"

のように、recipe.co.o.patternとrecipe.cpp.o.patternにccacheを追加する
今回は絶対パス指定。

動作確認

ビルドする際にccacheが有効になっているかを確認するために環境設定からより詳細な情報を表示するコンパイルにチェックを入れてコンパイラの警告は全てにしておきます

$ /usr/local/bin/ccache -s

参考

arduino で ccache (ESP32, M5StickC等 編) - Qiita

Discussion