Multiple disjoint source directories: Really this convoluted? [message #184355] |
Fri, 09 February 2007 18:51  |
Eclipse User |
|
|
|
Originally posted by: noreally.notaserver.com
Folks:
In this posting, I describe what I needed to do to create a project from
existing source featuring disjoint source dirs, so that:
a) Others stumbling down the same path might gain something.
b) Anyone who knows better can correct me.
FWIW Eclipse 3.3M4, CDT 4, linux.
The scenario is the not-uncommon situation of a big pile of existing C
source, spread over multi directories, with multiple executables to be
built. Each executable is composed from a main() file somewhere, plus other
files from other directories. Example:
/bigdir/source1 contains a file with main()
/bigdir/include .h headers for other helper .c files
/bigdir/helper_source helper .c files
/bigdir/lots_of_other_dirs irrelevant other stuff
.... ie: I want source1, include and helper_source, but not
lots_of_other_dirs.
It's possible to follow the CDT FAQ "How do I create a new project using a
directory full of existing source?"... select the top directory and make one
big project out of the whole thing. I've done this on a collection of about
500 .c files (about 200 executables) and it "works" but using the IDE is
very slow.
So, if wanting to work on a single executable, surely it's possible to make
a focused project for just that executable, and selectively include source
by picking and choosing directories?
The obvious way to do this would be to again follow the FAQ article,
initially select the main() dir(source1), and then later add additional
source dirs... but this path is blocked it seems.
Once the initial project is established with the first source dir, it is
indeed possible to add the include dir using Project Properties > C/C++
Include Paths > Add External Include Path..., after which you can indeed
browse to those files. Good. ("External" refers to "outside project's source
dir?)
But there appears no way to add additional source dirs.
Project Properties > C/C++ Project Paths > Source tab looks like the place
to add more folders. But the only Add button (no "Add External") invokes a
dialog with no way to navigate outside the previously specified source dir,
and no way to type anything in.
So, here's what I found *did* work:
1. Following CDT FAQ I created the project for source1 (and added the
include dir as well). I selected the project and ran Rebuild Index
2. Again following CDT FAQ I create a second project, this time for
helper_source. Again ran Rebuild Index.
3. I selected the source1 project > Project Properties > C/C++ Project Files
> Projects. If the helper_source project is open at this stage, it appears
in the Projects list, and can be check-marked to add it as required for the
current project.
At this point I found that I could browse from source1 main() to actual
definitions in helper_source (not just declarations in include). Yay --
that's my first milestone.
Outstanding Questions:
----------------------
1) Is this the intended way to do this? Why can't other source dirs just be
added to the original (source1) project?
2) I have not explored whether this builds properly, or whether eclipse
notices edits and rebuilds index properly etc. I figured I'd examine that
after someone lets me know this is the appropriate approach.
Thanks,
Graham
|
|
|
|
|
Re: Multiple disjoint source directories: Really this convoluted? [message #184389 is a reply to message #184380] |
Sun, 11 February 2007 12:20   |
Eclipse User |
|
|
|
Originally posted by: asdf.dd.dd
>
>> Sometimes a version control system can help you achieve the intended
>> directory structure without moving files , and thereby breaking other
>> tools that depend on this.
>
> Interesting point. I'll have to consult with colleagues who are more
> familiar with various version control systems than I am, to see how they
> would be applied here.
>
My point is , that with this directory structure in CVS / SVN:
big project \ common \ module1
big project \ common \ module2
big project \ common \ module3
big project \ common \ include
big project \ projects\ project A \ source
big project \ projects\ project B \ source
etc
you can check this out as:
myProjectA \ module1
myProjectA \ include
myProjectA \ source
(this one points to "source" under big project \ projects\ project A)
myProjectB \ module1
myProjectB \ module2
myProjectB \ include
myProjectB \ source
(this one points to "source" under big project \ projects\ project A)
I understand that this is what makes eclipse happy?
In other words, every "directory" in a cvs repository is called a module.
You can check-out a module in any directory you like.
When you change files in myProject A / module1, and commit them, and update
myProjectB , you will receive those changes into that working directory too.
With source safe its a bit different, and with SVN you could explore
"externals".
You can find VCS plugins for eclipse, but that is not nessecary. The above
is achievable using cvs/svn command line only !
I doubt , however , that this solves all your problems
regards
Troels
|
|
|
Re: Multiple disjoint source directories: Really this convoluted? [message #184629 is a reply to message #184355] |
Wed, 14 February 2007 08:58  |
Eclipse User |
|
|
|
Originally posted by: gerritvn.gpvno.co.za
I battled with the exact same problem and discovered this thread while
trying to solve it. With all the input I managed to solve it and it is
quite simple: In a Standard Make Project, the makefile determines what
will be compiled so sources can be in any directory structure. To get the
Indexer to work correctly, you have to add the folders:
Project > Properties > C/C++ Project Paths > Add Folder > Create New
Folder (Enter any name) > Advanced > Mark Link to folder in the file
system and enter the folder you want included.
|
|
|
Powered by
FUDForum. Page generated in 0.05606 seconds