Commit 730c2a4e authored by Basile.B's avatar Basile.B

fix windows build

close #37, #43, #44
parent 4b4b376b
Pipeline #150553641 passed with stages
in 1 minute and 6 seconds
......@@ -9,14 +9,20 @@ import
import
iz.memory;
version(Windows)
{
import core.runtime: rt_init, rt_term;
export extern(C) int d_rt_init(){ return rt_init(); }
export extern(C) int d_rt_term(){ return rt_term(); }
}
extern(C) void setRtOptions()
export extern(C) void setRtOptions()
{
//import core.gc.config : config;
//config.gc = "precise";
}
extern(C) void minimizeGcHeap()
export extern(C) void minimizeGcHeap()
{
import core.memory : GC;
__gshared ubyte c;
......
......@@ -7,7 +7,7 @@ import std.string : toStringz;
extern(C):
const(char)* ddemangle(const(char)* line)
export const(char)* ddemangle(const(char)* line)
{
__gshared Regex!char reDemangle;
__gshared bool reInit;
......
......@@ -20,7 +20,7 @@ import
* caretLine = the line where the declaration is located.
* plusComment = indicates if the template use the "*" or the "+" decoration.
*/
extern(C) const(char)* ddocTemplate(const(char)* src, int caretLine, bool plusComment)
export extern(C) const(char)* ddocTemplate(const(char)* src, int caretLine, bool plusComment)
{
LexerConfig config;
RollbackAllocator rba;
......
module dllmain;
version(Windows)
{
import core.sys.windows.windef;
import core.sys.windows.dll;
extern (Windows) BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID pvReserved)
{
return true;
}
}
\ No newline at end of file
......@@ -30,7 +30,7 @@ version(unittest){} else import
* - the count of operands, named "n2count" (as JSONNumber)
* - the sum of operands, named "n2sum" (as JSONNumber)
*/
extern(C) const(char)* halsteadMetrics(const(char)* src)
export extern(C) const(char)* halsteadMetrics(const(char)* src)
{
LexerConfig config;
RollbackAllocator rba;
......@@ -264,7 +264,7 @@ private final class HalsteadMetric: ASTVisitor
override void visit(const(PrimaryExpression) primary)
{
if (primary.identifierOrTemplateInstance !is null)
if (primary.identifierOrTemplateInstance !is null)
{
if (inFunctionCallChain[$-1])
chain ~= primary.identifierOrTemplateInstance;
......
......@@ -16,6 +16,11 @@ private alias moduleDeclarationToText = (ModuleDeclaration md) => md.moduleName
.map!(a => a.text)
.join(".");
struct Result
{
string[] data;
}
/**
* Lists the modules imported by a module
*
......@@ -27,9 +32,9 @@ private alias moduleDeclarationToText = (ModuleDeclaration md) => md.moduleName
* The results are used by to automatically detect the static libraries used by a
* dexed runnable module.
*/
extern(C) string[] listImports(const(char)* src)
export extern(C) string[]* listImports(const(char)* src)
{
string[] result;
string[]* result = &(new Result).data;
LexerConfig config;
RollbackAllocator rba;
StringCache sCache = StringCache(StringCache.defaultBucketCount);
......@@ -38,11 +43,11 @@ extern(C) string[] listImports(const(char)* src)
.getTokensForParser(config, &sCache)
.parseModule("", &rba, &ignoreErrors);
if (auto md = mod.moduleDeclaration)
result ~= '"' ~ moduleDeclarationToText(md) ~ '"';
*result ~= '"' ~ moduleDeclarationToText(md) ~ '"';
else
result ~= "\"#\"";
*result ~= "\"#\"";
ImportLister il = construct!(ImportLister)(&result);
ImportLister il = construct!(ImportLister)(result);
scope (exit) destruct(il);
il.visit(mod);
......@@ -59,13 +64,13 @@ extern(C) string[] listImports(const(char)* src)
* The results are used by to build a key value store linking libraries to other
* libraries, which is part of dexed "libman".
*/
extern(C) string[] listFilesImports(const(char)* joinedFiles)
export extern(C) string[]* listFilesImports(const(char)* joinedFiles)
{
string[] result;
string[]* result = &(new Result).data;
RollbackAllocator rba;
StringCache sCache = StringCache(StringCache.defaultBucketCount);
LexerConfig config = LexerConfig("", StringBehavior.source);
ImportLister il = construct!(ImportLister)(&result);
ImportLister il = construct!(ImportLister)(result);
scope(exit)
{
......@@ -80,9 +85,9 @@ extern(C) string[] listFilesImports(const(char)* joinedFiles)
.getTokensForParser(config, &sCache)
.parseModule("", &rba, &ignoreErrors);
if (auto md = mod.moduleDeclaration)
result ~= '"' ~ moduleDeclarationToText(md) ~ '"';
*result ~= '"' ~ moduleDeclarationToText(md) ~ '"';
else
result ~= '"' ~ cast(string)fname ~ '"';
*result ~= '"' ~ cast(string)fname ~ '"';
il.visit(mod);
}
......
......@@ -17,7 +17,7 @@ import
* Returns:
* wether a module contains the main function.
*/
extern(C) bool hasMainFun(const(char)* src)
export extern(C) bool hasMainFun(const(char)* src)
{
scope LexerConfig config;
scope RollbackAllocator rba;
......
......@@ -25,7 +25,7 @@ import
* Returns:
* The serialized symbols, as a C string.
*/
extern(C) const(char)* listSymbols(const(char)* src, bool deep)
export extern(C) const(char)* listSymbols(const(char)* src, bool deep)
{
Appender!(AstErrors) errors;
......
......@@ -8,7 +8,7 @@ import
import
common;
extern(C) const(char)* todoItems(const(char)* joinedFiles)
export extern(C) const(char)* todoItems(const(char)* joinedFiles)
{
scope Appender!string stream;
scope LexerConfig config = LexerConfig("", StringBehavior.source);
......
......@@ -869,9 +869,9 @@ begin
fCompilProc := TDexedProcess.Create(nil);
subjProjCompiling(fProjectSubject, fAsProjectItf);
fMsgs.message('compiling ' + prjname, fAsProjectItf, amcProj, amkInf);
fMsgs.message(usingCompilerInfo(CEProjectCompiler), fAsProjectItf, amcProj, amkInf);
fMsgs.message(usingCompilerInfo(CEProjectCompiler, false), fAsProjectItf, amcProj, amkInf);
fCompilProc.CurrentDirectory := prjpath;
fCompilProc.Executable := fCompilerSelector.getCompilerPath(CEProjectCompiler);
fCompilProc.Executable := fCompilerSelector.getCompilerPath(CEProjectCompiler, false);
if not fCompilProc.Executable.fileExists then
begin
fMsgs.message(format('error, the compiler path for `%s` does not seem valid',
......@@ -1072,7 +1072,7 @@ var
begin
str := TStringList.Create;
try
str.Add(fCompilerSelector.getCompilerPath(CEProjectCompiler));
str.Add(fCompilerSelector.getCompilerPath(CEProjectCompiler, false));
getOpts(str);
result := str.Text;
finally
......
......@@ -148,7 +148,7 @@ type
//
function singleServiceName: string;
function isCompilerValid(value: DCompiler): boolean;
function getCompilerPath(value: DCompiler): string;
function getCompilerPath(value: DCompiler; translateToWrapper: boolean): string;
procedure getCompilerImports(value: DCompiler; paths: TStrings);
//
procedure projNew(project: ICommonProject);
......@@ -615,21 +615,21 @@ begin
end;
end;
function TCompilersPathsEditor.getCompilerPath(value: DCompiler): string;
function TCompilersPathsEditor.getCompilerPath(value: DCompiler; translateToWrapper: boolean): string;
begin
result := '';
with fPaths do case value of
DCompiler.dmd: exit(DmdExeName);
DCompiler.gdc: exit(GdcExeName);
DCompiler.gdc: if not translateToWrapper then exit(GdcExeName) else exit(exeFullName('gdmd' + exeExt));
DCompiler.gdmd: exit(exeFullName('gdmd' + exeExt));
DCompiler.ldc: exit(LdcExeName);
DCompiler.ldc: if not translateToWrapper then exit(LdcExeName) else exit(exeFullName('ldmd2' + exeExt));
DCompiler.ldmd: exit(exeFullName('ldmd2' + exeExt));
DCompiler.user1: exit(User1ExeName);
DCompiler.user2: exit(User2ExeName);
DCompiler.global:
begin
checkIfGlobalIsGlobal;
exit(getCompilerPath(fPaths.definedAsGlobal));
exit(getCompilerPath(fPaths.definedAsGlobal, translateToWrapper));
end;
end;
end;
......
......@@ -21,23 +21,25 @@ type
type
PT = ^T;
strict private
fLength: PtrUInt;
fLength: PtrInt;
fPtr: PT;
function getItem(index: PtrUint): T;
function getItem(index: Ptrint): T;
public
// The count of elements
property length: PtrUInt read fLength;
property length: PtrInt read fLength;
// Pointer to the first element.
property ptr: PT read fPtr;
// overload "[]"
property item[index: PtrUint]: T read getItem; default;
property item[index: Ptrint]: T read getItem; default;
end;
// Give a view on D `char[]`
TDString = specialize TDArray<char> ;
PDString = ^TDString;
// Give a view on D `char[][]`
TDStrings = specialize TDArray<TDString>;
PDStrings = ^TDStrings;
{$IFDEF POSIX}
const
......@@ -49,9 +51,9 @@ const
{$ENDIF}
// Necessary to start the GC, run the static constructors, etc
procedure rt_init(); cdecl; external libdexedd_name;
function d_rt_init(): integer; cdecl; external libdexedd_name;
// Cleanup
procedure rt_term(); cdecl; external libdexedd_name;
function d_rt_term(): integer; cdecl; external libdexedd_name;
// Used to release memroy allocated in external D functions that are called in a thread,
// because managing the GC only works from the main thread.
// Memory is released every 32 calls.
......@@ -66,9 +68,9 @@ function hasMainFun(const src: PChar): Boolean; cdecl; external libdexedd_name;
// Returns the DDOC template for the declaration location at `caretLine` in the source code `src`.
function ddocTemplate(const src: PChar; caretLine: integer; plusComment: Boolean): PChar; cdecl; external libdexedd_name;
// List the imports of the module represented by `src`.
function listImports(const src: PChar): TDStrings; cdecl; external libdexedd_name;
function listImports(const src: PChar): PDStrings; cdecl; external libdexedd_name;
// List the imports of the modules located in `files` (list of files joined with pathseparaotr and null terminated)
function listFilesImports(const files: PChar): TDStrings; cdecl; external libdexedd_name;
function listFilesImports(const files: PChar): PDStrings; cdecl; external libdexedd_name;
// Get the variables necessary to compute the Halstead metrics of the functions within a module.
function halsteadMetrics(const src: PChar): PChar; cdecl; external libdexedd_name;
// Get the list of declarations within a module.
......@@ -92,7 +94,7 @@ procedure getModulesImports(files: string; results: TStrings);
implementation
function TDArray.getItem(index: PtrUint): T;
function TDArray.getItem(index: Ptrint): T;
begin
result := (fPtr + index)^;
end;
......@@ -104,7 +106,7 @@ var
j: integer;
s: string;
begin
i := listImports(PChar(source.Text));
i := listImports(PChar(source.Text))^;
for j := 0 to i.length-1 do
begin
e := i[j];
......@@ -121,8 +123,8 @@ var
j: integer;
s: string;
begin
i := listFilesImports(PChar(files));
for j := 0 to i.length-1 do
i := listFilesImports(PChar(files))^;
for j := 0 to i.length-1 do
begin
e := i[j];
s := e.ptr[0 .. e.length-1];
......@@ -133,7 +135,7 @@ end;
initialization
setRtOptions();
rt_init();
d_rt_init();
finalization
rt_term();
d_rt_term();
end.
......@@ -898,7 +898,7 @@ begin
str.Add('--build=' + fBuildTypes[fBuiltTypeIx]);
if (fConfigs.Count <> 1) and (fConfigs[0] <> DubDefaultConfigName) then
str.Add('--config=' + fConfigs[fConfigIx]);
str.Add('--compiler=' + fCompilerSelector.getCompilerPath(DubCompiler));
str.Add('--compiler=' + fCompilerSelector.getCompilerPath(DubCompiler, false));
dubBuildOptions.getOpts(str);
result := str.Text;
finally
......@@ -1164,7 +1164,7 @@ begin
if (fConfigs.Count <> 1) and (fConfigs[0] <> DubDefaultConfigName) then
fDubProc.Parameters.Add('--config=' + fConfigs[fConfigIx]);
end;
d := fCompilerSelector.getCompilerPath(DubCompiler);
d := fCompilerSelector.getCompilerPath(DubCompiler, true);
if not d.fileExists then
begin
fMsgs.message(format('error, the compiler path for `%s` does not seem valid',
......
......@@ -391,13 +391,13 @@ type
// Indicates wether a D compiler is usable.
function isCompilerValid(value: DCompiler): boolean;
// Returns a D compiler exe filename.
function getCompilerPath(value: DCompiler): string;
function getCompilerPath(value: DCompiler; translateToWrapper: boolean): string;
// Fills value with the runtime/phobos import paths for a particular D compiler.
procedure getCompilerImports(value: DCompiler; paths: TStrings);
end;
// Returns a string indicating which compiler will be used.
function usingCompilerInfo(value: DCompiler): string;
function usingCompilerInfo(value: DCompiler; translateToWrapper: boolean): string;
type
......@@ -668,10 +668,10 @@ begin
end;
{$ENDREGION}
function usingCompilerInfo(value: DCompiler): string;
function usingCompilerInfo(value: DCompiler; translateToWrapper: boolean): string;
begin
result := format('using %s (%s)',
[getCompilerSelector.getCompilerPath(value), DCompiler2String[value]]);
[getCompilerSelector.getCompilerPath(value, translateToWrapper), DCompiler2String[value]]);
end;
end.
......@@ -523,7 +523,7 @@ begin
dub.Parameters.Add('build');
dub.Parameters.Add('--build=release');
dub.Parameters.Add('--force');
dub.Parameters.Add('--compiler=' + getCompilerSelector.getCompilerPath(DubCompiler));
dub.Parameters.Add('--compiler=' + getCompilerSelector.getCompilerPath(DubCompiler, false));
dub.CurrentDirectory:= pth;
dub.Execute;
str := TStringList.Create;
......
......@@ -3053,7 +3053,7 @@ begin
dmdproc := TDexedProcess.Create(nil);
try
fMsgs.message('compiling ' + shortenPath(fDoc.fileName, 25), fDoc, amcEdit, amkInf);
fMsgs.message(usingCompilerInfo(fRunnablesOptions.compiler), fDoc, amcEdit, amkInf);
fMsgs.message(usingCompilerInfo(fRunnablesOptions.compiler, true), fDoc, amcEdit, amkInf);
if fDoc.fileName.fileExists then
fDoc.save
else
......@@ -3069,11 +3069,7 @@ begin
dmdproc.OnTerminate:= @asyncprocTerminate;
dmdproc.Options := [poUsePipes, poStderrToOutPut];
dmdproc.CurrentDirectory:=fDoc.fileName.extractFileDir;
case fRunnablesOptions.compiler of
gdc, gdmd: dmdProc.Executable := fCompilerSelector.getCompilerPath(gdmd);
ldc, ldmd: dmdProc.Executable := fCompilerSelector.getCompilerPath(ldmd);
else dmdProc.Executable := fCompilerSelector.getCompilerPath(fRunnablesOptions.compiler);
end;
dmdProc.Executable:= fCompilerSelector.getCompilerPath(fRunnablesOptions.compiler, true);
if not dmdProc.Executable.fileExists then
begin
fMsgs.message(format('error, the compiler path for `%s` does not seem valid',
......@@ -3456,7 +3452,7 @@ begin
{$ENDIF}
fRunProc.XTermProgram:=consoleProgram;
end;
d := fCompilerSelector.getCompilerPath(fRunnablesOptions.compiler);
d := fCompilerSelector.getCompilerPath(fRunnablesOptions.compiler, true);
if not d.fileExists then
begin
fMsgs.message(format('error, the compiler path for `%s` does not seem valid',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment