0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

JetBrains CLion + PlatformIO (macOS)

Last updated at Posted at 2023-03-19

概要

PlatformIO を macOS 上で JetBrains の C/C++ 開発用 IDE である CLion から使う方法についてごく簡単に整理してみました。

非商用であれば無償で使えるようになったようなので、ぜひ使ってみてください!

以下の記事を参考にさせて頂きました。インストール後の使い方についてはこちらのほうが詳しく記述されていますのでこちらも合わせてご参照ください。

インストール

参考) Installation - PlatformIO

Python 3 のインストール

PlatformIO の実行には Python 3 が必要です。Homebrew でインストールする場合は以下のコマンドでインストールします。

brew install python

PlatformIO Core のインストール

PlatformIO の CLI 版である PlatformIO Core をインストールします。こちらも Homebrew でインストールできるようですが、システムを汚したくない場合は推奨手順に従ってインストーラースクリプトを使います。これにより、ホームディレクトリの ~/.platformio/ 配下にインストールされます。

curl -fsSL -o get-platformio.py https://raw.githubusercontent.com/platformio/platformio-core-installer/master/get-platformio.py
python3 get-platformio.py

次に、インストールしたシェルコマンドを使うためパスを設定します。手順に従って、~/.platformio/penv/bin にインストールされたコマンドに ~/.local/bin からリンクします。

ln -s ~/.platformio/penv/bin/platformio ~/.local/bin/platformio
ln -s ~/.platformio/penv/bin/pio ~/.local/bin/pio
ln -s ~/.platformio/penv/bin/piodebuggdb ~/.local/bin/piodebuggdb

その上で、~/.local/bin にパスを通します。(Bash なら ~/.bash_profile など)

export PATH="${HOME}/.local/bin:${PATH}"

PlatformIO for CLion プラグインのインストール

CLion に PlatformIO for CLion プラグインをインストールします。

PlatformIO for CLion

プロジェクトの作成

プロジェクトを新規作成

メニューの File > New > Project... から、新規プロジェクトを作成します。ターゲットに「PlatformIO」、Board に開発対象のデバイスを選択します。

New Project

既存のプロジェクトを開く

メニューの Open > Open... から、既存の PlatformIO プロジェクトのディレクトリを選択します。

PlatformIO プロジェクト設定

PlatformIO プロジェクトに対する各種設定は、CLion から離れて別途 PlatformIO のホーム画面からおこないます。

CLI から platformio home コマンドを実行するか、CLIon メニューの Tools > PlatformIO > Home から PlatformIO のホーム画面を表示します。設定用の Web サーバーがローカル PC 上で動作し、ブラウザを UI としてアクセスします。プロジェクトの設定に変更を加えた場合は、CLion のメニューから Tool > PlatformIO > Reload PlatformIO Project を実行して設定を反映します。

基本操作

ファームウェアのビルド・書き込み

ウインドウ右上にある以下の部分から、Environment を選択して各アイコンをクリックします。アイコンは左から「Build」「Run」「Debug」となっています。

Build

その他の操作

Tool Window の PlatformIO から各種操作をおこなうことができます。

Build

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?