Skip to content

Added an option to use a local arduino-cli.yaml to add, for example, custom library paths. Which is a common request. #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,11 @@
"default": false,
"markdownDescription": "Use Arduino CLI installed instead of the legacy Arduino IDE. If `#arduino.path#` and `#arduino.commandPath#` are not set, the extension will use a version of Arduino CLI bundled with the extension. (Requires a restart after change)"
},
"arduino.useLocalArduinoCliConfigFile": {
"type": "boolean",
"default": false,
"markdownDescription": "Use a local arduino-cli.yaml file instead the default .../Arduino15/arduino-cli.yaml. (Requires a restart after change)"
},
"arduino.path": {
"type": "string",
"default": "",
Expand Down
4 changes: 4 additions & 0 deletions src/arduino/arduino.ts
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,10 @@ export class ArduinoApp {
}
}

if (this.useArduinoCli() && this._settings.useLocalArduinoCliConfigFile) {
args.push("--config-file", path.join(ArduinoWorkspace.rootPath, "arduino-cli.yaml"));
}

if (dc.buildPreferences) {
for (const pref of dc.buildPreferences) {
// Note: BuildPrefSetting makes sure that each preference
Expand Down
8 changes: 8 additions & 0 deletions src/arduino/arduinoSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface IArduinoSettings {
preferencePath: string;
preferences: Map<string, string>;
useArduinoCli: boolean;
useLocalArduinoCliConfigFile: boolean;
usingBundledArduinoCli: boolean;
analyzeOnSettingChange: boolean;
reloadPreferences(): void;
Expand All @@ -43,6 +44,8 @@ export class ArduinoSettings implements IArduinoSettings {

private _useArduinoCli: boolean;

private _useLocalArduinoCliConfigFile: boolean;

private _usingBundledArduinoCli: boolean = false;

private readonly bundledArduinoCliName: { [platform: string]: string } = {
Expand All @@ -62,6 +65,7 @@ export class ArduinoSettings implements IArduinoSettings {
const platform = os.platform();
this._commandPath = VscodeSettings.getInstance().commandPath;
this._useArduinoCli = VscodeSettings.getInstance().useArduinoCli;
this._useLocalArduinoCliConfigFile = VscodeSettings.getInstance().useLocalArduinoCliConfigFile;
await this.tryResolveArduinoPath();
if (platform === "win32") {
await this.updateWindowsPath();
Expand Down Expand Up @@ -171,6 +175,10 @@ export class ArduinoSettings implements IArduinoSettings {
return this._useArduinoCli;
}

get useLocalArduinoCliConfigFile() {
return this._useLocalArduinoCliConfigFile;
}

public get usingBundledArduinoCli() {
return this._usingBundledArduinoCli;
}
Expand Down
10 changes: 10 additions & 0 deletions src/arduino/vscodeSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const configKeys = {
IGNORE_BOARDS: "arduino.ignoreBoards",
SKIP_HEADER_PROVIDER: "arduino.skipHeaderProvider",
USE_ARDUINO_CLI: "arduino.useArduinoCli",
USE_LOCAL_ARDUINO_CLI_CONFIG_FILE: "arduino.useLocalArduinoCliConfigFile",
DISABLE_INTELLISENSE_AUTO_GEN: "arduino.disableIntelliSenseAutoGen",
ANALYZE_ON_OPEN: "arduino.analyzeOnOpen",
ANALYZE_ON_SETTING_CHANGE: "arduino.analyzeOnSettingChange",
Expand All @@ -34,6 +35,7 @@ export interface IVscodeSettings {
ignoreBoards: string[];
skipHeaderProvider: boolean;
useArduinoCli: boolean;
useLocalArduinoCliConfigFile: boolean;
disableIntelliSenseAutoGen: boolean;
analyzeOnOpen: boolean;
analyzeOnSettingChange: boolean;
Expand Down Expand Up @@ -123,6 +125,14 @@ export class VscodeSettings implements IVscodeSettings {
return this.setConfigValue(configKeys.USE_ARDUINO_CLI, value, true);
}

public get useLocalArduinoCliConfigFile(): boolean {
return this.getConfigValue(configKeys.USE_LOCAL_ARDUINO_CLI_CONFIG_FILE);
}

public setUseLocalArduinoCliConfigFile(value: boolean): Promise<void> {
return this.setConfigValue(configKeys.USE_LOCAL_ARDUINO_CLI_CONFIG_FILE, value, true);
}

public get skipHeaderProvider(): boolean {
return this.getConfigValue<boolean>(configKeys.SKIP_HEADER_PROVIDER);
}
Expand Down
Loading