Skip to content

Commit

Permalink
Merge pull request #114 from rainers/master
Browse files Browse the repository at this point in the history
Visual D 0.50.0-beta3
  • Loading branch information
rainers authored Jun 15, 2019
2 parents 6f0e245 + 0c5511a commit 3f2b9e7
Show file tree
Hide file tree
Showing 12 changed files with 94 additions and 18 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
#define VERSION_MINOR 50
#define VERSION_REVISION 0
#define VERSION_BETA -beta
#define VERSION_BUILD 2
#define VERSION_BUILD 3
30 changes: 30 additions & 0 deletions msbuild/dbuild/CompileD.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public CompileD()
this.switchOrderList.Add("StackStomp");
this.switchOrderList.Add("AllInst");
this.switchOrderList.Add("Main");
this.switchOrderList.Add("LowMem");
this.switchOrderList.Add("DebugCode");
this.switchOrderList.Add("DebugInfo");
this.switchOrderList.Add("DebugFull");
Expand Down Expand Up @@ -389,6 +390,17 @@ public bool Main
}
}

public bool LowMem
{
get { return GetBoolProperty("LowMem"); }
set
{
SetBoolProperty("LowMem", "Low Memory Usage",
"Use garbage collector to reduce memory needed by the compiler (-lowmem)",
"-lowmem", value);
}
}

public string DebugCode
{
get { return GetStringProperty("DebugCode"); }
Expand Down Expand Up @@ -1033,6 +1045,24 @@ public string GenCmdLine(Dictionary<string, object> parameters)
return GenerateCommandLineExceptSwitches(new string[0]);
}

#if TOOLS_V14 || TOOLS_V15
protected override string GenerateCommandLineCommandsExceptSwitches(string[] switchesToRemove, VCToolTask.CommandLineFormat format = VCToolTask.CommandLineFormat.ForBuildLog, VCToolTask.EscapeFormat escapeFormat = VCToolTask.EscapeFormat.Default)
{
string cmd = base.GenerateCommandLineCommandsExceptSwitches(switchesToRemove, format, escapeFormat);
#else
protected override string GenerateCommandLineCommands(VCToolTask.CommandLineFormat format = VCToolTask.CommandLineFormat.ForBuildLog)
{
string cmd = base.GenerateCommandLineCommands(format);
#endif
// must be outside of response file
if (LowMem)
if (string.IsNullOrEmpty(cmd))
cmd = " -lowmem";
else
cmd += " -lowmem"; // must be outside of response file
return cmd;
}

public override bool Execute()
{
if (!String.IsNullOrEmpty(TrackerLogDirectory))
Expand Down
1 change: 1 addition & 0 deletions msbuild/dcompile.targets
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@
ShowGC="%(DCompile.ShowGC)"
IgnorePragma="%(DCompile.IgnorePragma)"
ShowDependencies="%(DCompile.ShowDependencies)"
LowMem="%(DCompile.LowMem)"

DocDir="%(DCompile.DocDir)"
DocFile="%(DCompile.DocFile)"
Expand Down
1 change: 1 addition & 0 deletions msbuild/dcompile_defaults.props
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
<PerformSyntaxCheckOnly>false</PerformSyntaxCheckOnly>
<PreserveSourcePath>false</PreserveSourcePath>
<Main>false</Main>
<LowMem>false</LowMem>
<ShowDependencies>false</ShowDependencies>
<VersionIdentifiers></VersionIdentifiers>
<DebugIdentifiers></DebugIdentifiers>
Expand Down
3 changes: 2 additions & 1 deletion msbuild/dmd.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@
<DataSource Persistence="ProjectFile" ItemType="" Label="" HasConfigurationCondition="true" />
</BoolProperty.DataSource>
</BoolProperty>

<BoolProperty Name="LowMem" Category="General" DisplayName="Enable garbage collection for the compiler"
Description="Uses less memory for the compilation at the cost of slower compilation. (-lowmem)" Switch="-lowmem" />

<!-- =============== Messages =============== -->
<EnumProperty Name="Warnings" Category="Messages" DisplayName="Enable warnings" Description="Enable display of warnings. (-w, -wi)">
Expand Down
2 changes: 2 additions & 0 deletions msbuild/ldc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@
<DataSource Persistence="ProjectFile" ItemType="" Label="" HasConfigurationCondition="true" />
</BoolProperty.DataSource>
</BoolProperty>
<BoolProperty Name="LowMem" Category="General" DisplayName="Enable garbage collection for the compiler"
Description="Uses less memory for the compilation at the cost of slower compilation. (-lowmem)" Switch="-lowmem" />

<!-- =============== Messages =============== -->
<EnumProperty Name="Warnings" Category="Messages" DisplayName="Enable warnings" Description="Enable display of warnings. (-w, -wi)">
Expand Down
10 changes: 6 additions & 4 deletions nsis/visuald.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@
Caption "${LONG_APPNAME} ${VERSION} Setup"
!ifdef DMD
!ifdef LDC
!define OUT_SUFFIX "-dmd${DMD_VERSION}-ldc2-${LDC_VERSION}"
!define OUT_SUFFIX "-dmd-${DMD_VERSION}-ldc2-${LDC_VERSION}"
!else
!define OUT_SUFFIX "-dmd${DMD_VERSION}"
!define OUT_SUFFIX "-dmd-${DMD_VERSION}"
!endif
!else
!define OUT_SUFFIX ""
Expand Down Expand Up @@ -330,7 +330,7 @@ ${MementoSection} "Install DMD" SecDMD

; not using ${File} to keep compiler even if Visual D uninstalled

!define DmdBaseDir "$CompilerInstallDir\dmd${DMD_VERSION}"
!define DmdBaseDir "$CompilerInstallDir\dmd-${DMD_VERSION}"
${SetOutPath} "${DmdBaseDir}"
File /r ${DMD_SRC}\html
File /r ${DMD_SRC}\samples
Expand Down Expand Up @@ -911,6 +911,7 @@ SectionEnd
LangString DESC_SecVS2013 ${LANG_ENGLISH} "Register for usage in Visual Studio 2013."
LangString DESC_SecVS2015 ${LANG_ENGLISH} "Register for usage in Visual Studio 2015."
LangString DESC_SecVS2017 ${LANG_ENGLISH} "Register for usage in Visual Studio 2017."
LangString DESC_SecVS2019 ${LANG_ENGLISH} "Register for usage in Visual Studio 2019."
!ifdef EXPRESS
LangString DESC_SecVCExpress2008 ${LANG_ENGLISH} "Register for usage in Visual C++ Express 2008 (experimental and unusable)."
LangString DESC_SecVCExpress2010 ${LANG_ENGLISH} "Register for usage in Visual C++ Express 2010 (experimental and unusable)."
Expand Down Expand Up @@ -946,6 +947,7 @@ SectionEnd
!insertmacro MUI_DESCRIPTION_TEXT ${SecVS2013} $(DESC_SecVS2013)
!insertmacro MUI_DESCRIPTION_TEXT ${SecVS2015} $(DESC_SecVS2015)
!insertmacro MUI_DESCRIPTION_TEXT ${SecVS2017} $(DESC_SecVS2017)
!insertmacro MUI_DESCRIPTION_TEXT ${SecVS2019} $(DESC_SecVS2019)
!ifdef EXPRESS
!insertmacro MUI_DESCRIPTION_TEXT ${SecVCExpress2008} $(DESC_SecVCExpress2008)
!insertmacro MUI_DESCRIPTION_TEXT ${SecVCExpress2008} $(DESC_SecVCExpress2010)
Expand Down Expand Up @@ -1281,7 +1283,7 @@ Function DMDInstallPage
IfErrors 0 HasDInstallationFolder
ReadRegStr $DInstallDir HKLM "SOFTWARE\D" "Install_Dir"
IfErrors 0 HasDInstallationFolder
StrCpy $DInstallDir "c:\D"
StrCpy $DInstallDir "C:\D"
HasDInstallationFolder:
StrCpy $CompilerInstallDir $DInstallDir
HasCompilerInstallDir:
Expand Down
10 changes: 5 additions & 5 deletions stdext/string.d
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ bool _startsWith(string s, string w)
//alias startsWith _startsWith;

// munch deprecated in phobos
char[] _munch(ref char[] s, const(char)[] pattern) @safe pure @nogc
inout(char)[] _munch(ref inout(char)[] s, const(char)[] pattern) @safe pure @nogc
{
size_t j = s.length;
foreach (i, dchar c; s)
Expand All @@ -272,12 +272,12 @@ char[] _munch(ref char[] s, const(char)[] pattern) @safe pure @nogc
break;
}
}
char[] head = s[0 .. j];
auto head = s[0 .. j];
s = s[j .. $];
return head;
}

