Tuesday, March 17, 2015

How to set paths (library, debug, BPL, DCP, search) in Delphi XE7 (for multiplatform use)

So, Delphi's help doesn't tell us much about how to set up paths for DPK packages. It is ok. We got all used with Delphi's sloppy manual.

So, I will tell you how I do it so they work both on 32 and 64 Win platforms:



My packages


I have these major packages/folders:
  • Graphics32
  • Drag and Drop (Melander)
  • 3rd  Party (many small packages put together in a big package)
  • CommonPackages (these are my own packages)
I always build 'Graphics32', 'Drag and Drop' and '3rd  Party' packages only in Release mode. So, there is no DCUs and BPLs complied in Debug mode, therefore we don't set a path for $(Config).



Package setup 

Double click the DPK file to load it in Delphi. Go to project's settings and set xxxxxxxxxxxx.
This will ensure that the IDE and app that use this package don't have access to the package's PAS files. If the IDE has access to the PAS file it will recompile the files every time you complile the app.Even worst, if the IDE recompiles package's files, it will put the DCUs in app's folder!

Also unckeck 'Build as needed'. xxxxxxxxxxx




IDE setup 


IDE setup - Package output directory
  • For Win32 platform set it to: $(BDSCOMMONDIR)\Bpl
  • For Win64 platform set it to: $(BDSCOMMONDIR)\Bpl\$(Platform)
Do the same for 'DCP output directory'.


IDE setup - Library path settings

In Delphi options -> Library -> Library path, I set these paths for Win32 platform:
  • c:\MyProjects\Packages\DragDrop\$(Platform)
  • c:\MyProjects\Packages\Graphics32\$(Platform)
  • c:\MyProjects\Packages\Third party packages\$(Platform)
  • c:\MyProjects\Packages\CubicCommonControls\$(Platform)_$(Config)
Please note that Graphics32, Drag and Drop and 3rd  Partyonly have the $(Platform) set.

CommonPackages are multi-platform (Win32/64) and multi-config (debug, prerelease, release). Therefore, we use $(Config) in the path.
If the control uses *.res files you need to manually copy them in the $(Platform) folder (the folder where the DCU are written)

This is Delphi's help page for Browsing path: Specifies search paths where the compiler can find the required files for the package, such as .dcp and .bpi files.
This is the Delphi global library path. The compiler can find only those files that exist on the Library path. If you try to build your package with a file that is not on the Library path, you receive a compiler error.
Some resource files (such as controls.res) are only available in the Release folder (not the Debug folder), so you should ensure that your project Release directory either is specified in the Library path or will be resolved by at least one variable in the Library path.


Browse path

In Delphi options -> Library ->:
Enter the path to package's source code so the IDE will able to reach the code (for example to be able to open a file when you control+click a method in IDE):
  • c:\MyProjects\Packages\DragDrop\
  • c:\MyProjects\Packages\Graphics32\
  • c:\MyProjects\Packages\Third party packages\
  • c:\MyProjects\Packages\CubicCommonControls\
This is Delphi's help page for Browsing path: Specifies the directories where the Code Browsing feature of the Code Editor looks for unit files when it cannot find an identifier on the project search path or source path. The Code Editor searches for unit files used for code browsing in the following order:

  1. The project Search path for Delphi ( Project > Options > Delphi Compiler ) or the Include path for C++ ( Project > Options > Directories and Conditionals).
  2. The global browsing path (this option) for Win32 Delphi language projects; the directories specified with this option are appended to the debug source path for the project. Therefore, the debugger search order for unit files is determined by the following path settings:
    • The Browsing path (this option).
    • The project Source path (the directory in which the project was saved).


Search path

I am not sure you really need the thing below (I think you don't):

The project's 'Search Path' is set like this (for all platforms):
  • c:\MyProjects\Packages\DragDrop\$(Platform)
  • c:\MyProjects\Packages\Graphics32\$(Platform)
  • c:\MyProjects\Packages\Third party packages\$(Platform)
  • c:\MyProjects\Packages\CubicCommonControls\$(Platform)_$(Config)

You have to do the same for 32 and 64 bit platforms (in the 'Selected Platform' dropdown menu).


The applications

For applications (DPR) that are using the packages specified above I set the 'Unit output directory' like this (for 'All configurations/All platforms'):
  • .\$(Platform)_$(Config)


__________


Update: I had problems making a project to work when when I used a combination of $(Platform)_$(Config) and $(Platform) in the paths. It worked after I replaced $(Platform)_$(Config) with $(Platform).

No comments:

Post a Comment