native project + dmd wrapper modified to support #37

- partially implemented processing of overriden config
- remaining `getOpt()`functs to adapt are listed in Laz TODO list
This commit is contained in:
Basile Burg 2015-09-05 16:39:15 +02:00
parent 6f5a8e42cb
commit d2578128bd
2 changed files with 239 additions and 118 deletions

View File

@ -31,7 +31,7 @@ type
protected protected
property onChange: TNotifyEvent read fOnChange write fOnChange; property onChange: TNotifyEvent read fOnChange write fOnChange;
public public
procedure getOpts(const aList: TStrings); virtual; abstract; procedure getOpts(aList: TStrings; base: TOptsGroup = nil); virtual; abstract;
end; end;
(***************************************************************************** (*****************************************************************************
@ -54,7 +54,7 @@ type
property JSONFilename: TCEFilename read fJsonFname write setJSONFile; property JSONFilename: TCEFilename read fJsonFname write setJSONFile;
public public
procedure assign(aValue: TPersistent); override; procedure assign(aValue: TPersistent); override;
procedure getOpts(const aList: TStrings); override; procedure getOpts(aList: TStrings; base: TOptsGroup = nil); override;
end; end;
@ -96,7 +96,7 @@ type
public public
constructor create; constructor create;
procedure assign(aValue: TPersistent); override; procedure assign(aValue: TPersistent); override;
procedure getOpts(const aList: TStrings); override; procedure getOpts(aList: TStrings; base: TOptsGroup = nil); override;
end; end;
(** (**
@ -158,7 +158,7 @@ type
constructor create; constructor create;
destructor destroy; override; destructor destroy; override;
procedure assign(aValue: TPersistent); override; procedure assign(aValue: TPersistent); override;
procedure getOpts(const aList: TStrings); override; procedure getOpts(aList: TStrings; base: TOptsGroup = nil); override;
end; end;
(***************************************************************************** (*****************************************************************************
@ -179,7 +179,7 @@ type
procedure setDbgC(const aValue: boolean); procedure setDbgC(const aValue: boolean);
procedure setGenMap(const aValue: boolean); procedure setGenMap(const aValue: boolean);
procedure setDbgLevel(const aValue: Integer); procedure setDbgLevel(const aValue: Integer);
procedure setDbgIdents(const aValue: TStringList); procedure setDbgIdents(aValue: TStringList);
published published
property debug: boolean read fDebug write setDebug default false; property debug: boolean read fDebug write setDebug default false;
property debugIdentifiers: TStringList read fDbgIdents write setDbgIdents; property debugIdentifiers: TStringList read fDbgIdents write setDbgIdents;
@ -191,7 +191,7 @@ type
constructor create; constructor create;
destructor destroy; override; destructor destroy; override;
procedure assign(aValue: TPersistent); override; procedure assign(aValue: TPersistent); override;
procedure getOpts(const aList: TStrings); override; procedure getOpts(aList: TStrings;base: TOptsGroup = nil); override;
end; end;
(***************************************************************************** (*****************************************************************************
@ -223,7 +223,7 @@ type
constructor create; constructor create;
destructor destroy; override; destructor destroy; override;
procedure assign(aValue: TPersistent); override; procedure assign(aValue: TPersistent); override;
procedure getOpts(const aList: TStrings); override; procedure getOpts(aList: TStrings; base: TOptsGroup = nil); override;
end; end;
(***************************************************************************** (*****************************************************************************
@ -232,14 +232,14 @@ type
TOtherOpts = class(TOptsGroup) TOtherOpts = class(TOptsGroup)
private private
fCustom: TStringList; fCustom: TStringList;
procedure setCustom(const aValue: TStringList); procedure setCustom(aValue: TStringList);
published published
property customOptions: TStringList read fCustom write setCustom; property customOptions: TStringList read fCustom write setCustom;
public public
constructor create; constructor create;
destructor destroy; override; destructor destroy; override;
procedure assign(aValue: TPersistent); override; procedure assign(aValue: TPersistent); override;
procedure getOpts(const aList: TStrings); override; procedure getOpts(aList: TStrings; base: TOptsGroup = nil); override;
end; end;
(***************************************************************************** (*****************************************************************************
@ -261,14 +261,14 @@ type
protected protected
property executable: TCEFilename read fExecutable write setExecutable; property executable: TCEFilename read fExecutable write setExecutable;
property workingDirectory: TCEPathname read fWorkDir write setWorkDir; property workingDirectory: TCEPathname read fWorkDir write setWorkDir;
property options: TProcessOptions read fOptions write setOptions; property options: TProcessOptions read fOptions write setOptions default [];
property parameters: TStringList read fParameters write setParameters; property parameters: TStringList read fParameters write setParameters;
property showWindow: TShowWindowOptions read fShowWin write setShowWin; property showWindow: TShowWindowOptions read fShowWin write setShowWin default swoNone;
public public
constructor create; constructor create;
destructor destroy; override; destructor destroy; override;
procedure assign(source: TPersistent); override; procedure assign(source: TPersistent); override;
procedure getOpts(const aList: TStrings); override; procedure getOpts(aList: TStrings; base: TOptsGroup = nil); override;
{ TAsyncProcess "Parameters" inherits from UTF8 process, { TAsyncProcess "Parameters" inherits from UTF8 process,
and the property reader is not anymore "fParameters" but "fUTF8Parameters" and the property reader is not anymore "fParameters" but "fUTF8Parameters"
without the overload aProcess does not get the Parameters if aProcess is TAsynProcess...} without the overload aProcess does not get the Parameters if aProcess is TAsynProcess...}
@ -318,6 +318,8 @@ type
fPreProcOpt: TCompileProcOptions; fPreProcOpt: TCompileProcOptions;
fPostProcOpt: TCompileProcOptions; fPostProcOpt: TCompileProcOptions;
fRunProjOpt: TProjectRunOptions; fRunProjOpt: TProjectRunOptions;
fIsBaseConfiguration: boolean;
fIsOverriddenConfiguration: boolean;
procedure doChanged; procedure doChanged;
procedure subOptsChanged(sender: TObject); procedure subOptsChanged(sender: TObject);
procedure setName(const aValue: string); procedure setName(const aValue: string);
@ -330,6 +332,8 @@ type
procedure setPreProcOpt(const aValue: TCompileProcOptions); procedure setPreProcOpt(const aValue: TCompileProcOptions);
procedure setPostProcOpt(const aValue: TCompileProcOptions); procedure setPostProcOpt(const aValue: TCompileProcOptions);
procedure setRunProjOpt(const aValue: TProjectRunOptions); procedure setRunProjOpt(const aValue: TProjectRunOptions);
procedure setisBaseConfiguration(const aValue: boolean);
procedure setisOverriddenConfiguration(const aValue: boolean);
protected protected
function nameFromID: string; function nameFromID: string;
published published
@ -343,11 +347,13 @@ type
property preBuildProcess: TCompileProcOptions read fPreProcOpt write setPreProcOpt; property preBuildProcess: TCompileProcOptions read fPreProcOpt write setPreProcOpt;
property postBuildProcess: TCompileProcOptions read fPostProcOpt write setPostProcOpt; property postBuildProcess: TCompileProcOptions read fPostProcOpt write setPostProcOpt;
property runOptions: TProjectRunOptions read fRunProjOpt write setRunProjOpt; property runOptions: TProjectRunOptions read fRunProjOpt write setRunProjOpt;
property isBaseConfiguration: boolean read fIsBaseConfiguration write setisBaseConfiguration default false;
property isOverriddenConfiguration: boolean read fIsOverriddenConfiguration write setisOverriddenConfiguration default false;
public public
constructor create(aCollection: TCollection); override; constructor create(aCollection: TCollection); override;
destructor destroy; override; destructor destroy; override;
procedure assign(aValue: TPersistent); override; procedure assign(aValue: TPersistent); override;
procedure getOpts(const aList: TStrings); procedure getOpts(aList: TStrings; base: TCompilerConfiguration = nil);
property onChanged: TNotifyEvent read fOnChanged write fOnChanged; property onChanged: TNotifyEvent read fOnChanged write fOnChanged;
end; end;
@ -362,7 +368,11 @@ begin
end; end;
{$REGION TDocOpts --------------------------------------------------------------} {$REGION TDocOpts --------------------------------------------------------------}
procedure TDocOpts.getOpts(const aList: TStrings); procedure TDocOpts.getOpts(aList: TStrings; base: TOptsGroup = nil);
var
baseopt: TDocOpts;
begin
if base = nil then
begin begin
if fGenDoc then if fGenDoc then
aList.Add('-D'); aList.Add('-D');
@ -372,6 +382,26 @@ begin
aList.Add('-Dd' + symbolExpander.get(fDocDir)); aList.Add('-Dd' + symbolExpander.get(fDocDir));
if fJsonFname <> '' then if fJsonFname <> '' then
aList.Add('-Xf' + symbolExpander.get(fJsonFname)); aList.Add('-Xf' + symbolExpander.get(fJsonFname));
end else
begin
baseopt := TDocOpts(base);
if baseopt.fGenDoc or fGenDoc then
aList.Add('-D');
if baseopt.fGenJson or fGenJson then
aList.Add('-X');
if (baseopt.fDocDir <> '') and (fDocDir <> '') then
aList.Add('-Dd' + symbolExpander.get(fDocDir))
else if (fDocDir <> '') then
aList.Add('-Dd' + symbolExpander.get(fDocDir))
else if (baseopt.fDocDir <> '') then
aList.Add('-Dd' + symbolExpander.get(baseopt.fDocDir));
if (baseopt.fJsonFname <> '') and (fJsonFname <> '') then
aList.Add('-Xf' + symbolExpander.get(fJsonFname))
else if fJsonFname <> '' then
aList.Add('-Xf' + symbolExpander.get(fJsonFname))
else if (baseopt.fJsonFname <> '') then
aList.Add('-Dd' + symbolExpander.get(baseopt.fJsonFname));
end;
end; end;
procedure TDocOpts.assign(aValue: TPersistent); procedure TDocOpts.assign(aValue: TPersistent);
@ -446,14 +476,17 @@ begin
fWarnings := true; fWarnings := true;
end; end;
procedure TMsgOpts.getOpts(const aList: TStrings); procedure TMsgOpts.getOpts(aList: TStrings; base: TOptsGroup = nil);
var var
opt : string; dep, depbase: string;
baseopt: TMsgOpts;
const const
DepStr : array[TDepHandling] of string = ('-d', '', '-de'); DepStr : array[TDepHandling] of string = ('-d', '', '-de');
begin begin
opt := DepStr[fDepHandling]; if base = nil then
if opt <> '' then aList.Add(opt); begin
dep := DepStr[fDepHandling];
if dep <> '' then aList.Add(dep);
if fVerbose then aList.Add('-v'); if fVerbose then aList.Add('-v');
if fWarnings then aList.Add('-w'); if fWarnings then aList.Add('-w');
if fWarnEx then aList.Add('-wi'); if fWarnEx then aList.Add('-wi');
@ -461,6 +494,20 @@ begin
if fQuiet then aList.Add('-quiet'); if fQuiet then aList.Add('-quiet');
if fVgc then aList.Add('-vgc'); if fVgc then aList.Add('-vgc');
if fCol then aList.Add('-vcolumns'); if fCol then aList.Add('-vcolumns');
end else
begin
baseopt := TMsgOpts(base);
dep := DepStr[fDepHandling];
depbase := DepStr[baseopt.fDepHandling];
if dep <> depbase then aList.Add(dep) else aList.Add(depbase);
if baseopt.fVerbose or fVerbose then aList.Add('-v');
if baseopt.fWarnings or fWarnings then aList.Add('-w');
if baseopt.fWarnEx or fWarnEx then aList.Add('-wi');
if baseopt.fVtls or fVtls then aList.Add('-vtls');
if baseopt.fQuiet or fQuiet then aList.Add('-quiet');
if baseopt.fVgc or fVgc then aList.Add('-vgc');
if baseopt.fCol or fCol then aList.Add('-vcolumns');
end;
end; end;
procedure TMsgOpts.assign(aValue: TPersistent); procedure TMsgOpts.assign(aValue: TPersistent);
@ -553,18 +600,21 @@ begin
inherited; inherited;
end; end;
procedure TOutputOpts.getOpts(const aList: TStrings); procedure TOutputOpts.getOpts(aList: TStrings; base: TOptsGroup = nil);
var var
opt: string; str, strbase: string;
baseopt: TOutputOpts;
const const
trgKindStr: array[TTargetSystem] of string = ('', '-m32','-m64'); trgKindStr: array[TTargetSystem] of string = ('', '-m32','-m64');
binKindStr: array[TProjectBinaryKind] of string = ('', '-lib', '-shared', '-c'); binKindStr: array[TProjectBinaryKind] of string = ('', '-lib', '-shared', '-c');
bchKindStr: array[TBoundCheckKind] of string = ('on', 'safeonly', 'off'); bchKindStr: array[TBoundCheckKind] of string = ('on', 'safeonly', 'off');
begin begin
opt := binKindStr[fBinKind]; if base = nil then
if opt <> '' then aList.Add(opt); begin
opt := trgKindStr[fTrgKind]; str := binKindStr[fBinKind];
if opt <> '' then aList.Add(opt); if str <> '' then aList.Add(str);
str := trgKindStr[fTrgKind];
if str <> '' then aList.Add(str);
if fUnittest then aList.Add('-unittest'); if fUnittest then aList.Add('-unittest');
if fInline then aList.Add('-inline'); if fInline then aList.Add('-inline');
if fOptimz then aList.Add('-O'); if fOptimz then aList.Add('-O');
@ -573,14 +623,14 @@ begin
if fAllInst then aList.Add('-allinst'); if fAllInst then aList.Add('-allinst');
if fAddMain then aList.Add('-main'); if fAddMain then aList.Add('-main');
if fRelease then aList.Add('-release'); if fRelease then aList.Add('-release');
for opt in fVerIds do begin for str in fVerIds do begin
if length(opt) > 0 then if length(str) > 0 then
if opt[1] = ';' then if str[1] = ';' then
continue; continue;
if length(opt) > 1 then if length(str) > 1 then
if opt[1..2] = '//' then if str[1..2] = '//' then
continue; continue;
aList.Add('-version=' + opt ); aList.Add('-version=' + str);
end; end;
// //
if fRelease then if fRelease then
@ -591,7 +641,10 @@ begin
else else
if fBoundsCheck <> onAlways then if fBoundsCheck <> onAlways then
aList.Add('-boundscheck=' + bchKindStr[fBoundsCheck] ); aList.Add('-boundscheck=' + bchKindStr[fBoundsCheck] );
end else
begin
//TODO-cNativeProjects: get output options if base config is specified.
end;
end; end;
procedure TOutputOpts.assign(aValue: TPersistent); procedure TOutputOpts.assign(aValue: TPersistent);
@ -722,9 +775,12 @@ begin
inherited; inherited;
end; end;
procedure TDebugOpts.getOpts(const aList: TStrings); procedure TDebugOpts.getOpts(aList: TStrings; base: TOptsGroup = nil);
var var
idt: string; idt, idtbase: string;
baseopt: TDebugOpts;
begin
if base = nil then
begin begin
if fDebug then aList.Add('-debug'); if fDebug then aList.Add('-debug');
if fDbgLevel <> 0 then if fDbgLevel <> 0 then
@ -734,6 +790,10 @@ begin
if fDbgD then aList.Add('-g'); if fDbgD then aList.Add('-g');
if fDbgC then aList.Add('-gc'); if fDbgC then aList.Add('-gc');
if fGenMap then aList.Add('-map'); if fGenMap then aList.Add('-map');
end else
begin
//TODO-cNativeProjects: get debug options if base config is specified.
end;
end; end;
procedure TDebugOpts.assign(aValue: TPersistent); procedure TDebugOpts.assign(aValue: TPersistent);
@ -802,7 +862,7 @@ begin
doChanged; doChanged;
end; end;
procedure TDebugOpts.setDbgIdents(const aValue: TStringList); procedure TDebugOpts.setDbgIdents(aValue: TStringList);
begin begin
fDbgIdents.Assign(aValue); fDbgIdents.Assign(aValue);
updateForceDbgBool; updateForceDbgBool;
@ -832,10 +892,13 @@ begin
// EndUpdate is not called to avoid an infinite loop // EndUpdate is not called to avoid an infinite loop
end; end;
procedure TPathsOpts.getOpts(const aList: TStrings); procedure TPathsOpts.getOpts(aList: TStrings; base: TOptsGroup = nil);
var var
str: string; str: string;
exts: TStringList; exts: TStringList;
baseopt: TPathsOpts;
begin
if base = nil then
begin begin
exts := TStringList.Create; exts := TStringList.Create;
try try
@ -857,6 +920,10 @@ begin
aList.Add('-of' + symbolExpander.get(fFname)); aList.Add('-of' + symbolExpander.get(fFname));
if fObjDir <> '' then if fObjDir <> '' then
aList.Add('-od' + symbolExpander.get(fObjDir)); aList.Add('-od' + symbolExpander.get(fObjDir));
end else
begin
//TODO-cNativeProjects: get paths options if base config is specified.
end;
end; end;
procedure TPathsOpts.assign(aValue: TPersistent); procedure TPathsOpts.assign(aValue: TPersistent);
@ -954,9 +1021,12 @@ begin
inherited; inherited;
end; end;
procedure TOtherOpts.getOpts(const aList: TStrings); procedure TOtherOpts.getOpts(aList: TStrings; base: TOptsGroup = nil);
var var
str1, str2: string; str1, str2: string;
baseopt: TOtherOpts;
begin
if base = nil then
begin begin
for str1 in fCustom do if str1 <> '' then for str1 in fCustom do if str1 <> '' then
begin begin
@ -972,9 +1042,13 @@ begin
str2 := str1; str2 := str1;
aList.AddText(symbolExpander.get(str2)); aList.AddText(symbolExpander.get(str2));
end; end;
end else
begin
//TODO-cNativeProjects: get others options if base config is specified.
end;
end; end;
procedure TOtherOpts.setCustom(const aValue: TStringList); procedure TOtherOpts.setCustom(aValue: TStringList);
begin begin
fCustom.Assign(aValue); fCustom.Assign(aValue);
doChanged; doChanged;
@ -1009,12 +1083,13 @@ begin
else inherited; else inherited;
end; end;
procedure TCustomProcOptions.getOpts(const aList: TStrings); procedure TCustomProcOptions.getOpts(aList: TStrings; base: TOptsGroup = nil);
begin begin
end; end;
procedure TCustomProcOptions.setProcess(var aProcess: TProcess); procedure TCustomProcOptions.setProcess(var aProcess: TProcess);
begin begin
//TODO-cNativeProjects: adapt TCustomProcOptions.setProcess to base/override system
aProcess.Parameters.Clear; aProcess.Parameters.Clear;
aProcess.Parameters.AddText(symbolExpander.get(Parameters.Text)); aProcess.Parameters.AddText(symbolExpander.get(Parameters.Text));
aProcess.Executable := fExecutable; aProcess.Executable := fExecutable;
@ -1152,6 +1227,8 @@ begin
fPreProcOpt.assign(src.fPreProcOpt); fPreProcOpt.assign(src.fPreProcOpt);
fPostProcOpt.assign(src.fPostProcOpt); fPostProcOpt.assign(src.fPostProcOpt);
fRunProjOpt.assign(src.fRunProjOpt); fRunProjOpt.assign(src.fRunProjOpt);
//
// isBase / isOverriden not copied by purpose.
end end
else inherited; else inherited;
end; end;
@ -1161,7 +1238,9 @@ begin
result := format('<configuration %d>', [ID]); result := format('<configuration %d>', [ID]);
end; end;
procedure TCompilerConfiguration.getOpts(const aList: TStrings); procedure TCompilerConfiguration.getOpts(aList: TStrings; base: TCompilerConfiguration = nil);
begin
if (base = nil) or (base = self) then
begin begin
fDocOpts.getOpts(aList); fDocOpts.getOpts(aList);
fDebugOpts.getOpts(aList); fDebugOpts.getOpts(aList);
@ -1169,6 +1248,15 @@ begin
fOutputOpts.getOpts(aList); fOutputOpts.getOpts(aList);
fPathsOpts.getOpts(aList); fPathsOpts.getOpts(aList);
fOthers.getOpts(aList); fOthers.getOpts(aList);
end else
begin
fDocOpts.getOpts(aList, base.fDocOpts);
fDebugOpts.getOpts(aList, base.fDebugOpts);
fMsgOpts.getOpts(aList, base.fMsgOpts);
fOutputOpts.getOpts(aList, base.fOutputOpts);
fPathsOpts.getOpts(aList, base.fPathsOpts);
fOthers.getOpts(aList, base.fOthers);
end;
end; end;
procedure TCompilerConfiguration.setName(const aValue: string); procedure TCompilerConfiguration.setName(const aValue: string);
@ -1235,6 +1323,19 @@ procedure TCompilerConfiguration.setRunProjOpt(const aValue: TProjectRunOptions)
begin begin
fRunProjOpt.assign(aValue); fRunProjOpt.assign(aValue);
end; end;
procedure TCompilerConfiguration.setisBaseConfiguration(const aValue: boolean);
begin
fIsBaseConfiguration := aValue;
doChanged;
end;
procedure TCompilerConfiguration.setisOverriddenConfiguration(const aValue: boolean);
begin
fIsBaseConfiguration := false;
fIsOverriddenConfiguration := aValue;
doChanged;
end;
{$ENDREGION} {$ENDREGION}
initialization initialization

View File

@ -39,8 +39,10 @@ type
fRunner: TCEProcess; fRunner: TCEProcess;
fOutputFilename: string; fOutputFilename: string;
fCanBeRun: boolean; fCanBeRun: boolean;
fBaseConfig: TCompilerConfiguration;
procedure updateOutFilename; procedure updateOutFilename;
procedure doChanged; procedure doChanged;
procedure getBaseConfig;
procedure setLibAliases(const aValue: TStringList); procedure setLibAliases(const aValue: TStringList);
procedure subMemberChanged(sender : TObject); procedure subMemberChanged(sender : TObject);
procedure setOptsColl(const aValue: TCollection); procedure setOptsColl(const aValue: TCollection);
@ -241,6 +243,20 @@ begin
endUpdate; endUpdate;
end; end;
procedure TCENativeProject.getBaseConfig;
var
i: integer;
begin
fBaseConfig := nil;
for i:= 0 to fConfigs.Count-1 do
if configuration[i].isBaseConfiguration then
fBaseConfig := configuration[i];
for i := 0 to fConfigs.Count-1 do
if configuration[i].isBaseConfiguration then
if configuration[i] <> fBaseConfig then
configuration[i].isBaseConfiguration := false;
end;
procedure TCENativeProject.subMemberChanged(sender : TObject); procedure TCENativeProject.subMemberChanged(sender : TObject);
begin begin
beginUpdate; beginUpdate;
@ -275,6 +291,7 @@ var
begin begin
fModified := true; fModified := true;
updateOutFilename; updateOutFilename;
getBaseConfig;
subjProjChanged(fProjectSubject, self); subjProjChanged(fProjectSubject, self);
if assigned(fOnChange) then fOnChange(Self); if assigned(fOnChange) then fOnChange(Self);
{$IFDEF DEBUG} {$IFDEF DEBUG}
@ -392,6 +409,9 @@ begin
// but always adds -I<path> // but always adds -I<path>
LibMan.getLibSources(libAliasesPtr, aList); LibMan.getLibSources(libAliasesPtr, aList);
// config // config
if currentConfiguration.isOverriddenConfiguration then
currentConfiguration.getOpts(aList, fBaseConfig)
else
currentConfiguration.getOpts(aList); currentConfiguration.getOpts(aList);
finally finally
ex_files.Free; ex_files.Free;