mirror of https://gitlab.com/basile.b/dexed.git
parent
6c4a47a48c
commit
4ed8b33e1e
|
@ -12,6 +12,37 @@ uses
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
|
TMakeProjectOptionsBase = class(TWritableLfmTextComponent)
|
||||||
|
strict private
|
||||||
|
fNumThreads: integer;
|
||||||
|
fSourceDirectories: TStringList;
|
||||||
|
fQuiet: boolean;
|
||||||
|
fKeepGoing: boolean;
|
||||||
|
procedure setSourceDirectories(value: TStringList);
|
||||||
|
published
|
||||||
|
property keepGoing: boolean read fKeepGoing write fKeepGoing default false;
|
||||||
|
property quiet: boolean read fQuiet write fQuiet default false;
|
||||||
|
property numThreads: integer read fNumThreads write fNumThreads default 1;
|
||||||
|
property sourceDirectories: TStringList read fSourceDirectories write setSourceDirectories;
|
||||||
|
public
|
||||||
|
constructor create(aOwner: TComponent); override;
|
||||||
|
destructor destroy(); override;
|
||||||
|
procedure assign(other: TPersistent); override;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TMakeProjectOptions = class(TMakeProjectOptionsBase, IEditableOptions)
|
||||||
|
strict private
|
||||||
|
fBackup: TMakeProjectOptionsBase;
|
||||||
|
function optionedWantCategory(): string;
|
||||||
|
function optionedWantEditorKind: TOptionEditorKind;
|
||||||
|
function optionedWantContainer: TPersistent;
|
||||||
|
procedure optionedEvent(event: TOptionEditorEvent);
|
||||||
|
function optionedOptionsModified: boolean;
|
||||||
|
public
|
||||||
|
constructor create(aOwner: TComponent); override;
|
||||||
|
destructor destroy; override;
|
||||||
|
end;
|
||||||
|
|
||||||
TMakeProject = class(TComponent, ICommonProject)
|
TMakeProject = class(TComponent, ICommonProject)
|
||||||
private
|
private
|
||||||
|
|
||||||
|
@ -110,6 +141,95 @@ end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
var
|
||||||
|
makeProjectOptions: TMakeProjectOptions;
|
||||||
|
const
|
||||||
|
optFname = 'makeProjectsOptions.txt';
|
||||||
|
|
||||||
|
constructor TMakeProjectOptionsBase.create(aOwner: TComponent);
|
||||||
|
begin
|
||||||
|
inherited create(aOwner);
|
||||||
|
fNumThreads := 1;
|
||||||
|
fSourceDirectories := TStringList.Create;
|
||||||
|
fSourceDirectories.AddStrings(['src', 'import', 'include']);
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TMakeProjectOptionsBase.destroy();
|
||||||
|
begin
|
||||||
|
fSourceDirectories.Free;
|
||||||
|
inherited;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TMakeProjectOptionsBase.setSourceDirectories(value: TStringList);
|
||||||
|
begin
|
||||||
|
fSourceDirectories.Assign(value);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TMakeProjectOptionsBase.assign(other: TPersistent);
|
||||||
|
var
|
||||||
|
src: TMakeProjectOptionsBase;
|
||||||
|
begin
|
||||||
|
if other is TMakeProjectOptionsBase then
|
||||||
|
begin
|
||||||
|
src := TMakeProjectOptionsBase(other);
|
||||||
|
fSourceDirectories.Assign(src.sourceDirectories);
|
||||||
|
fQuiet:= src.fQuiet;
|
||||||
|
fKeepGoing:= src.fKeepGoing;
|
||||||
|
fNumThreads:= src.fNumThreads;
|
||||||
|
end
|
||||||
|
else inherited;
|
||||||
|
end;
|
||||||
|
|
||||||
|
constructor TMakeProjectOptions.create(aOwner: TComponent);
|
||||||
|
var
|
||||||
|
fname: string;
|
||||||
|
begin
|
||||||
|
inherited;
|
||||||
|
fBackup := TMakeProjectOptionsBase.Create(nil);
|
||||||
|
EntitiesConnector.addObserver(self);
|
||||||
|
fname := getDocPath + optFname;
|
||||||
|
if fname.fileExists then
|
||||||
|
loadFromFile(fname);
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TMakeProjectOptions.destroy;
|
||||||
|
begin
|
||||||
|
saveToFile(getDocPath + optFname);
|
||||||
|
EntitiesConnector.removeObserver(self);
|
||||||
|
fBackup.free;
|
||||||
|
inherited;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TMakeProjectOptions.optionedWantCategory(): string;
|
||||||
|
begin
|
||||||
|
exit('Makefile projects');
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TMakeProjectOptions.optionedWantEditorKind: TOptionEditorKind;
|
||||||
|
begin
|
||||||
|
exit(oekGeneric);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TMakeProjectOptions.optionedWantContainer: TPersistent;
|
||||||
|
begin
|
||||||
|
fBackup.assign(self);
|
||||||
|
exit(self);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TMakeProjectOptions.optionedEvent(event: TOptionEditorEvent);
|
||||||
|
begin
|
||||||
|
case event of
|
||||||
|
oeeAccept: fBackup.assign(self);
|
||||||
|
oeeCancel: self.assign(fBackup);
|
||||||
|
oeeSelectCat:fBackup.assign(self);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TMakeProjectOptions.optionedOptionsModified: boolean;
|
||||||
|
begin
|
||||||
|
exit(false);
|
||||||
|
end;
|
||||||
|
|
||||||
constructor TMakeProject.create(aOwner: TComponent);
|
constructor TMakeProject.create(aOwner: TComponent);
|
||||||
begin
|
begin
|
||||||
inherited create(aOwner);
|
inherited create(aOwner);
|
||||||
|
@ -170,6 +290,7 @@ var
|
||||||
line1: string;
|
line1: string;
|
||||||
hidden: string = DirectorySeparator + '.';
|
hidden: string = DirectorySeparator + '.';
|
||||||
f: string;
|
f: string;
|
||||||
|
p: string;
|
||||||
colPos: integer;
|
colPos: integer;
|
||||||
i: integer;
|
i: integer;
|
||||||
begin
|
begin
|
||||||
|
@ -205,24 +326,14 @@ begin
|
||||||
fSrcs.Sorted:=false;
|
fSrcs.Sorted:=false;
|
||||||
srcs := TStringList.Create;
|
srcs := TStringList.Create;
|
||||||
try
|
try
|
||||||
listFiles(srcs, fBasePath + 'src', true);
|
for p in makeProjectOptions.sourceDirectories do
|
||||||
for f in srcs do
|
begin
|
||||||
if pos(hidden, f) = 0 then
|
listFiles(srcs, fBasePath + p, true);
|
||||||
fSrcs.Add(f[fBasePath.length + 1 .. f.length]);
|
for f in srcs do
|
||||||
srcs.Clear;
|
if pos(hidden, f) = 0 then
|
||||||
|
fSrcs.Add(f[fBasePath.length + 1 .. f.length]);
|
||||||
listFiles(srcs, fBasePath + 'include', true);
|
srcs.Clear;
|
||||||
for f in srcs do
|
end;
|
||||||
if pos(hidden, f) = 0 then
|
|
||||||
fSrcs.Add(f[fBasePath.length + 1 .. f.length]);
|
|
||||||
srcs.Clear;
|
|
||||||
|
|
||||||
listFiles(srcs, fBasePath + 'import', true);
|
|
||||||
for f in srcs do
|
|
||||||
if pos(hidden, f) = 0 then
|
|
||||||
fSrcs.Add(f[fBasePath.length + 1 .. f.length]);
|
|
||||||
srcs.Clear;
|
|
||||||
|
|
||||||
finally
|
finally
|
||||||
srcs.Free;
|
srcs.Free;
|
||||||
end;
|
end;
|
||||||
|
@ -264,9 +375,15 @@ end;
|
||||||
|
|
||||||
function TMakeProject.getCommandLine: string;
|
function TMakeProject.getCommandLine: string;
|
||||||
begin
|
begin
|
||||||
result := 'make ' + '-f ' + fFilename;
|
result := 'make ' + '-f' + fFilename;
|
||||||
if not fRuleIndex.equals(0) then
|
if not fRuleIndex.equals(0) then
|
||||||
result += ' ' + fRules[fRuleIndex];
|
result += ' ' + fRules[fRuleIndex];
|
||||||
|
if makeProjectOptions.keepGoing then
|
||||||
|
result += ' -k';
|
||||||
|
if makeProjectOptions.quiet then
|
||||||
|
result += ' -q';
|
||||||
|
if makeProjectOptions.numThreads > 1 then
|
||||||
|
result += ' -j' + makeProjectOptions.numThreads.ToString();
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMakeProject.stopCompilation;
|
procedure TMakeProject.stopCompilation;
|
||||||
|
@ -396,9 +513,17 @@ begin
|
||||||
p := shortenPath(fFilename);
|
p := shortenPath(fFilename);
|
||||||
fMakeProc := TDexedProcess.create(nil);
|
fMakeProc := TDexedProcess.create(nil);
|
||||||
fMakeProc.executable := 'make';
|
fMakeProc.executable := 'make';
|
||||||
|
|
||||||
fMakeProc.Parameters.AddStrings([ '-f', fFilename]);
|
fMakeProc.Parameters.AddStrings([ '-f', fFilename]);
|
||||||
if not fRuleIndex.equals(0) then
|
if not fRuleIndex.equals(0) then
|
||||||
fMakeProc.Parameters.Add(fRules[fRuleIndex]);
|
fMakeProc.Parameters.Add(fRules[fRuleIndex]);
|
||||||
|
if makeProjectOptions.keepGoing then
|
||||||
|
fMakeProc.Parameters.Add(' -k');
|
||||||
|
if makeProjectOptions.quiet then
|
||||||
|
fMakeProc.Parameters.Add(' -q');
|
||||||
|
if makeProjectOptions.numThreads > 1 then
|
||||||
|
fMakeProc.Parameters.Add(' -j' + makeProjectOptions.numThreads.ToString());
|
||||||
|
|
||||||
fMakeProc.Options := fMakeProc.Options + [poStderrToOutPut, poUsePipes];
|
fMakeProc.Options := fMakeProc.Options + [poStderrToOutPut, poUsePipes];
|
||||||
fMakeProc.ShowWindow := swoHIDE;
|
fMakeProc.ShowWindow := swoHIDE;
|
||||||
fMakeProc.CurrentDirectory := fFilename.extractFilePath;
|
fMakeProc.CurrentDirectory := fFilename.extractFilePath;
|
||||||
|
@ -431,5 +556,9 @@ begin
|
||||||
result := false;
|
result := false;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
initialization
|
||||||
|
makeProjectOptions:= TMakeProjectOptions.create(nil);
|
||||||
|
finalization
|
||||||
|
makeProjectOptions.free;
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue