Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Developing Arduino Libraries using Visual Studio/Micro and Github (Read 2863 times)
Pascal Roobrouck
Junior Member
**
Offline


Posts: 19
Joined: Mar 3rd, 2017
Developing Arduino Libraries using Visual Studio/Micro and Github
Jun 6th, 2018 at 10:03am
Print Post  
I would like to know what are the best practices for developing Arduino libraries, making them compatible with the Arduino IDE 1.5: Library specification and using Github.

Here is how I do it right now (but maybe there is a smarter way)

1. create a repository in github (on my computer this is in a folder under ...\documents\github, eg. ...\documents\github\mynewlibrary). Set up the contents of this folder according to the Arduino IDE 1.5: Library specification.

2. do a local commit to Github, then sync with Github.com
The files can now be downloaded from Github as a .zip library, and installed in Arduino IDE and Visual Micro. Doing so they arrive in ...\documents\arduino\libraries\mynewlibrary-master

3. now you can use the library in a new project, and at the same time edit and further develop the library as a second project : see https://www.visualmicro.com/pics/Arduino-Shared-Library_5.png - although I don't know yet how to get visual micro open the library as a project... (help needed  Tongue)

4. when ready for a new release of your library, you sync the files between :
* ...\documents\arduino\libraries\mynewlibrary-master
* ...\documents\github\mynewlibrary
using a filesync tool like FreeFileSync
Then commit changes to Github and sync with Github.com


Your ideas on how to improve / finetune this process are appreciated!
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Developing Arduino Libraries using Visual Studio/Micro and Github
Reply #1 - Jun 6th, 2018 at 11:08am
Print Post  
Below is the answer I have given in other threads. You are already on the way but I think you just need to step back and explore VS/VM then GIT is easy.

If you use option A you just need a shared project which in VS terms is just a project file with .vcxitems extension instead of .vcxproj extension. You should use the visual micro options to "Create a project when adding libraries" simply to see how a shared project looks.

When you see a shared project you should realize that you can just add a .vcxitems file with same name as your library to your library project then you can add it to your solution that also contains your arduino project. Then add a Reference>SharedProject from the Arduino project to the shared lib project. See the readme.txt when Visual Micro creates a shared lib project for you. OR use file>new>project>C++>arduino library. 

All VS .vcxitems and .vxcproj files are just text files that you can edit with notepad but you should not need to when you explore the various workflows.

So option A gives you a cross platform library that is GIT capable and will work nicely with your Arduino project(s)

Option B is simpler and gives the library sources below the project. The lib sources are then included in the project/solution explorer as if part of the arduino project. The entire single Arduino project can then be checked into GIT which will automatically include your local libraries. Libraries in the specified location in an Arduino project are treated as normal libraries.


You can use the 1.5 spec or older for libs but they MUST have the library.properties file. 

You can also right click a library properties in the "solution explorer > publish library" to have the library "Published to your sketchbook/libraries folder". 

The -master is not used because it is just some rubbish that git uses. Normally, you can rename any "-master" folders to normal because both arduino ide and visual micro do some internal rubbish to remove the "-master" rubbish when attempting to resolve libraries Smiley



Option A
  Create (or let visual micro create) shared library projects (see the checkbox on the "Add Library" menu for an example). Then right click "References" for your your Arduino project and and add the libraries as "Shared Projects". Using this system the libraries can be in any location. There is also a "File>New>C++>Arduino Library" which shows more clearly how a library can become a "shared library project".

or 

Option B
  You can copy libraries to "project_folder\_micro-api\libraries" and then include them in the project using right click in the solution explorer. You will need to click the little "show all files" icon above the solution explorer to see the libraries you copied using windows explorer. Visual Micro will use the local libraries sources during builds but will treat them as libraries and not local project code. However, they will also be a part of the project as far as any GIT tools are concerned

  
Back to top
WWW  
IP Logged
 
Pascal Roobrouck
Junior Member
**
Offline


Posts: 19
Joined: Mar 3rd, 2017
Re: Developing Arduino Libraries using Visual Studio/Micro and Github
Reply #2 - Jun 6th, 2018 at 11:58am
Print Post  
Thanks Tim,

looks like option A is the more robust one.
Thanks for the tip about the -master postfix... another annoyance solved

After mastering this technique, I will look into using Git directly from within VS, instead of using the Windows Git client and syncing files between VS/VM and the local Git repositories. After MS buying Github, I think this will be the preferred way of working in the future.

have a nice day!
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Developing Arduino Libraries using Visual Studio/Micro and Github
Reply #3 - Jun 6th, 2018 at 12:03pm
Print Post  
Take a look at "tools>extensions and updates". There is a GIT extension that has been downloaded 58 million times so it should be okay but I haven't used it.
  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint