mirror of https://gitlab.com/basile.b/dexed.git
added simpleCOmmands to ce proj format + improve UTF8 compat
This commit is contained in:
parent
cfd3e788ef
commit
097875dd59
|
@ -257,17 +257,20 @@ type
|
|||
fOptions: TProcessOptions;
|
||||
fParameters: TStringList;
|
||||
fShowWin: TShowWindowOptions;
|
||||
fCommands: TStringList;
|
||||
procedure setExecutable(const aValue: TCEFilename);
|
||||
procedure setWorkDir(const aValue: TCEPathname);
|
||||
procedure setOptions(const aValue: TProcessOptions);
|
||||
procedure setParameters(aValue: TStringList);
|
||||
procedure setShowWin(const aValue: TShowWindowOptions);
|
||||
procedure setCommands(aValue: TStringList);
|
||||
protected
|
||||
property executable: TCEFilename read fExecutable write setExecutable;
|
||||
property workingDirectory: TCEPathname read fWorkDir write setWorkDir;
|
||||
property options: TProcessOptions read fOptions write setOptions default [];
|
||||
property parameters: TStringList read fParameters write setParameters;
|
||||
property showWindow: TShowWindowOptions read fShowWin write setShowWin default swoNone;
|
||||
property simpleCommands: TStringList read fCommands write setCommands;
|
||||
public
|
||||
constructor create;
|
||||
destructor destroy; override;
|
||||
|
@ -292,6 +295,7 @@ type
|
|||
property options default [];
|
||||
property parameters;
|
||||
property showWindow default swoNone;
|
||||
property simpleCommands;
|
||||
end;
|
||||
|
||||
(*****************************************************************************
|
||||
|
@ -1167,11 +1171,13 @@ end;
|
|||
constructor TCustomProcOptions.create;
|
||||
begin
|
||||
fParameters := TStringList.Create;
|
||||
fCommands := TStringList.Create;
|
||||
end;
|
||||
|
||||
destructor TCustomProcOptions.destroy;
|
||||
begin
|
||||
fParameters.Free;
|
||||
fCommands.Free;
|
||||
inherited;
|
||||
end;
|
||||
|
||||
|
@ -1267,6 +1273,12 @@ begin
|
|||
doChanged;
|
||||
end;
|
||||
|
||||
procedure TCustomProcOptions.setCommands(aValue: TStringList);
|
||||
begin
|
||||
fCommands.Assign(aValue);
|
||||
doChanged;
|
||||
end;
|
||||
|
||||
procedure TCustomProcOptions.setShowWin(const aValue: TShowWindowOptions);
|
||||
begin
|
||||
if fShowWin = aValue then exit;
|
||||
|
|
|
@ -283,7 +283,7 @@ var
|
|||
fname: string;
|
||||
begin
|
||||
fname := aFilename;
|
||||
if fileExists(fname) then
|
||||
if fname.fileExists then
|
||||
fname := ExtractRelativepath(fBasePath, fname);
|
||||
result := fSrcs.IndexOf(fname) <> -1;
|
||||
end;
|
||||
|
@ -303,7 +303,7 @@ var
|
|||
fname: string;
|
||||
begin
|
||||
fname := fSrcs.Strings[index];
|
||||
if FileExists(fname) then
|
||||
if fname.fileExists then
|
||||
result := fname
|
||||
else
|
||||
result := expandFilenameEx(fBasePath, fname);
|
||||
|
@ -373,7 +373,7 @@ var
|
|||
msgs: ICEMessagesDisplay;
|
||||
begin
|
||||
result := false;
|
||||
if not FileExists(fFilename) then
|
||||
if not fFilename.fileExists then
|
||||
begin
|
||||
dlgOkInfo('The DUB project must be saved before being compiled or run !');
|
||||
exit;
|
||||
|
@ -824,7 +824,7 @@ begin
|
|||
gdc: DubCompilerFilename := exeFullName('gdc' + exeExt);
|
||||
ldc: DubCompilerFilename := exeFullName('ldc2' + exeExt);
|
||||
end;
|
||||
if (not fileExists(DubCompilerFilename)) or DubCompilerFilename.isEmpty then
|
||||
if (not DubCompilerFilename.fileExists) or DubCompilerFilename.isEmpty then
|
||||
begin
|
||||
value := dmd;
|
||||
DubCompilerFilename:= 'dmd' + exeExt;
|
||||
|
|
|
@ -12,7 +12,7 @@ uses
|
|||
ce_dialogs,
|
||||
{$ENDIF}
|
||||
Classes, SysUtils, process, strUtils, ce_common, ce_writableComponent,
|
||||
ce_dmdwrap, ce_observer, ce_interfaces, ce_processes;
|
||||
ce_dmdwrap, ce_observer, ce_interfaces, ce_processes, LazFileUtils;
|
||||
|
||||
type
|
||||
|
||||
|
@ -131,7 +131,7 @@ constructor TCENativeProject.create(aOwner: TComponent);
|
|||
begin
|
||||
inherited create(aOwner);
|
||||
//
|
||||
fRunnerOldCwd := GetCurrentDir;
|
||||
fRunnerOldCwd := GetCurrentDirUTF8;
|
||||
fProjectSubject := TCEProjectSubject.create;
|
||||
//
|
||||
fLibAliases := TStringList.Create;
|
||||
|
@ -400,7 +400,7 @@ begin
|
|||
begin
|
||||
str := symbolExpander.get(currentConfiguration.pathsOptions.exclusions.Strings[i]);
|
||||
rel := expandFilenameEx(fBasePath, currentConfiguration.pathsOptions.exclusions.Strings[i]);
|
||||
if fileExists(str) then
|
||||
if str.fileExists then
|
||||
ex_files.Add(str)
|
||||
else if str.dirExists then
|
||||
ex_folds.Add(str);
|
||||
|
@ -482,7 +482,7 @@ var
|
|||
if fSrcs.Count = 0 then exit;
|
||||
allMissing := true;
|
||||
for i:= 0 to fSrcs.Count-1 do
|
||||
if fileExists(sourceAbsolute(i)) then
|
||||
if sourceAbsolute(i).fileExists then
|
||||
allMissing := false;
|
||||
if not allMissing then exit;
|
||||
if dlgOkCancel( 'The project source(s) are all missing. ' + LineEnding +
|
||||
|
@ -516,7 +516,7 @@ var
|
|||
for i:= fSrcs.Count-1 downto 0 do
|
||||
begin
|
||||
oldsrc := sourceAbsolute(i);
|
||||
if fileExists(oldsrc) then continue;
|
||||
if oldsrc.fileExists then continue;
|
||||
if dlgOkCancel(format('a particular project source file ("%s") is missing. '
|
||||
+ LineEnding + 'This happends if a source file has been moved, renamed ' +
|
||||
'or deleted.' + LineEnding + LineEnding +
|
||||
|
@ -572,7 +572,7 @@ begin
|
|||
end;
|
||||
|
||||
procedure TCENativeProject.readerPropNoFound(Reader: TReader; Instance: TPersistent;
|
||||
var PropName: string; IsPath: Boolean; var Handled, Skip: Boolean);
|
||||
var PropName: string; IsPath: Boolean; var Handled, Skip: Boolean);
|
||||
//var
|
||||
//idt: string;
|
||||
//curr: TCompilerConfiguration;
|
||||
|
@ -642,41 +642,69 @@ begin
|
|||
//
|
||||
fCanBeRun := false;
|
||||
if currentConfiguration.outputOptions.binaryKind = executable then
|
||||
fCanBeRun := fileExists(fOutputFilename);
|
||||
fCanBeRun := fOutputFilename.fileExists;
|
||||
end;
|
||||
|
||||
function TCENativeProject.runPrePostProcess(const processInfo: TCompileProcOptions): Boolean;
|
||||
var
|
||||
process: TProcess;
|
||||
lst: TStringList;
|
||||
com: boolean;
|
||||
proc: TProcess;
|
||||
pname: string;
|
||||
i, j: integer;
|
||||
begin
|
||||
//
|
||||
for i := 0 to processInfo.simpleCommands.Count-1 do
|
||||
begin
|
||||
pname := symbolExpander.get(processInfo.simpleCommands.Strings[i]);
|
||||
proc := TProcess.Create(nil);
|
||||
lst := TStringList.Create;
|
||||
try
|
||||
CommandToList(pname, lst);
|
||||
proc.Executable := lst.Strings[0];
|
||||
proc.Options:= [poUsePipes, poStderrToOutPut];
|
||||
lst.Delete(0);
|
||||
proc.Parameters.Assign(lst);
|
||||
proc.Execute;
|
||||
com := proc.ExitCode = 0;
|
||||
lst.Clear;
|
||||
ce_common.processOutputToStrings(proc, lst);
|
||||
for j := 0 to lst.Count -1 do
|
||||
getMessageDisplay.message(lst.Strings[j], self as ICECommonProject, amcProj, amkAuto);
|
||||
finally
|
||||
proc.Free;
|
||||
lst.Free;
|
||||
end;
|
||||
if not com then
|
||||
exit(false);
|
||||
end;
|
||||
//
|
||||
pname := symbolExpander.get(processInfo.executable);
|
||||
if (not exeInSysPath(pname)) and pname.isNotEmpty then
|
||||
exit(false)
|
||||
else if pname.isEmpty then
|
||||
exit(true);
|
||||
//
|
||||
process := TProcess.Create(nil);
|
||||
proc := TProcess.Create(nil);
|
||||
try
|
||||
processInfo.setProcess(process);
|
||||
process.Executable := exeFullName(pname);
|
||||
j := process.Parameters.Count-1;
|
||||
processInfo.setProcess(proc);
|
||||
proc.Executable := exeFullName(pname);
|
||||
j := proc.Parameters.Count-1;
|
||||
for i:= 0 to j do
|
||||
process.Parameters.AddText(symbolExpander.get(process.Parameters.Strings[i]));
|
||||
proc.Parameters.AddText(symbolExpander.get(proc.Parameters.Strings[i]));
|
||||
for i:= 0 to j do
|
||||
process.Parameters.Delete(0);
|
||||
if process.CurrentDirectory.isNotEmpty then
|
||||
process.CurrentDirectory := symbolExpander.get(process.CurrentDirectory);
|
||||
proc.Parameters.Delete(0);
|
||||
if proc.CurrentDirectory.isNotEmpty then
|
||||
proc.CurrentDirectory := symbolExpander.get(proc.CurrentDirectory);
|
||||
// else cwd is set to project dir in compile()
|
||||
ensureNoPipeIfWait(process);
|
||||
process.Execute;
|
||||
while process.Running do
|
||||
if poUsePipes in process.Options then
|
||||
runProcOutput(process);
|
||||
ensureNoPipeIfWait(proc);
|
||||
proc.Execute;
|
||||
while proc.Running do
|
||||
if poUsePipes in proc.Options then
|
||||
runProcOutput(proc);
|
||||
finally
|
||||
result := process.ExitStatus = 0;
|
||||
process.Free;
|
||||
result := proc.ExitStatus = 0;
|
||||
proc.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -702,17 +730,17 @@ begin
|
|||
subjProjCompiling(fProjectSubject, Self);
|
||||
//
|
||||
prjpath := fFileName.extractFilePath;
|
||||
oldCwd := GetCurrentDir;
|
||||
SetCurrentDir(prjpath);
|
||||
oldCwd := GetCurrentDirUTF8;
|
||||
SetCurrentDirUTF8(prjpath);
|
||||
//
|
||||
if not runPrePostProcess(config.preBuildProcess) then
|
||||
msgs.message('project warning: the pre-compilation process has not been properly executed',
|
||||
msgs.message('warning: pre-compilation process or commands not properly executed',
|
||||
self as ICECommonProject, amcProj, amkWarn);
|
||||
SetCurrentDir(prjpath);
|
||||
SetCurrentDirUTF8(prjpath);
|
||||
//
|
||||
if (Sources.Count = 0) and (config.pathsOptions.extraSources.Count = 0) then
|
||||
begin
|
||||
SetCurrentDir(oldCwd);
|
||||
SetCurrentDirUTF8(oldCwd);
|
||||
exit;
|
||||
end;
|
||||
//
|
||||
|
@ -745,12 +773,12 @@ begin
|
|||
updateOutFilename;
|
||||
compilproc.Free;
|
||||
end;
|
||||
SetCurrentDir(prjpath);
|
||||
SetCurrentDirUTF8(prjpath);
|
||||
//
|
||||
if not runPrePostProcess(config.PostBuildProcess) then
|
||||
msgs.message( 'project warning: the post-compilation process has not been properly executed',
|
||||
msgs.message( 'warning: post-compilation process or commands not properly executed',
|
||||
self as ICECommonProject, amcProj, amkWarn);
|
||||
SetCurrentDir(oldCwd);
|
||||
SetCurrentDirUTF8(oldCwd);
|
||||
end;
|
||||
|
||||
function TCENativeProject.run(const runArgs: string = ''): Boolean;
|
||||
|
@ -778,7 +806,7 @@ begin
|
|||
until prm = '';
|
||||
end;
|
||||
//
|
||||
if not fileExists(outputFilename) then
|
||||
if not outputFilename.fileExists then
|
||||
begin
|
||||
getMessageDisplay.message('output executable missing: ' + shortenPath(outputFilename, 25),
|
||||
self as ICECommonProject, amcProj, amkErr);
|
||||
|
@ -788,7 +816,7 @@ begin
|
|||
fRunner.Executable := outputFilename;
|
||||
if fRunner.CurrentDirectory.isEmpty then
|
||||
begin
|
||||
fRunnerOldCwd := GetCurrentDir;
|
||||
fRunnerOldCwd := GetCurrentDirUTF8;
|
||||
cwd := fRunner.Executable.extractFilePath;
|
||||
chDir(cwd);
|
||||
fRunner.CurrentDirectory := cwd;
|
||||
|
@ -858,7 +886,7 @@ var
|
|||
i: integer;
|
||||
begin
|
||||
result := false;
|
||||
if not FileExists(fOutputFilename) then exit;
|
||||
if not fOutputFilename.fileExists then exit;
|
||||
dt := FileAge(fOutputFilename);
|
||||
for i := 0 to fSrcs.Count-1 do
|
||||
if fileAge(sourceAbsolute(i)) > dt then exit;
|
||||
|
@ -941,7 +969,7 @@ var
|
|||
fname: string;
|
||||
begin
|
||||
fname := fSrcs.Strings[index];
|
||||
if FileExists(fname) then
|
||||
if fname.fileExists then
|
||||
result := fname
|
||||
else
|
||||
result := expandFilenameEx(fBasePath, fname);
|
||||
|
@ -990,7 +1018,7 @@ begin
|
|||
gdc: NativeProjectCompilerFilename := exeFullName('cegdcldc' + exeExt);
|
||||
ldc: NativeProjectCompilerFilename := exeFullName('ldmd2' + exeExt);
|
||||
end;
|
||||
if (not fileExists(NativeProjectCompilerFilename))
|
||||
if (not NativeProjectCompilerFilename.fileExists)
|
||||
or NativeProjectCompilerFilename.isEmpty then
|
||||
begin
|
||||
value := dmd;
|
||||
|
|
|
@ -191,12 +191,14 @@ procedure TCEToolItem.execute(previous: TCEToolItem);
|
|||
var
|
||||
prm: string;
|
||||
inp: string;
|
||||
old: string;
|
||||
begin
|
||||
ce_processes.killProcess(fProcess);
|
||||
//
|
||||
if fClearMessages then
|
||||
getMessageDisplay(fMsgs).clearByContext(amcMisc);
|
||||
//
|
||||
old := GetCurrentDirUTF8;
|
||||
fProcess := TCEProcess.Create(nil);
|
||||
fProcess.OnReadData:= @processOutput;
|
||||
fProcess.OnTerminate:= @processOutput;
|
||||
|
@ -214,7 +216,7 @@ begin
|
|||
end;
|
||||
ensureNoPipeIfWait(fProcess);
|
||||
//
|
||||
if FileExists(fProcess.Executable) then
|
||||
if fProcess.Executable.fileExists then
|
||||
begin
|
||||
fProcess.Execute;
|
||||
if previous.isNotNil and previous.outputToNext
|
||||
|
@ -227,6 +229,8 @@ begin
|
|||
fProcess.CloseInput;
|
||||
end;
|
||||
end;
|
||||
//
|
||||
SetCurrentDirUTF8(old);
|
||||
end;
|
||||
|
||||
procedure TCEToolItem.processOutput(sender: TObject);
|
||||
|
|
Loading…
Reference in New Issue