views:

217

answers:

5

We create via "Tools | Options | Environment Variables" Variables like that:

$(Sources) = D:\Sources\Delphi
$(OurLib) = $(Sources)\OurLib\Src
$(OurApp1) = $(Sources)\Applications\App1\3.x
$(ThirdParty) = $(Sources)\ThirdPartyComponents

We use these Variables in the project search path like that:

($OurApp1)\Src\Core;($OurApp1)\Src\GUI;($OurApp1)\Src\Plugins;$(ThirdParty)\JVCL

But this is broken since Delphi 2009 as these variables are not evaluated completely anymore (see QC #73276). So the files in the directories are not found by the compiler. A work around: Use only complete directories in the environment variables.

We use this approach because on all developer machines and the build servers the files can be found and we only have to point $(Sources) to the right place.

We don't have anything in our global library path (except the Delphi defaults), because that wouldn't be in the version control and isn't reflected to other developers or build machines.

One problem is: If one unit in $(OurLib) decides to include another new unit maybe in a new path, all projects break because the don't find this new unit. Then we have to go through all projects and add the search path. I really hate the search path editor...wouldn't be a simple memofield much better to edit than this replace/add/delete logic?

Another thing we do is not adding many units to our project. Especially everything from $(OurLib), but we often have units like plugins which add functionality only by including them. For different editions of our products we want to include different units. As Delphi always messes up $IFDEFs in the uses clause in the .dpr we help us by including units named like "IncludePlugins" which then include the units depending on IFDEFs. But not including units in the project makes navigating to a pain. The units don't appear in the project, they are not found by Ctrl+12 (Show Units), they are not shown in code completion etc.

Has anybody a better way to cope with these problems?

+1  A: 

We use standard drive mappings.

Our current project is always on W: regardless if it is a network drive or a substitute.

This works great.

When you need to work on a different project, swap the W: and you can continue.

Gamecat
In fact we do this too. Our build machines map $(Sources) always to S: and the resulting binaries are placed on T: where the setups are created from. No all applications of our tool chain supports changing the root directory.
Stebi
+1  A: 

We use only relative paths, any libraries are always below the libs subdirectory while the project source code resides in the src subdir. So our search paths always look like:

..\libs\library1;..\libs\library2\common;

etc.

All libraries are added as svn:external to each project, so checking out the project will automatically check out the libraries as well and the search path will always point to the correct version of the library for that project.

Not perfect, but it works most of the time.

I have to agree about the search path editor, it is even worse for relative paths because you must not use the "..." buttons otherwise Delphi will insert an absolute path.

dummzeuch
+1  A: 

You can copy the search path out to an editor, modify it and then copy it back.

Toby Allen
A: 

Your search path is much too big. It should contain only the things you want Delphi to recompile with your project. You don't really want to recompile the Jedi VCL every day, do you?

I create a single directory where all compiled units go. Say, C:\dcu. Specify that as the "unit output directory" in all packages. My "search path," then, is always just this:

$(Delphi)\Lib;C:\dcu

The compiler finds everything it needs, and it never finds any source code. The only source code it ever sees is in the files that directly belong to whatever project I'm compiling. The project's own source directories don't need to be on the search path because all of those files are already direct members of the project. The compiler knows exactly where they are.

For me, all a project's source files go in a single directory. If you want separate directories for different parts, like Core and GUI, then I would put those in separate packages so I could work on them and compile them separately. Even if the final program doesn't use the resultant BPLs, packages are still a good way of segmenting your project and defining dependencies.

When compiling units for one project doesn't automatically compile units for all the other projects, you're forced to change active projects. It takes a moment of your time, but it also serves as a mental reminder that you're "changing hats," too.

Although you're producing just one product, that doesn't mean you should have just one project in Delphi. You should have at least one project for each executable module (EXE, DLL, BPL) in your product. Use project groups to manage multiple projects in a single IDE session. No unit should be a member of more than one project.


I don't understand your part about plug-ins and different editions of your project. When you say "plug-in," I assume you're talking about separate executable modules, like DLLs or packages, that the customer can choose to include or not. Couldn't you turn your different editions' features into plug-in modules that simply don't include in the lesser editions? Then you don't have to worry about conditional compilation of your project; just have several different installer packagers that grab different sets of plug-ins.

Rob Kennedy
One DCU-Directory: I remember we already considered this, but I think there were problems with duplicated unit names. But I'll rethink this.Plugins: Some things are way to difficult to differentiate via "real" plugins (DLLs/Packages), e.g. a Trial version of the application. As we don't use packages it would be a huge work to include e.g. a TFrame descendant via a DLL as we would have to interface this.
Stebi
A: 

I have always found it odd that this has never been addressed adequately. I suggested recently to David I that Delphi should allow the user to set up some sort of preferred development structure and that third party library publishers could be made aware of this so that they could automatically adjust their installers to install correctly in the preferred development framework. If the preferred development structure was stored in an XML file or similar, then, it could be copied from one computer to another on a development team.

As an alternative, it could make an interesting project to create a Delphi application that would allow a user to "refactor" their library installation in a high level way. You specify which folders on your system contain source or compiled components or whatever and where you want to keep source files or compiled units, hit Go and your system gets rearranged for you, while updating your Delphi environment so that when you start Delphi, it finds everything it should.