Skip to content

Commit 7be2a42

Browse files
committed
Added support for optional library names for debug builds
1 parent 406728b commit 7be2a42

File tree

7 files changed

+319
-80
lines changed

7 files changed

+319
-80
lines changed

Bin/Chet.exe

9 KB
Binary file not shown.

Chet.dproj

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,13 @@
101101
<DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo>
102102
</PropertyGroup>
103103
<PropertyGroup Condition="'$(Cfg_2_Win64)'!=''">
104-
<Debugger_RunParams>..\Sample\usp10.chet</Debugger_RunParams>
104+
<Debugger_RunParams>..\Sample\Sample.chet </Debugger_RunParams>
105105
<VerInfo_AutoIncVersion>true</VerInfo_AutoIncVersion>
106-
<VerInfo_Build>67</VerInfo_Build>
106+
<VerInfo_Build>73</VerInfo_Build>
107107
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
108-
<VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.3.0.67;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.1.0.42;Comments=</VerInfo_Keys>
109-
<VerInfo_MinorVer>3</VerInfo_MinorVer>
108+
<VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.4.0.73;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.4.0;Comments=</VerInfo_Keys>
109+
<VerInfo_MinorVer>4</VerInfo_MinorVer>
110+
<Icon_MainIcon>Chet_Icon.ico</Icon_MainIcon>
110111
</PropertyGroup>
111112
<ItemGroup>
112113
<DelphiCompile Include="$(MainSource)">
@@ -154,7 +155,10 @@
154155
<Source>
155156
<Source Name="MainSource">Chet.dpr</Source>
156157
</Source>
157-
<Excluded_Packages/>
158+
<Excluded_Packages>
159+
<Excluded_Packages Name="$(BDSBIN)\dcloffice2k280.bpl">Microsoft Office 2000 Sample Automation Server Wrapper Components</Excluded_Packages>
160+
<Excluded_Packages Name="$(BDSBIN)\dclofficexp280.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
161+
</Excluded_Packages>
158162
</Delphi.Personality>
159163
<Platforms>
160164
<Platform value="Win32">False</Platform>

Chet.res

-8 Bytes
Binary file not shown.

Classes/Chet.HeaderTranslator.pas

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2275,7 +2275,12 @@ procedure THeaderTranslator.WritePlatforms;
22752275
First: Boolean;
22762276
PT: TPlatformType;
22772277
P: TPlatform;
2278+
DebugDefine: String;
22782279
begin
2280+
DebugDefine := FProject.DebugDefine.Trim;
2281+
if (DebugDefine = '') then
2282+
DebugDefine := 'DEBUG';
2283+
22792284
First := True;
22802285
FWriter.StartSection('const');
22812286

@@ -2300,7 +2305,16 @@ procedure THeaderTranslator.WritePlatforms;
23002305

23012306
FWriter.WriteLn(')}');
23022307

2303-
FWriter.WriteLn('%s%s = ''%s'';', [FSymbolPrefix, FProject.LibraryConstant, P.LibraryName]);
2308+
if (P.DebugLibraryName = '') then
2309+
begin
2310+
FWriter.WriteLn('%s%s = ''%s'';',
2311+
[FSymbolPrefix, FProject.LibraryConstant, P.LibraryName])
2312+
end
2313+
else
2314+
begin
2315+
FWriter.WriteLn('%s%s = {$IFDEF %s}''%s''{$ELSE}''%s''{$ENDIF};',
2316+
[FSymbolPrefix, FProject.LibraryConstant, DebugDefine, P.DebugLibraryName, P.LibraryName]);
2317+
end;
23042318
FWriter.WriteLn('_PU = ''%s'';', [P.Prefix]);
23052319
end;
23062320
end;

Classes/Chet.Project.pas

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,11 @@ TPlatform = class
118118
FPlatformType: TPlatformType;
119119
FEnabled: Boolean;
120120
FLibraryName: String;
121+
FDebugLibraryName: String;
121122
FPrefix: String;
122123
procedure SetEnabled(const AValue: Boolean);
123124
procedure SetLibraryName(const AValue: String);
125+
procedure SetDebugLibraryName(const AValue: String);
124126
procedure SetPrefix(const AValue: String);
125127
public
126128
constructor Create(const AProject: TProject;
@@ -149,6 +151,11 @@ TPlatform = class
149151
{ The name of the (dynamic or static) library for this platform. }
150152
property LibraryName: String read FLibraryName write SetLibraryName;
151153

154+
{ Optional name of the (dynamic or static) library containing a DEBUG build
155+
for this platform. This version of the library will be used if the
156+
application is built with a define that is set in TProject.DebugDefine. }
157+
property DebugLibraryName: String read FDebugLibraryName write SetDebugLibraryName;
158+
152159
{ The function name prefix to use for this platform. Usually an empty
153160
string, but on some platforms, each function will have a '_' prefix. }
154161
property Prefix: String read FPrefix write SetPrefix;
@@ -167,6 +174,7 @@ TProject = class
167174
FUseUnits: String;
168175

169176
FLibraryConstant: String;
177+
FDebugDefine: String;
170178
FPlatforms: array [TPlatformType] of TPlatform;
171179

172180
FIgnoreParseErrors: Boolean;
@@ -210,6 +218,7 @@ TProject = class
210218
procedure SetUnconvertibleHandling(const Value: TUnconvertibleHandling);
211219
function GetPlatform(const AIndex: TPlatformType): TPlatform;
212220
procedure SetLibraryConstant(const Value: String);
221+
procedure SetDebugDefine(const Value: String);
213222
procedure SetEnumHandling(const Value: TEnumHandling);
214223
procedure SetUseUnits(const Value: String);
215224
procedure SetSymbolsToIgnore(const Value: TStrings);
@@ -299,6 +308,15 @@ TProject = class
299308
LIB_MYLIB = 'mylib.dll' }
300309
property LibraryConstant: String read FLibraryConstant write SetLibraryConstant;
301310

311+
(*The name of the define that is used to link to Debug versions of the
312+
library. For example, if there are is a debug version of the 'mylib.dll'
313+
library called 'mylib_debug.dll', and DebugDefine is set to 'DEBUG_LIBS',
314+
then the following code will be generated:
315+
316+
const
317+
LIB_MYLIB = {$IFDEF DEBUG_LIBS}'mylib_debug.dll'{ELSE}'mylib.dll'{$ENDIF} *)
318+
property DebugDefine: String read FDebugDefine write SetDebugDefine;
319+
302320
{ Information about each of the supported platforms }
303321
property Platforms[const AIndex: TPlatformType]: TPlatform read GetPlatform;
304322

@@ -403,10 +421,12 @@ implementation
403421
ID_UNCONVERTIBLE_HANDLING = 'UnconvertibleHandling';
404422
ID_ENABLED = 'Enabled';
405423
ID_LIBRARY_NAME = 'LibraryName';
424+
ID_DEBUG_LIBRARY_NAME = 'DebugLibraryName';
406425
ID_PREFIX = 'Prefix';
407426
ID_LIBRARY_CONSTANT = 'LibraryConstant';
408427
ID_EXCLUDED_HEADERS = 'ExcludedHeaders';
409428
ID_CUSTOM_CTYPES_MAP = 'CTypesToDelphiMap';
429+
ID_DEBUG_DEFINE = 'DebugDefine';
410430
ID_COUNT = 'Count';
411431
ID_ITEM = 'Item';
412432
ID_SCRIPT = 'Script';
@@ -577,6 +597,7 @@ procedure TProject.Load(const AFilename: String);
577597
FTargetPasFile := IniFile.ReadString(IS_PROJECT, ID_TARGET_PAS_FILE, '');
578598
FUseUnits := IniFile.ReadString(IS_PROJECT, ID_USE_UNITS, '');
579599
FLibraryConstant := IniFile.ReadString(IS_PROJECT, ID_LIBRARY_CONSTANT, '');
600+
FDebugDefine := IniFile.ReadString(IS_PROJECT, ID_DEBUG_DEFINE, '');
580601
FIgnoredFiles := IniFile.ReadString(IS_PROJECT, ID_EXCLUDED_HEADERS, '');
581602
FCustomCTypesMap := IniFile.ReadString(IS_PROJECT, ID_CUSTOM_CTYPES_MAP, '');
582603
for P := Low(TPlatformType) to High(TPlatformType) do
@@ -639,6 +660,7 @@ procedure TProject.Reset;
639660
FTargetPasFile := '';
640661
FUseUnits := '';
641662
FLibraryConstant := '';
663+
FDebugDefine := '';
642664
FIgnoredFiles := '';
643665