bool parseLong(ref char[] txt, out long res)
bool parseLong(ref const(char)[] txt, out long res)
{
_munch(txt, " \t\n\r");
int n = 0;
Expand All @@ -290,13 +290,13 @@ bool parseLong(ref char[] txt, out long res)
return true;
}

char[] parseNonSpace(ref char[] txt)
inout(char)[] parseNonSpace(ref inout(char)[] txt)
{
_munch(txt, " \t\n\r");
int n = 0;
while(n < txt.length && !isWhite(txt[n]))
n++;
char[] res = txt[0..n];
auto res = txt[0..n];
txt = txt[n..$];
return res;
}
Expand Down
2 changes: 1 addition & 1 deletion visuald/dlangsvc.d
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ class LanguageService : DisposingComObject,
*/
*pbstrName = null;
*piLineOffset = 0;
return S_OK;
return E_FAIL;
}

override HRESULT GetProximityExpressions(IVsTextBuffer pBuffer, in int iLine, in int iCol, in int cLines, IVsEnumBSTR* ppEnum)
Expand Down
6 changes: 3 additions & 3 deletions visuald/profiler.d
Original file line number Diff line number Diff line change
Expand Up @@ -2036,14 +2036,14 @@ class ProfileItemIndex
}
else if(curItem)
{
char[] txt = buf;
const(char)[] txt = buf;
_munch(txt, " \t\n\r");
if(txt.length > 0 && isDigit(txt[0]))
{
long calls;
if(parseLong(txt, calls))
{
char[] id = parseNonSpace(txt);
auto id = parseNonSpace(txt);
if(id.length > 0)
{
_munch(txt, " \t\n\r");
Expand All @@ -2061,7 +2061,7 @@ class ProfileItemIndex
else if(txt.length > 0)
{
long calls, treeTime, funcTime;
char[] id = parseNonSpace(txt);
auto id = parseNonSpace(txt);
if(id.length > 0 &&
parseLong(txt, calls) &&
parseLong(txt, treeTime) &&
Expand Down
17 changes: 16 additions & 1 deletion visuald/propertypage.d
Original file line number Diff line number Diff line change
Expand Up @@ -2532,7 +2532,7 @@ class UpdatePropertyPage : GlobalPropertyPage
auto info = checkForUpdate(CheckProduct.VisualD, -1.days, opts.checkUpdatesVisualD);
updateVisualDInfo(info);

info = checkForUpdate(CheckProduct.DMD, -1.days, opts.checkUpdatesVisualD);
info = checkForUpdate(CheckProduct.DMD, -1.days, opts.checkUpdatesDMD);
updateDMDInfo(info);

info = checkForUpdate(CheckProduct.LDC, -1.days, opts.checkUpdatesLDC);
Expand Down Expand Up @@ -2985,6 +2985,7 @@ struct MagoOptions
bool showVTable;
bool flatClassFields;
bool expandableStrings;
uint maxArrayElements;

void saveToRegistry()
{
Expand All @@ -2994,6 +2995,7 @@ struct MagoOptions
keyMago.Set("showVTable", showVTable);
keyMago.Set("flatClassFields", flatClassFields);
keyMago.Set("expandableStrings", expandableStrings);
keyMago.Set("maxArrayElements", maxArrayElements);
}

void loadFromRegistry()
Expand All @@ -3005,6 +3007,7 @@ struct MagoOptions
showVTable = (keyMago.GetDWORD("showVTable", 1) != 0);
flatClassFields = (keyMago.GetDWORD("flatClassFields", 0) != 0);
expandableStrings = (keyMago.GetDWORD("expandableStrings", 0) != 0);
maxArrayElements = keyMago.GetDWORD("maxArrayElements", 1000);
}
}

Expand All @@ -3023,6 +3026,10 @@ class MagoPropertyPage : ResizablePropertyPage
AddControl("", mShowVTable = new CheckBox(mCanvas, "Show virtual function table as field of classes"));
AddControl("", mFlatClassFields = new CheckBox(mCanvas, "Show base class fields as direct fields"));
AddControl("", mExpandableStrings = new CheckBox(mCanvas, "Expand strings to show array of characters"));
auto saveWidth = kLabelWidth;
kLabelWidth = kPageWidth * 4 / 5;
AddControl("Limit array elements shown in expansions to", mMaxArrayElements = new Text(mCanvas));
kLabelWidth = saveWidth;
}

override void UpdateDirty(bool bDirty)
Expand Down Expand Up @@ -3069,6 +3076,7 @@ class MagoPropertyPage : ResizablePropertyPage
mShowVTable.setChecked(mOptions.showVTable);
mFlatClassFields.setChecked(mOptions.flatClassFields);
mExpandableStrings.setChecked(mOptions.expandableStrings);
mMaxArrayElements.setText(to!string(mOptions.maxArrayElements));
}

int DoApply(ref MagoOptions opts, ref MagoOptions refopts)
Expand All @@ -3079,6 +3087,12 @@ class MagoPropertyPage : ResizablePropertyPage
changes += changeOption(mShowVTable.isChecked(), opts.showVTable, refopts.showVTable);
changes += changeOption(mFlatClassFields.isChecked(), opts.flatClassFields, refopts.flatClassFields);
changes += changeOption(mExpandableStrings.isChecked(), opts.expandableStrings, refopts.expandableStrings);

import stdext.string;
long maxelem;
const(char)[] txt = mMaxArrayElements.getText();
if (parseLong(txt, maxelem))
changes += changeOption(cast(uint)maxelem, opts.maxArrayElements, refopts.maxArrayElements);
return changes;
}

Expand All @@ -3087,6 +3101,7 @@ class MagoPropertyPage : ResizablePropertyPage
CheckBox mShowVTable;
CheckBox mFlatClassFields;
CheckBox mExpandableStrings;
Text mMaxArrayElements;
}

///////////////////////////////////////////////////////////////////////////////
Expand Down
28 changes: 26 additions & 2 deletions visuald/updates.d
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,22 @@ struct UpdateInfo
}

UpdateInfo* checkForUpdate(CheckProduct prod, Duration renew, int frequency)
{
auto info = _checkForUpdate(prod, renew, frequency);

if (prod == CheckProduct.DMD && frequency == CheckFrequency.DailyPrereleases)
{
// check releases for DMD prerelases, too
auto relinfo = _checkForUpdate(prod, renew, CheckFrequency.Daily);
auto prever = extractVersion(info.name);
auto relver = extractVersion(relinfo.name);
if (relver > prever)
info = relinfo;
}
return info;
}

UpdateInfo* _checkForUpdate(CheckProduct prod, Duration renew, int frequency)
{
bool prereleases = frequency == CheckFrequency.DailyPrereleases;
string updateDir = std.path.buildPath(environment["APPDATA"], "VisualD", "Updates");
Expand Down Expand Up @@ -118,7 +134,9 @@ UpdateInfo* checkForUpdate(CheckProduct prod, Duration renew, int frequency)
{
auto info = new UpdateInfo;
info.name = "DMD " ~ txt;
info.download_url = "http://" ~ domain ~ url[0..$-6] ~ "2.x/" ~ txt ~ "/dmd." ~ txt ~ ".windows.7z";
auto verinfo = extractVersion(txt);
auto ver = verinfo.major ~ "." ~ verinfo.minor ~ "." ~ verinfo.rev;
info.download_url = "http://" ~ domain ~ url[0..$-6] ~ verinfo.major ~ ".x/" ~ ver ~ "/dmd." ~ txt ~ ".windows.7z";
info.lastCheck = modTime;
info.updated = updated;
return info;
Expand Down Expand Up @@ -238,7 +256,13 @@ void winHttpGet(DownloadRequest* req)
header.ptr, &dwSize,
WINHTTP_NO_HEADER_INDEX);
debug(UPDATE) writeln("Header: ", header);

auto lines = header.splitLines();
if (lines.length == 0 || !lines[0].startsWith("HTTP/"))
throw new Exception("no HTTP header");
if (!lines[0].endsWith(" OK"))
throw new Exception(to!string(lines[0]));

foreach(ln; lines)
if (ln.startsWith("Content-Length:"))
{
Expand Down Expand Up @@ -531,7 +555,7 @@ void doUpdate(string baseDir, CheckProduct prod, int frequency, void delegate(st
break;

case CheckProduct.DMD:
string dmdname = info.name.replace(" ", "").toLower();
string dmdname = info.name.replace(" ", "-").toLower();
string dmd2x = buildPath(baseDir, dmdname);
unzipCompiler(tgtfile, "dmd2", dmd2x);
Package.GetGlobalOptions().DMD.InstallDir = dmd2x;
Expand Down

0 comments on commit 3f2b9e7

Please sign in to comment.