[英]How to properly configure a cross-platform Delphi XE2 project?
現在我有2個平台(Mac和Win32)和2個配置(Debug ans Release)。 整件事都在SVN下。
這是構建輸出的布局:
.\App\$(Platform)\$(Config)
代碼分為幾個文件夾,位於此處:
.\Code\MyProject.dpr
.\Code\Common\
.\Code\Forms\
.\Code\Source\
常見的數據文件在這里:
.\Data\ custom data files (dlls, textures, models, etc.)
這個方案有一定的缺陷,我需要解決,但我不知道如何讓它變得更好。 我想在數據文件夾下的SVN中只有一組數據文件,但我需要在構建時自動將其復制到.\\App\\$(Platform)\\$(Config)
路徑(注意,某些數據文件是常見的兩個平台,但有些不是)。 有沒有辦法設置構建過程來復制文件,就像部署和PAServer一樣? 或者,我可以將數據文件的路徑設置為..\\..\\Data
,但這對我來說很奇怪。
也許還有其他一些我不知道的選項,或者項目布局可以完全改變? 您將如何設置項目結構並構建跨平台編譯?
好吧,這是一個老帖子,但這是我在Delphi中做的(並且類似地在Visual Studio中)來解決在不同文件夾中具有不同平台/配置輸出可執行文件但是一組通用數據的問題。 我有一個功能來剝離“子”文件夾部分,然后我的應用程序可以始終訪問這些文件夾的根目錄中的公共數據(在您的情況下。\\ App)。 當然,您可以根據需要向ProjectPath添加更多平台和配置:
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.';
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.