Skip to content
This repository was archived by the owner on Oct 1, 2024. It is now read-only.

Support custom libraries with portable version of Arduino #946

Merged
merged 4 commits into from
Feb 17, 2020

Conversation

raomin
Copy link
Contributor

@raomin raomin commented Dec 19, 2019

When running with a portable version of Adruino IDE, the custom libraries are put in:
--> arduino-1.8.10\portable\sketchbook\libraries
(and not in Documents\Arduino\libraries).

This PR replaces the hard coded ref to Documents\Arduino\libraries with a ref to _settings.sketchbookPath that works with the portable version and the installed one.

@hellyzh
Copy link
Contributor

hellyzh commented Dec 25, 2019

Please check to configure VS Code with Arduino settings for "arduino.path" as below, then the sample will get the correct custom Arduino libraries path. And the hard code one is default folder of downloaded libraries as well as the portable Arduino.
In Visual Studio Code, click File > Preferences > Settings, then click the Open Settings (JSON) icon in the upper-right corner of the Settings page.
"arduino.path": "C:\\Program Files (x86)\\Arduino"

@raomin raomin changed the title Support custom libraries in portable version Support custom libraries with portable version of Arduino Dec 25, 2019
@raomin
Copy link
Contributor Author

raomin commented Dec 25, 2019

Thanks for your feedback @hellyzh .

Maybe I didn't explain clearly, the problem is when you are using a portable version of Arduino IDE (regardless whether you use a portable version of VScode or not).

The purpose of installing Arduino as portable is to place it elsewhere than "C:\Program Files (x86)\Arduino" ; usually in user writable folder, eg C;\users\johndoe\arduino-1.8.10
In this setup, the sketchbook folder is C;\users\johndoe\arduino-1.8.10\sketchbook and the downloaded libs are in C;\users\johndoe\arduino-1.8.10\sketchbook\libraries
Yet the vscode-arduino plugin adds the standard "c:\user\johndoe\documents\arduino\libraries" which does not exists in this case.

More generally, if you move the sketchbook from the user Documents folder, the custom libraries folder is not included...

This patch points it to {arduino.sketchbook}\libraries which is always where Arduino would put it.

@hellyzh hellyzh requested a review from dooriya December 26, 2019 05:34
@raomin
Copy link
Contributor Author

raomin commented Jan 15, 2020

Please @dooriya , can you consider this PR?
I have students with portable version of Arduino and they cannot get their examples working because the custom libraries are not included. As they are beginners it's really not helpful for them.
TIA.

@hellyzh
Copy link
Contributor

hellyzh commented Jan 16, 2020

@raomin, the custom package tools location code should be updated to the same. Could you please also include the change in your PR?

@raomin
Copy link
Contributor Author

raomin commented Jan 16, 2020

Hi @hellyzh, I do not know what custom package tools location is.
I never encountered such folder or libraries Documents\Arduino\hardware\tools (and google neither), so I don't know what it refers to nor what it should point to in a generic approach.

Custom board libraries are already correctly handled per selected board here.

So I beleive the line could be removed. But, if you wish, I could replace
includePath.push(path.join(os.homedir(), "Documents", "Arduino", "hardware", "tools", "**"));
by this
includePath.push(path.join(this._settings.sketchbookPath, "hardware", "tools", "**"));

@hellyzh
Copy link
Contributor

hellyzh commented Jan 17, 2020

I suggest to keep it which will not break any other usage. So please do the replace as you mentioned.

@raomin
Copy link
Contributor Author

raomin commented Jan 17, 2020

Done! PR updated.

@raomin
Copy link
Contributor Author

raomin commented Feb 3, 2020

Hi!
Is there still something blocking this PR?
@dooriya ?

@dooriya
Copy link
Member

dooriya commented Feb 17, 2020

Hi!
Is there still something blocking this PR?
@dooriya ?

The change looks good to me, approved :)
Sorry for the belated response.

@dooriya dooriya merged commit 8137305 into microsoft:master Feb 17, 2020
@elektronikworkshop
Copy link
Contributor

BTW: All this path fiddling will become obsolete anyways with the automagical c_cpp_properties.json configuration I'm currently working on. I have it working here and It's reaching beta for OSX and Linux in the next few days. Windows support will follow.

Progress can be followed here: #438 and especially here.

Regards
EW

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants