mirror of https://gitlab.com/basile.b/dexed.git
added symbolic string support to pre/post build processes name. added related example.
This commit is contained in:
parent
5dd9f2aff4
commit
074a767438
|
|
@ -0,0 +1,30 @@
|
||||||
|
object CurrentProject: TCEProject
|
||||||
|
OptionsCollection = <
|
||||||
|
item
|
||||||
|
name = 'release'
|
||||||
|
outputOptions.inlining = True
|
||||||
|
outputOptions.noBoundsCheck = False
|
||||||
|
outputOptions.boundsCheck = offAlways
|
||||||
|
outputOptions.optimizations = True
|
||||||
|
outputOptions.release = True
|
||||||
|
pathsOptions.outputFilename = '<CPP>..\..\cleaner.exe'
|
||||||
|
preBuildProcess.options = []
|
||||||
|
preBuildProcess.showWindow = swoNone
|
||||||
|
postBuildProcess.executable = '<CAP>cleaner.exe'
|
||||||
|
postBuildProcess.options = [poUsePipes, poStderrToOutPut]
|
||||||
|
postBuildProcess.parameters.Strings = (
|
||||||
|
'-r'
|
||||||
|
'-f'
|
||||||
|
'<CAP>'
|
||||||
|
'-e'
|
||||||
|
'.tmp,.res'
|
||||||
|
)
|
||||||
|
postBuildProcess.showWindow = swoHIDE
|
||||||
|
runOptions.options = []
|
||||||
|
runOptions.showWindow = swoNone
|
||||||
|
end>
|
||||||
|
Sources.Strings = (
|
||||||
|
'..\src\cleaner.d'
|
||||||
|
)
|
||||||
|
ConfigurationIndex = 0
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,65 @@
|
||||||
|
module cleaner;
|
||||||
|
|
||||||
|
import std.stdio;
|
||||||
|
import std.path;
|
||||||
|
import std.file;
|
||||||
|
import std.getopt;
|
||||||
|
import std.array;
|
||||||
|
|
||||||
|
//as a runnable: -f "dir" -r -e ".ext1,.ext2"
|
||||||
|
|
||||||
|
/*
|
||||||
|
as a post-build process, parameter list:
|
||||||
|
-f
|
||||||
|
pathtoclean (w/o dbl quotes)
|
||||||
|
-r
|
||||||
|
-e
|
||||||
|
.a,.b,.c
|
||||||
|
*/
|
||||||
|
void main(string args[])
|
||||||
|
{
|
||||||
|
bool recursive;
|
||||||
|
string root;
|
||||||
|
string userexts;
|
||||||
|
string exts[];
|
||||||
|
|
||||||
|
exts ~= [".obj", ".o"];
|
||||||
|
|
||||||
|
getopt(args, config.passThrough,
|
||||||
|
"f|from", &root,
|
||||||
|
"r|recursive", &recursive,
|
||||||
|
"e|ext", &userexts
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!exists(root) || root.length == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (userexts.length != 0)
|
||||||
|
{
|
||||||
|
auto itms = split(userexts, ',');
|
||||||
|
foreach(itm; itms)
|
||||||
|
if (itm.length > 1 && itm[0] == '.')
|
||||||
|
exts ~= itm;
|
||||||
|
}
|
||||||
|
|
||||||
|
void clean(in string currroot)
|
||||||
|
{
|
||||||
|
DirIterator entries = dirEntries(currroot, SpanMode.shallow);
|
||||||
|
|
||||||
|
foreach(entry; entries)
|
||||||
|
{
|
||||||
|
scope(failure){}
|
||||||
|
|
||||||
|
if (!isDir(entry))
|
||||||
|
{
|
||||||
|
foreach(trg_ext; exts)
|
||||||
|
if (entry.extension == trg_ext)
|
||||||
|
std.file.remove(entry);
|
||||||
|
}
|
||||||
|
else if (recursive)
|
||||||
|
clean(entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
clean(root);
|
||||||
|
}
|
||||||
|
|
@ -646,7 +646,10 @@ begin
|
||||||
ext := extractFileExt(anExeName);
|
ext := extractFileExt(anExeName);
|
||||||
if ext <> exeExt then
|
if ext <> exeExt then
|
||||||
anExeName += exeExt;
|
anExeName += exeExt;
|
||||||
exit(ExeSearch(anExeName, '') <> '');
|
if FileExists(anExeName) then
|
||||||
|
exit(true)
|
||||||
|
else
|
||||||
|
exit(ExeSearch(anExeName, '') <> '');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
|
|
|
||||||
|
|
@ -1259,7 +1259,7 @@ procedure TCEMainForm.compileProject(const aProject: TCEProject);
|
||||||
var
|
var
|
||||||
dmdproc: TProcess;
|
dmdproc: TProcess;
|
||||||
ppproc: TProcess;
|
ppproc: TProcess;
|
||||||
olddir, prjpath: string;
|
olddir, prjpath, ppname: string;
|
||||||
i: NativeInt;
|
i: NativeInt;
|
||||||
begin
|
begin
|
||||||
|
|
||||||
|
|
@ -1267,12 +1267,14 @@ begin
|
||||||
|
|
||||||
with fProject.currentConfiguration do
|
with fProject.currentConfiguration do
|
||||||
begin
|
begin
|
||||||
if preBuildProcess.executable <> '' then
|
ppname := expandSymbolicString(preBuildProcess.executable);
|
||||||
if exeInSysPath(preBuildProcess.executable) then
|
if ppname <> '``' then
|
||||||
|
if exeInSysPath(ppname) then
|
||||||
begin
|
begin
|
||||||
ppproc := TProcess.Create(nil);
|
ppproc := TProcess.Create(nil);
|
||||||
try
|
try
|
||||||
preBuildProcess.setProcess(ppproc);
|
preBuildProcess.setProcess(ppproc);
|
||||||
|
ppproc.Executable := ppname;
|
||||||
for i:= 0 to ppproc.Parameters.Count-1 do
|
for i:= 0 to ppproc.Parameters.Count-1 do
|
||||||
ppproc.Parameters.Strings[i] := expandSymbolicString(ppproc.Parameters.Strings[i]);
|
ppproc.Parameters.Strings[i] := expandSymbolicString(ppproc.Parameters.Strings[i]);
|
||||||
if ppproc.CurrentDirectory = '' then
|
if ppproc.CurrentDirectory = '' then
|
||||||
|
|
@ -1324,12 +1326,14 @@ begin
|
||||||
|
|
||||||
with fProject.currentConfiguration do
|
with fProject.currentConfiguration do
|
||||||
begin
|
begin
|
||||||
if postBuildProcess.executable <> '' then
|
ppname := expandSymbolicString(postBuildProcess.executable);
|
||||||
if exeInSysPath(postBuildProcess.executable) then
|
if ppname <> '``' then
|
||||||
|
if exeInSysPath(ppname) then
|
||||||
begin
|
begin
|
||||||
ppproc := TProcess.Create(nil);
|
ppproc := TProcess.Create(nil);
|
||||||
try
|
try
|
||||||
postBuildProcess.setProcess(ppproc);
|
postBuildProcess.setProcess(ppproc);
|
||||||
|
ppproc.Executable := ppname;
|
||||||
for i:= 0 to ppproc.Parameters.Count-1 do
|
for i:= 0 to ppproc.Parameters.Count-1 do
|
||||||
ppproc.Parameters.Strings[i] := expandSymbolicString(ppproc.Parameters.Strings[i]);
|
ppproc.Parameters.Strings[i] := expandSymbolicString(ppproc.Parameters.Strings[i]);
|
||||||
if ppproc.CurrentDirectory = '' then
|
if ppproc.CurrentDirectory = '' then
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue