started background tool that compiles native project with gc or ldc

This commit is contained in:
Basile Burg 2015-12-10 23:55:37 +01:00
parent b3a3eaac30
commit dc90942bb8
7 changed files with 143 additions and 39 deletions

24
cegdcldc/cegdcldc.coedit Normal file
View File

@ -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

72
cegdcldc/main.d Normal file
View File

@ -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;
}
}

4
cegdcldc/readme.md Normal file
View File

@ -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.

View File

@ -3,7 +3,7 @@ object _1: TCENativeProject
item
name = 'default'
documentationOptions.generateDocumentation = True
documentationOptions.DocumentationDirectory = '..\doc'
documentationOptions.DocumentationDirectory = '../doc'
debugingOptions.debug = True
debugingOptions.debugIdentifiers.Strings = (
'a'
@ -16,18 +16,16 @@ object _1: TCENativeProject
outputOptions.versionIdentifiers.Strings = (
'revision_1'
)
pathsOptions.outputFilename = '..\output\main.exe'
preBuildProcess.executable = 'C:\Dev\pasproj\Coedit\lazproj\test\coeditproj\pre.bat'
pathsOptions.outputFilename = '../output/main'
preBuildProcess.workingDirectory = '<CPP>'
preBuildProcess.options = [poWaitOnExit]
postBuildProcess.executable = 'C:\Dev\pasproj\Coedit\lazproj\test\coeditproj\post.bat'
postBuildProcess.workingDirectory = '<CPP>'
postBuildProcess.options = [poWaitOnExit]
end
item
name = 'alternative'
documentationOptions.generateDocumentation = True
documentationOptions.DocumentationDirectory = '..\doc'
documentationOptions.DocumentationDirectory = '../doc'
debugingOptions.debug = True
debugingOptions.debugLevel = 3
messagesOptions.additionalWarnings = True
@ -38,12 +36,12 @@ object _1: TCENativeProject
outputOptions.versionIdentifiers.Strings = (
'revision_2'
)
pathsOptions.outputFilename = '..\output\main.exe'
pathsOptions.outputFilename = '../output/main'
end>
Sources.Strings = (
'..\src\main.d'
'..\src\barclass.d'
'..\src\fooclass.d'
'../src/main.d'
'../src/barclass.d'
'../src/fooclass.d'
)
ConfigurationIndex = 0
end

View File

@ -13,7 +13,7 @@ import std.stdio;
import fooclass;
import barclass;
void main(string args[])
void main(string[] args)
{
auto foo = new Foo;
auto bar = new Bar;

View File

@ -813,14 +813,14 @@ end;
procedure setDubCompiler(value: TCECompiler);
begin
case value of
dmd: DubCompilerFilename := exeFullName('dmd');
gdc: DubCompilerFilename := exeFullName('gdc');
ldc: DubCompilerFilename := exeFullName('ldc2');
dmd: DubCompilerFilename := exeFullName('dmd' + exeExt);
gdc: DubCompilerFilename := exeFullName('gdc' + exeExt);
ldc: DubCompilerFilename := exeFullName('ldc2' + exeExt);
end;
if (not fileExists(DubCompilerFilename)) or (DubCompilerFilename = '') then
begin
value := dmd;
DubCompilerFilename:= 'dmd';
DubCompilerFilename:= 'dmd' + exeExt;
end;
DubCompiler := value;
end;

View File

@ -44,12 +44,12 @@ type
procedure updateOutFilename;
procedure doChanged;
procedure getBaseConfig;
procedure setLibAliases(const aValue: TStringList);
procedure setLibAliases(const value: TStringList);
procedure subMemberChanged(sender : TObject);
procedure setOptsColl(const aValue: TCollection);
procedure setRoot(const aValue: string);
procedure setSrcs(const aValue: TStringList);
procedure setConfIx(aValue: Integer);
procedure setOptsColl(const value: TCollection);
procedure setRoot(const value: string);
procedure setSrcs(const value: TStringList);
procedure setConfIx(value: Integer);
function getConfig(const ix: integer): TCompilerConfiguration;
function getCurrConf: TCompilerConfiguration;
function runPrePostProcess(const processInfo: TCompileProcOptions): Boolean;
@ -182,11 +182,11 @@ begin
result.onChanged := @subMemberChanged;
end;
procedure TCENativeProject.setOptsColl(const aValue: TCollection);
procedure TCENativeProject.setOptsColl(const value: TCollection);
var
i: nativeInt;
begin
fConfigs.Assign(aValue);
fConfigs.Assign(value);
for i:= 0 to fConfigs.Count-1 do
Configuration[i].onChanged := @subMemberChanged;
end;
@ -209,11 +209,11 @@ begin
fSrcs.Add(relSrc);
end;
procedure TCENativeProject.setRoot(const aValue: string);
procedure TCENativeProject.setRoot(const value: string);
begin
if fRootFolder = aValue then exit;
if fRootFolder = value then exit;
beginUpdate;
fRootFolder := aValue;
fRootFolder := value;
endUpdate;
end;
@ -240,27 +240,27 @@ begin
endUpdate;
end;
procedure TCENativeProject.setLibAliases(const aValue: TStringList);
procedure TCENativeProject.setLibAliases(const value: TStringList);
begin
beginUpdate;
fLibAliases.Assign(aValue);
fLibAliases.Assign(value);
endUpdate;
end;
procedure TCENativeProject.setSrcs(const aValue: TStringList);
procedure TCENativeProject.setSrcs(const value: TStringList);
begin
beginUpdate;
fSrcs.Assign(aValue);
fSrcs.Assign(value);
patchPlateformPaths(fSrcs);
endUpdate;
end;
procedure TCENativeProject.setConfIx(aValue: Integer);
procedure TCENativeProject.setConfIx(value: Integer);
begin
beginUpdate;
if aValue < 0 then aValue := 0;
if aValue > fConfigs.Count-1 then aValue := fConfigs.Count-1;
fConfIx := aValue;
if value < 0 then value := 0;
if value > fConfigs.Count-1 then value := fConfigs.Count-1;
fConfIx := value;
endUpdate;
end;
@ -684,7 +684,7 @@ function TCENativeProject.compile: Boolean;
var
config: TCompilerConfiguration;
compilproc: TProcess;
prjpath, oldCwd: string;
prjpath, oldCwd, str: string;
prjname: string;
msgs: ICEMessagesDisplay;
begin
@ -728,6 +728,14 @@ begin
compilproc.ShowWindow := swoHIDE;
getOpts(compilproc.Parameters);
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
compProcOutput(compilproc);
if compilproc.ExitStatus = 0 then begin
@ -978,17 +986,15 @@ end;
procedure setNativeProjectCompiler(value: TCECompiler);
begin
case value of
// TODO-cfeature: a dmd2gdc and a dmd2ldc2 option translater.
// maybe done in D using getOpt, as a tool: ceLdcOpt, ceGDCOpt
dmd: NativeProjectCompilerFilename := exeFullName('dmd');
gdc: NativeProjectCompilerFilename := ''; // need option translater dmd->gdc
ldc: NativeProjectCompilerFilename := ''; // need option translater dmd->ldc
dmd: NativeProjectCompilerFilename := exeFullName('dmd' + exeExt);
gdc: NativeProjectCompilerFilename := exeFullName('cegdcldc' + exeExt);
ldc: NativeProjectCompilerFilename := exeFullName('cegdcldc' + exeExt);
end;
if (not fileExists(NativeProjectCompilerFilename))
or (NativeProjectCompilerFilename = '') then
begin
value := dmd;
NativeProjectCompilerFilename:= 'dmd';
NativeProjectCompilerFilename:= 'dmd' + exeExt;
end;
NativeProjectCompiler := value;
end;