mirror of https://gitlab.com/basile.b/dexed.git
started background tool that compiles native project with gc or ldc
This commit is contained in:
parent
b3a3eaac30
commit
dc90942bb8
|
@ -0,0 +1,24 @@
|
||||||
|
object CurrentProject: TCENativeProject
|
||||||
|
OptionsCollection = <
|
||||||
|
item
|
||||||
|
name = 'default'
|
||||||
|
outputOptions.boundsCheck = onAlways
|
||||||
|
pathsOptions.outputFilename = '../bin/cegdcldc'
|
||||||
|
runOptions.options = [poUsePipes, poStderrToOutPut]
|
||||||
|
runOptions.parameters.Strings = (
|
||||||
|
'-main'
|
||||||
|
'-gdc'
|
||||||
|
)
|
||||||
|
end
|
||||||
|
item
|
||||||
|
name = 'release'
|
||||||
|
outputOptions.inlining = True
|
||||||
|
outputOptions.boundsCheck = offAlways
|
||||||
|
outputOptions.optimizations = True
|
||||||
|
outputOptions.release = True
|
||||||
|
end>
|
||||||
|
Sources.Strings = (
|
||||||
|
'main.d'
|
||||||
|
)
|
||||||
|
ConfigurationIndex = 0
|
||||||
|
end
|
|
@ -0,0 +1,72 @@
|
||||||
|
module cegdcldc;
|
||||||
|
|
||||||
|
import
|
||||||
|
core.thread, std.stdio, std.process, std.file;
|
||||||
|
|
||||||
|
void convertToGdc(string option, ref string[] options)
|
||||||
|
{
|
||||||
|
// files
|
||||||
|
if (option.exists)
|
||||||
|
options ~= option;
|
||||||
|
// switches
|
||||||
|
else switch(option)
|
||||||
|
{
|
||||||
|
default: break;
|
||||||
|
case "w": break;
|
||||||
|
case "wi": break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void convertToLdc2(string option, ref string[] options)
|
||||||
|
{
|
||||||
|
// files
|
||||||
|
if (option.exists)
|
||||||
|
options ~= option;
|
||||||
|
// switches
|
||||||
|
switch(option)
|
||||||
|
{
|
||||||
|
default: break;
|
||||||
|
case "w": break;
|
||||||
|
case "wi": break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(string[] args)
|
||||||
|
{
|
||||||
|
string[] commandLine = [readln];
|
||||||
|
|
||||||
|
if (args.length == 1)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if (commandLine[0] != "gdc" && commandLine[0] != "ldc2")
|
||||||
|
return 2;
|
||||||
|
|
||||||
|
switch(commandLine[0])
|
||||||
|
{
|
||||||
|
case "gdc":
|
||||||
|
foreach(option; args[1..$])
|
||||||
|
convertToGdc(option, commandLine);
|
||||||
|
break;
|
||||||
|
case "ldc2":
|
||||||
|
foreach(option; args[1..$])
|
||||||
|
convertToLdc2(option, commandLine);
|
||||||
|
break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ProcessPipes ppid = pipeProcess(commandLine);
|
||||||
|
while(true)
|
||||||
|
{
|
||||||
|
Thread.sleep(dur!"msecs"(250));
|
||||||
|
auto result = tryWait(ppid.pid);
|
||||||
|
|
||||||
|
foreach(line; ppid.stdout.byLine)
|
||||||
|
stdout.writeln(line);
|
||||||
|
foreach(line; ppid.stderr.byLine)
|
||||||
|
stderr.writeln(line);
|
||||||
|
|
||||||
|
if (result.terminated)
|
||||||
|
return result.status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
Coedit Gdc - Ldc
|
||||||
|
================
|
||||||
|
|
||||||
|
This small program converts the options of a Coedit project (aka _native project_) to [LDC]() or [GDC]() options.
|
|
@ -3,7 +3,7 @@ object _1: TCENativeProject
|
||||||
item
|
item
|
||||||
name = 'default'
|
name = 'default'
|
||||||
documentationOptions.generateDocumentation = True
|
documentationOptions.generateDocumentation = True
|
||||||
documentationOptions.DocumentationDirectory = '..\doc'
|
documentationOptions.DocumentationDirectory = '../doc'
|
||||||
debugingOptions.debug = True
|
debugingOptions.debug = True
|
||||||
debugingOptions.debugIdentifiers.Strings = (
|
debugingOptions.debugIdentifiers.Strings = (
|
||||||
'a'
|
'a'
|
||||||
|
@ -16,18 +16,16 @@ object _1: TCENativeProject
|
||||||
outputOptions.versionIdentifiers.Strings = (
|
outputOptions.versionIdentifiers.Strings = (
|
||||||
'revision_1'
|
'revision_1'
|
||||||
)
|
)
|
||||||
pathsOptions.outputFilename = '..\output\main.exe'
|
pathsOptions.outputFilename = '../output/main'
|
||||||
preBuildProcess.executable = 'C:\Dev\pasproj\Coedit\lazproj\test\coeditproj\pre.bat'
|
|
||||||
preBuildProcess.workingDirectory = '<CPP>'
|
preBuildProcess.workingDirectory = '<CPP>'
|
||||||
preBuildProcess.options = [poWaitOnExit]
|
preBuildProcess.options = [poWaitOnExit]
|
||||||
postBuildProcess.executable = 'C:\Dev\pasproj\Coedit\lazproj\test\coeditproj\post.bat'
|
|
||||||
postBuildProcess.workingDirectory = '<CPP>'
|
postBuildProcess.workingDirectory = '<CPP>'
|
||||||
postBuildProcess.options = [poWaitOnExit]
|
postBuildProcess.options = [poWaitOnExit]
|
||||||
end
|
end
|
||||||
item
|
item
|
||||||
name = 'alternative'
|
name = 'alternative'
|
||||||
documentationOptions.generateDocumentation = True
|
documentationOptions.generateDocumentation = True
|
||||||
documentationOptions.DocumentationDirectory = '..\doc'
|
documentationOptions.DocumentationDirectory = '../doc'
|
||||||
debugingOptions.debug = True
|
debugingOptions.debug = True
|
||||||
debugingOptions.debugLevel = 3
|
debugingOptions.debugLevel = 3
|
||||||
messagesOptions.additionalWarnings = True
|
messagesOptions.additionalWarnings = True
|
||||||
|
@ -38,12 +36,12 @@ object _1: TCENativeProject
|
||||||
outputOptions.versionIdentifiers.Strings = (
|
outputOptions.versionIdentifiers.Strings = (
|
||||||
'revision_2'
|
'revision_2'
|
||||||
)
|
)
|
||||||
pathsOptions.outputFilename = '..\output\main.exe'
|
pathsOptions.outputFilename = '../output/main'
|
||||||
end>
|
end>
|
||||||
Sources.Strings = (
|
Sources.Strings = (
|
||||||
'..\src\main.d'
|
'../src/main.d'
|
||||||
'..\src\barclass.d'
|
'../src/barclass.d'
|
||||||
'..\src\fooclass.d'
|
'../src/fooclass.d'
|
||||||
)
|
)
|
||||||
ConfigurationIndex = 0
|
ConfigurationIndex = 0
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,7 +13,7 @@ import std.stdio;
|
||||||
import fooclass;
|
import fooclass;
|
||||||
import barclass;
|
import barclass;
|
||||||
|
|
||||||
void main(string args[])
|
void main(string[] args)
|
||||||
{
|
{
|
||||||
auto foo = new Foo;
|
auto foo = new Foo;
|
||||||
auto bar = new Bar;
|
auto bar = new Bar;
|
||||||
|
|
|
@ -813,14 +813,14 @@ end;
|
||||||
procedure setDubCompiler(value: TCECompiler);
|
procedure setDubCompiler(value: TCECompiler);
|
||||||
begin
|
begin
|
||||||
case value of
|
case value of
|
||||||
dmd: DubCompilerFilename := exeFullName('dmd');
|
dmd: DubCompilerFilename := exeFullName('dmd' + exeExt);
|
||||||
gdc: DubCompilerFilename := exeFullName('gdc');
|
gdc: DubCompilerFilename := exeFullName('gdc' + exeExt);
|
||||||
ldc: DubCompilerFilename := exeFullName('ldc2');
|
ldc: DubCompilerFilename := exeFullName('ldc2' + exeExt);
|
||||||
end;
|
end;
|
||||||
if (not fileExists(DubCompilerFilename)) or (DubCompilerFilename = '') then
|
if (not fileExists(DubCompilerFilename)) or (DubCompilerFilename = '') then
|
||||||
begin
|
begin
|
||||||
value := dmd;
|
value := dmd;
|
||||||
DubCompilerFilename:= 'dmd';
|
DubCompilerFilename:= 'dmd' + exeExt;
|
||||||
end;
|
end;
|
||||||
DubCompiler := value;
|
DubCompiler := value;
|
||||||
end;
|
end;
|
||||||
|
|
|
@ -44,12 +44,12 @@ type
|
||||||
procedure updateOutFilename;
|
procedure updateOutFilename;
|
||||||
procedure doChanged;
|
procedure doChanged;
|
||||||
procedure getBaseConfig;
|
procedure getBaseConfig;
|
||||||
procedure setLibAliases(const aValue: TStringList);
|
procedure setLibAliases(const value: TStringList);
|
||||||
procedure subMemberChanged(sender : TObject);
|
procedure subMemberChanged(sender : TObject);
|
||||||
procedure setOptsColl(const aValue: TCollection);
|
procedure setOptsColl(const value: TCollection);
|
||||||
procedure setRoot(const aValue: string);
|
procedure setRoot(const value: string);
|
||||||
procedure setSrcs(const aValue: TStringList);
|
procedure setSrcs(const value: TStringList);
|
||||||
procedure setConfIx(aValue: Integer);
|
procedure setConfIx(value: Integer);
|
||||||
function getConfig(const ix: integer): TCompilerConfiguration;
|
function getConfig(const ix: integer): TCompilerConfiguration;
|
||||||
function getCurrConf: TCompilerConfiguration;
|
function getCurrConf: TCompilerConfiguration;
|
||||||
function runPrePostProcess(const processInfo: TCompileProcOptions): Boolean;
|
function runPrePostProcess(const processInfo: TCompileProcOptions): Boolean;
|
||||||
|
@ -182,11 +182,11 @@ begin
|
||||||
result.onChanged := @subMemberChanged;
|
result.onChanged := @subMemberChanged;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCENativeProject.setOptsColl(const aValue: TCollection);
|
procedure TCENativeProject.setOptsColl(const value: TCollection);
|
||||||
var
|
var
|
||||||
i: nativeInt;
|
i: nativeInt;
|
||||||
begin
|
begin
|
||||||
fConfigs.Assign(aValue);
|
fConfigs.Assign(value);
|
||||||
for i:= 0 to fConfigs.Count-1 do
|
for i:= 0 to fConfigs.Count-1 do
|
||||||
Configuration[i].onChanged := @subMemberChanged;
|
Configuration[i].onChanged := @subMemberChanged;
|
||||||
end;
|
end;
|
||||||
|
@ -209,11 +209,11 @@ begin
|
||||||
fSrcs.Add(relSrc);
|
fSrcs.Add(relSrc);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCENativeProject.setRoot(const aValue: string);
|
procedure TCENativeProject.setRoot(const value: string);
|
||||||
begin
|
begin
|
||||||
if fRootFolder = aValue then exit;
|
if fRootFolder = value then exit;
|
||||||
beginUpdate;
|
beginUpdate;
|
||||||
fRootFolder := aValue;
|
fRootFolder := value;
|
||||||
endUpdate;
|
endUpdate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -240,27 +240,27 @@ begin
|
||||||
endUpdate;
|
endUpdate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCENativeProject.setLibAliases(const aValue: TStringList);
|
procedure TCENativeProject.setLibAliases(const value: TStringList);
|
||||||
begin
|
begin
|
||||||
beginUpdate;
|
beginUpdate;
|
||||||
fLibAliases.Assign(aValue);
|
fLibAliases.Assign(value);
|
||||||
endUpdate;
|
endUpdate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCENativeProject.setSrcs(const aValue: TStringList);
|
procedure TCENativeProject.setSrcs(const value: TStringList);
|
||||||
begin
|
begin
|
||||||
beginUpdate;
|
beginUpdate;
|
||||||
fSrcs.Assign(aValue);
|
fSrcs.Assign(value);
|
||||||
patchPlateformPaths(fSrcs);
|
patchPlateformPaths(fSrcs);
|
||||||
endUpdate;
|
endUpdate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCENativeProject.setConfIx(aValue: Integer);
|
procedure TCENativeProject.setConfIx(value: Integer);
|
||||||
begin
|
begin
|
||||||
beginUpdate;
|
beginUpdate;
|
||||||
if aValue < 0 then aValue := 0;
|
if value < 0 then value := 0;
|
||||||
if aValue > fConfigs.Count-1 then aValue := fConfigs.Count-1;
|
if value > fConfigs.Count-1 then value := fConfigs.Count-1;
|
||||||
fConfIx := aValue;
|
fConfIx := value;
|
||||||
endUpdate;
|
endUpdate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -684,7 +684,7 @@ function TCENativeProject.compile: Boolean;
|
||||||
var
|
var
|
||||||
config: TCompilerConfiguration;
|
config: TCompilerConfiguration;
|
||||||
compilproc: TProcess;
|
compilproc: TProcess;
|
||||||
prjpath, oldCwd: string;
|
prjpath, oldCwd, str: string;
|
||||||
prjname: string;
|
prjname: string;
|
||||||
msgs: ICEMessagesDisplay;
|
msgs: ICEMessagesDisplay;
|
||||||
begin
|
begin
|
||||||
|
@ -728,6 +728,14 @@ begin
|
||||||
compilproc.ShowWindow := swoHIDE;
|
compilproc.ShowWindow := swoHIDE;
|
||||||
getOpts(compilproc.Parameters);
|
getOpts(compilproc.Parameters);
|
||||||
compilproc.Execute;
|
compilproc.Execute;
|
||||||
|
if NativeProjectCompiler <> dmd then
|
||||||
|
begin
|
||||||
|
case NativeProjectCompiler of
|
||||||
|
gdc: begin str := 'gdc'; compilproc.Input.Write(str[1], 3) end;
|
||||||
|
ldc: begin str := 'ldc2'; compilproc.Input.Write(str[1], 4) end;
|
||||||
|
end;
|
||||||
|
compilproc.CloseInput;
|
||||||
|
end;
|
||||||
while compilProc.Running do
|
while compilProc.Running do
|
||||||
compProcOutput(compilproc);
|
compProcOutput(compilproc);
|
||||||
if compilproc.ExitStatus = 0 then begin
|
if compilproc.ExitStatus = 0 then begin
|
||||||
|
@ -978,17 +986,15 @@ end;
|
||||||
procedure setNativeProjectCompiler(value: TCECompiler);
|
procedure setNativeProjectCompiler(value: TCECompiler);
|
||||||
begin
|
begin
|
||||||
case value of
|
case value of
|
||||||
// TODO-cfeature: a dmd2gdc and a dmd2ldc2 option translater.
|
dmd: NativeProjectCompilerFilename := exeFullName('dmd' + exeExt);
|
||||||
// maybe done in D using getOpt, as a tool: ceLdcOpt, ceGDCOpt
|
gdc: NativeProjectCompilerFilename := exeFullName('cegdcldc' + exeExt);
|
||||||
dmd: NativeProjectCompilerFilename := exeFullName('dmd');
|
ldc: NativeProjectCompilerFilename := exeFullName('cegdcldc' + exeExt);
|
||||||
gdc: NativeProjectCompilerFilename := ''; // need option translater dmd->gdc
|
|
||||||
ldc: NativeProjectCompilerFilename := ''; // need option translater dmd->ldc
|
|
||||||
end;
|
end;
|
||||||
if (not fileExists(NativeProjectCompilerFilename))
|
if (not fileExists(NativeProjectCompilerFilename))
|
||||||
or (NativeProjectCompilerFilename = '') then
|
or (NativeProjectCompilerFilename = '') then
|
||||||
begin
|
begin
|
||||||
value := dmd;
|
value := dmd;
|
||||||
NativeProjectCompilerFilename:= 'dmd';
|
NativeProjectCompilerFilename:= 'dmd' + exeExt;
|
||||||
end;
|
end;
|
||||||
NativeProjectCompiler := value;
|
NativeProjectCompiler := value;
|
||||||
end;
|
end;
|
||||||
|
|
Loading…
Reference in New Issue