DEV Community

codemee
codemee

Posted on • Edited on

PlatformIO 的客製化設定

PlatformIO 是個很棒的開發環境, 不過預設安裝下, 有些設定可能不符所需, 本文將介紹幾個使用 PlatformIO 前需要注意的小技巧。

讓 PlatformIO 使用非預設的資料夾

PlatformIO 預設會將各平台的工具鏈安裝在使用者資料夾下的 .platformio 資料夾下, 如果你和我一樣 C 磁碟快爆了, 就會想讓 PlatformIO 使用其他磁碟下的資料夾。要做到這件事, 只要設定 PLATFORMIO_CORE_DIR 環境變數為你希望的路徑, 再重新安裝 PlatformIO 即可, 例如我就改成在 D:\.platformio:
alt text
這樣我就不怕 C: 爆了。

修改預設的專案資料夾

在我安裝的 PlatformIO 中, 建立專案時雖然可以取消勾選 Use default location 選項, 可是我在交談窗中選好資料夾卻無法按 Finish 鈕, 不知道是我安裝的問題還是 PlatformIO 的問題。即使可以, 每次建專案都要選擇資料夾也是有點麻煩, 還好, 只要透過 PlatformIO Core CLI 下指令就可以了:

  1. 在 VSCode 的指令區中執行 PlatformIO: Open PlatformIO Core CLI
  2. 執行以下指令即可更改預設的專案資料夾:

    # pio settings set projects_dir "D:\code\espidf\"
    

上例就是將我的專案預設資料夾更改為 "D:\code\espidf\"。

  1. 以下指令可查詢目前的預設專案資料夾:

    # pio settings get projects_dir
    Name          Current value [Default]                           Description
    ------------  ------------------------------------------------  ----------------------------------------------------------
    projects_dir  D:\code\espidf                                    Default location for PlatformIO projects (PlatformIO Home)
                  [C:\Users\ShinWei\Documents\PlatformIO\Projects]
    

    可以看到已經修改成功了。

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more