Question

Right now I have 2 platforms (Mac and Win32) and 2 configs (Debug ans Release). Whole thing is under SVN.

Here is layout for build output:

.\App\$(Platform)\$(Config)

The code is split into few folders and located here:

.\Code\MyProject.dpr
.\Code\Common\
.\Code\Forms\
.\Code\Source\

Common data files are here:

.\Data\ custom data files (dlls, textures, models, etc.)

This scheme has certain flaws though, which I need to resolve, but I don't know how to make it better. I want to have only one set of data files in SVN under Data folder, but I need to have it copied to .\App\$(Platform)\$(Config) paths automatically on build (note, certain data files are common for both platforms, but some are not). Is there a way to setup build process to copy the files, like it does with Deployment and PAServer? Alternatively I could setup paths to Data files as ..\..\Data, but that looks weird to me.

Maybe there are some other options I'm not aware of, or project layout could be changed completely? How would you setup the project structure and build for cross-platform compiling?

Was it helpful?

Solution

Use the Post Build actions.

From Project Options | Build Events | Post Build Events | Commands

How to setup

Further reading at

  1. Creating Build Events

  2. Pre and Post-Build Automation in Delphi

OTHER TIPS

Ok, this is an old post, but this is what I do in Delphi (and similarly in Visual Studio) to get around this problem of having the different platform/config output executables in different folders, but a common set of data. I have a function to strip off the "sub" folder parts, then my app can always access the common data in the root of these folders (in your case .\App). Of course you can add further platforms and configs to the function ProjectPath as required:

uses System.StrUtils;
...
function ProjectPath : string;
// Removes sub-folders created by the Delphi IDE, so the executable can refer to the source folder,
// rather than to where the executable is.
// Excludes trailiong path delimiter
begin
  Result := ExtractFilePath (Application.ExeName);
  Result := System.StrUtils.ReplaceText (Result, '\Win32'  , '');    // ReplaceText is case insensitive
  Result := System.StrUtils.ReplaceText (Result, '\Win64'  , '');
  Result := System.StrUtils.ReplaceText (Result, '\Debug'  , '');
  Result := System.StrUtils.ReplaceText (Result, '\Release', '');
  Result := ExcludeTrailingPathDelimiter (Result);
end;
...
ConnectionString := 'Database=' + ProjectPath +'\DATAFILE.DAT;etc.';
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top