9
votes

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?

2
"resource files" has a loaded meaning. Most windows devs think of resource scripts (.res) or their compiled equivalent (.rc) which are embedded into the executable by the linker. AFAIK this is unique to the portable executable format used by Windows. Since you want them copied to the output folder can I assume this is not what you're referring to?Kenneth Cochran
Sorry for confusion. I was referring to data files (dlls, textures, models, etc.). I have edited the question slightly.Kromster
Won't the project PostBuild action help?Gad D Lord
Formulated with some screenshot and further reading links as an answer.Gad D Lord

2 Answers

7
votes

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

0
votes

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.';