Incorporating external source code directories into an AS7 project

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm running Microchip Studio V 7.0.2542 on Windows 10.

 

I'd like to create a project that incorporates .c and .h files from several external directories.  What is the "idiomatically correct" way do accomplish this in AS7?

 

So far, what I've done is to create folders inside my AS7 project that parallels the external folder structure, then add a link to each external .c and .h file, but that can't possibly be the best way.  Is it?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The easiest method is first to

 

1) Click on the "show all files" icon at the top of the solution explorer

2) Right click on the directories (or files) you want to include and select "include in project"

 

Note that the directories must be in the project directory for this to work

 

 

 

 

John Malaugh

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You'll note that the OP states:

I'd like to create a project that incorporates .c and .h files from several external directories.

Except for that detail, your answer works well. 

 

I could write a script that copies the external files into the project directory prior to building, but I was hoping for something less prone to error. 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There are two main ways to do this:

  • Right click your project in Solution Explorer, Add, Existing File. In the pop-up window is a small arrow next to the add button, select 'Add as Link'. You do NOT need to move the files into the solution or project directory to use this. Note you will need to add the path to where these files live in the Directories section of the project configuration (again, right click on your project in Solution Explorer and navigate to Properties -> Directories. You need to do this for #includes to work.
  • If using Git, insert the files as a Git submodule into your master repository (which is a whole subject in itself, and whilst submodules are marmite - used properly, they are great - and have been vastly improved in recently Git releases).