644666
for P := Low(TPlatformType) to High(TPlatformType) do
@@ -675,6 +697,7 @@ procedure TProject.Save(const AFilename: String);
675697
IniFile.WriteString(IS_PROJECT, ID_TARGET_PAS_FILE, FTargetPasFile);
676698
IniFile.WriteString(IS_PROJECT, ID_USE_UNITS, FUseUnits);
677699
IniFile.WriteString(IS_PROJECT, ID_LIBRARY_CONSTANT, FLibraryConstant);
700+
IniFile.WriteString(IS_PROJECT, ID_DEBUG_DEFINE, FDebugDefine);
678701
IniFile.WriteString(IS_PROJECT, ID_EXCLUDED_HEADERS, FIgnoredFiles);
679702
IniFile.WriteString(IS_PROJECT, ID_CUSTOM_CTYPES_MAP, FCustomCTypesMap);
680703

@@ -756,6 +779,15 @@ procedure TProject.SetCustomCTypesMap(const AValue: String);
756779
end;
757780
end;
758781

782+
procedure TProject.SetDebugDefine(const Value: String);
783+
begin
784+
if (Value <> FDebugDefine) then
785+
begin
786+
FDebugDefine := Value;
787+
Modified := True;
788+
end;
789+
end;
790+
759791
procedure TProject.SetDelayedLoading(const Value: Boolean);
760792
begin
761793
if (Value <> FDelayedLoading) then
@@ -921,13 +953,15 @@ procedure TPlatform.Load(const AIniFile: TMemIniFile);
921953

922954
FEnabled := AIniFile.ReadBool(Section, ID_ENABLED, False);
923955
FLibraryName := AIniFile.ReadString(Section, ID_LIBRARY_NAME, '');
956+
FDebugLibraryName := AIniFile.ReadString(Section, ID_DEBUG_LIBRARY_NAME, '');
924957
FPrefix := AIniFile.ReadString(Section, ID_PREFIX, '');
925958
end;
926959

927960
procedure TPlatform.Reset;
928961
begin
929962
FEnabled := (FPlatformType = TPlatformType.Win32);
930963
FLibraryName := '';
964+
FDebugLibraryName := '';
931965
FPrefix := '';
932966
end;
933967

@@ -938,9 +972,19 @@ procedure TPlatform.Save(const AIniFile: TMemIniFile);
938972
Section := IS_PLATFORM_PREFIX + GetEnumName(TypeInfo(TPlatformType), Ord(FPlatformType));
939973
AIniFile.WriteBool(Section, ID_ENABLED, FEnabled);
940974
AIniFile.WriteString(Section, ID_LIBRARY_NAME, FLibraryName);
975+
AIniFile.WriteString(Section, ID_DEBUG_LIBRARY_NAME, FDebugLibraryName);
941976
AIniFile.WriteString(Section, ID_PREFIX, FPrefix);
942977
end;
943978

979+
procedure TPlatform.SetDebugLibraryName(const AValue: String);
980+
begin
981+
if (AValue <> FDebugLibraryName) then
982+
begin
983+
FDebugLibraryName := AValue;
984+
FProject.Modified := True;
985+
end;
986+
end;
987+
944988
procedure TPlatform.SetEnabled(const AValue: Boolean);
945989
begin
946990
if (AValue <> FEnabled) then

0 commit comments

Comments
 (0)