diff --git a/Beef.sln b/Beef.sln index 71525de7..d0679726 100644 --- a/Beef.sln +++ b/Beef.sln @@ -405,7 +405,7 @@ Global HideSolutionNode = FALSE EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - VD_Solution = |§r|§n|§r|§n |§r|§n X86|§r|§n |§r|§n SolutionGuid = {460361DC-9F40-4AE7-B647-82D5D69B70DC} + VD_Solution = |§r|§n|§r|§n |§r|§n X86|§r|§n |§r|§n EndGlobalSection EndGlobal diff --git a/BeefLibs/Beefy2D/src/BFApp.bf b/BeefLibs/Beefy2D/src/BFApp.bf index 89d769f3..e6f68a3d 100644 --- a/BeefLibs/Beefy2D/src/BFApp.bf +++ b/BeefLibs/Beefy2D/src/BFApp.bf @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Text; -using System.Runtime.InteropServices; using System.Diagnostics; using System.IO; using Beefy.gfx; diff --git a/BeefLibs/Beefy2D/src/BFWindow.bf b/BeefLibs/Beefy2D/src/BFWindow.bf index 6e6903e8..3dc95c47 100644 --- a/BeefLibs/Beefy2D/src/BFWindow.bf +++ b/BeefLibs/Beefy2D/src/BFWindow.bf @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Text; -using System.Runtime.InteropServices; using System.Diagnostics; using Beefy.gfx; using Beefy.sys; diff --git a/BeefLibs/Beefy2D/src/Utils.bf b/BeefLibs/Beefy2D/src/Utils.bf index 63bd03a9..e3bdde0f 100644 --- a/BeefLibs/Beefy2D/src/Utils.bf +++ b/BeefLibs/Beefy2D/src/Utils.bf @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Text; -using System.Runtime.InteropServices; using System.Reflection; using System.Threading; using System.IO; diff --git a/BeefLibs/Beefy2D/src/gfx/ConstantDataDefinition.bf b/BeefLibs/Beefy2D/src/gfx/ConstantDataDefinition.bf index 0c2cbb39..7a726e2b 100644 --- a/BeefLibs/Beefy2D/src/gfx/ConstantDataDefinition.bf +++ b/BeefLibs/Beefy2D/src/gfx/ConstantDataDefinition.bf @@ -2,7 +2,6 @@ using System; using System.Collections.Generic; using System.Text; using System.Threading.Tasks; -using System.Runtime.InteropServices; using System.Reflection; using System.Diagnostics; diff --git a/BeefLibs/Beefy2D/src/gfx/DrawLayer.bf b/BeefLibs/Beefy2D/src/gfx/DrawLayer.bf index c1b37661..09b8b4df 100644 --- a/BeefLibs/Beefy2D/src/gfx/DrawLayer.bf +++ b/BeefLibs/Beefy2D/src/gfx/DrawLayer.bf @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Runtime.InteropServices; using System.Text; using Beefy.widgets; using Beefy; diff --git a/BeefLibs/Beefy2D/src/gfx/Font.bf b/BeefLibs/Beefy2D/src/gfx/Font.bf index f85effd8..fddb5d92 100644 --- a/BeefLibs/Beefy2D/src/gfx/Font.bf +++ b/BeefLibs/Beefy2D/src/gfx/Font.bf @@ -1,5 +1,4 @@ using System; -using System.Runtime.InteropServices; using System.Collections.Generic; using System.Text; using System.IO; diff --git a/BeefLibs/Beefy2D/src/gfx/Graphics.bf b/BeefLibs/Beefy2D/src/gfx/Graphics.bf index 38552d58..17cc13c2 100644 --- a/BeefLibs/Beefy2D/src/gfx/Graphics.bf +++ b/BeefLibs/Beefy2D/src/gfx/Graphics.bf @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Text; -using System.Runtime.InteropServices; using Beefy.utils; using Beefy.geom; using System.Diagnostics; diff --git a/BeefLibs/Beefy2D/src/gfx/Image.bf b/BeefLibs/Beefy2D/src/gfx/Image.bf index 0df2ea4b..275ceaf8 100644 --- a/BeefLibs/Beefy2D/src/gfx/Image.bf +++ b/BeefLibs/Beefy2D/src/gfx/Image.bf @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Text; -using System.Runtime.InteropServices; using Beefy.utils; using System.Diagnostics; diff --git a/BeefLibs/Beefy2D/src/gfx/Model.bf b/BeefLibs/Beefy2D/src/gfx/Model.bf index dc47ee35..fc1ef489 100644 --- a/BeefLibs/Beefy2D/src/gfx/Model.bf +++ b/BeefLibs/Beefy2D/src/gfx/Model.bf @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Text; -using System.Runtime.InteropServices; using System.Threading.Tasks; using Beefy; using Beefy.utils; diff --git a/BeefLibs/Beefy2D/src/gfx/RenderState.bf b/BeefLibs/Beefy2D/src/gfx/RenderState.bf index dc769822..31f6713d 100644 --- a/BeefLibs/Beefy2D/src/gfx/RenderState.bf +++ b/BeefLibs/Beefy2D/src/gfx/RenderState.bf @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; using Beefy; diff --git a/BeefLibs/Beefy2D/src/gfx/Shader.bf b/BeefLibs/Beefy2D/src/gfx/Shader.bf index 53f73ddf..c2835f4e 100644 --- a/BeefLibs/Beefy2D/src/gfx/Shader.bf +++ b/BeefLibs/Beefy2D/src/gfx/Shader.bf @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Text; -using System.Runtime.InteropServices; namespace Beefy.gfx { diff --git a/BeefLibs/Beefy2D/src/gfx/Vertex3D.bf b/BeefLibs/Beefy2D/src/gfx/Vertex3D.bf index 8326728f..6823c9fa 100644 --- a/BeefLibs/Beefy2D/src/gfx/Vertex3D.bf +++ b/BeefLibs/Beefy2D/src/gfx/Vertex3D.bf @@ -2,7 +2,6 @@ using System; using System.Collections.Generic; using System.Text; using System.Threading.Tasks; -using System.Runtime.InteropServices; namespace Beefy.gfx { diff --git a/BeefLibs/Beefy2D/src/gfx/VertexDefinition.bf b/BeefLibs/Beefy2D/src/gfx/VertexDefinition.bf index a1622f17..87f89356 100644 --- a/BeefLibs/Beefy2D/src/gfx/VertexDefinition.bf +++ b/BeefLibs/Beefy2D/src/gfx/VertexDefinition.bf @@ -2,7 +2,6 @@ using System; using System.Collections.Generic; using System.Text; using System.Threading.Tasks; -using System.Runtime.InteropServices; using System.Reflection; using System.Diagnostics; diff --git a/BeefLibs/Beefy2D/src/res/PSDReader.bf b/BeefLibs/Beefy2D/src/res/PSDReader.bf index ff663221..dd53c74c 100644 --- a/BeefLibs/Beefy2D/src/res/PSDReader.bf +++ b/BeefLibs/Beefy2D/src/res/PSDReader.bf @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Text; -using System.Runtime.InteropServices; using Beefy.gfx; namespace Beefy.res diff --git a/BeefLibs/Beefy2D/src/res/ResourceManager.bf b/BeefLibs/Beefy2D/src/res/ResourceManager.bf index 784d66e5..90e05d00 100644 --- a/BeefLibs/Beefy2D/src/res/ResourceManager.bf +++ b/BeefLibs/Beefy2D/src/res/ResourceManager.bf @@ -4,7 +4,6 @@ using System.Text; using System.Reflection; using Beefy.utils; using Beefy.gfx; -using System.Runtime.InteropServices; namespace Beefy.res { diff --git a/BeefLibs/Beefy2D/src/res/SoundBank.bf b/BeefLibs/Beefy2D/src/res/SoundBank.bf index a545b9a5..2bb7e1bf 100644 --- a/BeefLibs/Beefy2D/src/res/SoundBank.bf +++ b/BeefLibs/Beefy2D/src/res/SoundBank.bf @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Text; -using System.Runtime.InteropServices; using Beefy; namespace Beefy.res diff --git a/BeefLibs/Beefy2D/src/res/SoundEvent.bf b/BeefLibs/Beefy2D/src/res/SoundEvent.bf index 259cc5c9..963becc3 100644 --- a/BeefLibs/Beefy2D/src/res/SoundEvent.bf +++ b/BeefLibs/Beefy2D/src/res/SoundEvent.bf @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Text; -using System.Runtime.InteropServices; using Beefy; namespace Beefy.res diff --git a/BeefLibs/Beefy2D/src/res/SoundParameter.bf b/BeefLibs/Beefy2D/src/res/SoundParameter.bf index cc87b457..aa2c8990 100644 --- a/BeefLibs/Beefy2D/src/res/SoundParameter.bf +++ b/BeefLibs/Beefy2D/src/res/SoundParameter.bf @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Text; -using System.Runtime.InteropServices; using Beefy; namespace Beefy.res diff --git a/BeefLibs/Beefy2D/src/sys/SysMenu.bf b/BeefLibs/Beefy2D/src/sys/SysMenu.bf index a2a9b2b5..495d50a6 100644 --- a/BeefLibs/Beefy2D/src/sys/SysMenu.bf +++ b/BeefLibs/Beefy2D/src/sys/SysMenu.bf @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Text; using Beefy.widgets; using Beefy; -using System.Runtime.InteropServices; namespace Beefy.sys { diff --git a/BeefLibs/Beefy2D/src/theme/dark/DarkTooltip.bf b/BeefLibs/Beefy2D/src/theme/dark/DarkTooltip.bf index d2600cbd..ed609cd9 100644 --- a/BeefLibs/Beefy2D/src/theme/dark/DarkTooltip.bf +++ b/BeefLibs/Beefy2D/src/theme/dark/DarkTooltip.bf @@ -82,6 +82,7 @@ namespace Beefy.theme.dark public ~this() { + Debug.Assert(mHasClosed); Detach(); } @@ -187,11 +188,6 @@ namespace Beefy.theme.dark if (mWidgetWindow != null) { - WidgetWindow.sOnMouseDown.Remove(scope => HandleMouseDown, true); - WidgetWindow.sOnMouseWheel.Remove(scope => HandleMouseWheel, true); - WidgetWindow.sOnMenuItemSelected.Remove(scope => HandleSysMenuItemSelected, true); - WidgetWindow.sOnKeyDown.Remove(scope => HandleKeyDown, true); - mWidgetWindow.Close(); } mCloseEvent(); @@ -249,6 +245,18 @@ namespace Beefy.theme.dark Close(); } + + protected override void RemovedFromWindow() + { + base.RemovedFromWindow(); + + Debug.Assert(mHasClosed); + + WidgetWindow.sOnMouseDown.Remove(scope => HandleMouseDown, true); + WidgetWindow.sOnMouseWheel.Remove(scope => HandleMouseWheel, true); + WidgetWindow.sOnMenuItemSelected.Remove(scope => HandleSysMenuItemSelected, true); + WidgetWindow.sOnKeyDown.Remove(scope => HandleKeyDown, true); + } } static class DarkTooltipManager diff --git a/BeefLibs/Beefy2D/src/utils/BeefPerf.bf b/BeefLibs/Beefy2D/src/utils/BeefPerf.bf index d162c63c..dba781ea 100644 --- a/BeefLibs/Beefy2D/src/utils/BeefPerf.bf +++ b/BeefLibs/Beefy2D/src/utils/BeefPerf.bf @@ -1,5 +1,4 @@ using System; -using System.Runtime.InteropServices; namespace Beefy.utils { diff --git a/BeefLibs/Beefy2D/src/utils/PerfTimer.bf b/BeefLibs/Beefy2D/src/utils/PerfTimer.bf index 0bc7d415..7328c757 100644 --- a/BeefLibs/Beefy2D/src/utils/PerfTimer.bf +++ b/BeefLibs/Beefy2D/src/utils/PerfTimer.bf @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Runtime.InteropServices; using System.Text; namespace Beefy.utils diff --git a/BeefLibs/Beefy2D/src/widgets/ButtonWidget.bf b/BeefLibs/Beefy2D/src/widgets/ButtonWidget.bf index ef328c64..6dbac60e 100644 --- a/BeefLibs/Beefy2D/src/widgets/ButtonWidget.bf +++ b/BeefLibs/Beefy2D/src/widgets/ButtonWidget.bf @@ -2,7 +2,6 @@ using System; using System.Collections.Generic; using System.Text; using Beefy.gfx; -using System.Runtime.InteropServices; namespace Beefy.widgets { diff --git a/BeefLibs/Beefy2D/src/widgets/EditWidget.bf b/BeefLibs/Beefy2D/src/widgets/EditWidget.bf index 10879703..7f285bfe 100644 --- a/BeefLibs/Beefy2D/src/widgets/EditWidget.bf +++ b/BeefLibs/Beefy2D/src/widgets/EditWidget.bf @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Runtime.InteropServices; using System.Diagnostics; using System.Text; using System.Threading; diff --git a/BeefLibs/Beefy2D/src/widgets/ListView.bf b/BeefLibs/Beefy2D/src/widgets/ListView.bf index a7101b49..7bbb6add 100644 --- a/BeefLibs/Beefy2D/src/widgets/ListView.bf +++ b/BeefLibs/Beefy2D/src/widgets/ListView.bf @@ -852,7 +852,7 @@ namespace Beefy.widgets newSelection = GetRoot(); while (newSelection.mChildAreaHeight > 0) { - newSelection = GetRoot().mChildItems[GetRoot().mChildItems.Count - 1]; + newSelection = newSelection.mChildItems[newSelection.mChildItems.Count - 1]; } case KeyCode.PageUp: int32 numIterations = (int32)(mScrollContentContainer.mHeight / selectedItem.mSelfHeight); diff --git a/BeefLibs/corlib/src/System/Attribute.bf b/BeefLibs/corlib/src/System/Attribute.bf index d5d3ee03..d80e506c 100644 --- a/BeefLibs/corlib/src/System/Attribute.bf +++ b/BeefLibs/corlib/src/System/Attribute.bf @@ -277,33 +277,6 @@ namespace System public bool Profile; } - namespace Runtime.InteropServices - { - public enum CallingConvention - { - Winapi = 1, - Cdecl = 2, - StdCall = 3, - ThisCall = 4, - FastCall = 5, - - Default = Cdecl - } - - [AttributeUsage(AttributeTargets.Method /*3*/)] - public struct DllImportAttribute : Attribute - { - public this(String dllName) - { - CallingConvention = .Default; - CLink = false; - } - - public CallingConvention CallingConvention; - public bool CLink; - } - } - public struct ImportAttribute : Attribute { public this(String libName) @@ -311,6 +284,11 @@ namespace System } } + public struct ExportAttribute : Attribute + { + + } + [AttributeUsage(AttributeTargets.StaticField | AttributeTargets.Field, .NotInherited)] public struct ThreadStaticAttribute : Attribute { diff --git a/BeefLibs/corlib/src/System/Collections/Generic/Dictionary.bf b/BeefLibs/corlib/src/System/Collections/Generic/Dictionary.bf index 8474e523..e34e1039 100644 --- a/BeefLibs/corlib/src/System/Collections/Generic/Dictionary.bf +++ b/BeefLibs/corlib/src/System/Collections/Generic/Dictionary.bf @@ -261,7 +261,7 @@ namespace System.Collections.Generic return -1; } - private int FindEntryAlt(TOther key) where TOther : IOpEquals, IHashable + private int FindEntryWith(TAltKey key) where TAltKey : IOpEquals, IHashable { if (mBuckets != null) { @@ -545,6 +545,20 @@ namespace System.Collections.Generic return false; } + public bool TryGetWith(TAltKey key, out TKey matchKey, out TValue value) where TAltKey : IOpEquals, IHashable + { + int_cosize i = (int_cosize)FindEntryWith(key); + if (i >= 0) + { + matchKey = mEntries[i].mKey; + value = mEntries[i].mValue; + return true; + } + matchKey = default(TKey); + value = default(TValue); + return false; + } + public TValue GetValueOrDefault(TKey key) { int_cosize i = (int_cosize)FindEntry(key); diff --git a/BeefLibs/corlib/src/System/Collections/IEnumerator.bf b/BeefLibs/corlib/src/System/Collections/IEnumerator.bf index 79b192ed..89855c8a 100644 --- a/BeefLibs/corlib/src/System/Collections/IEnumerator.bf +++ b/BeefLibs/corlib/src/System/Collections/IEnumerator.bf @@ -1,5 +1,4 @@ using System; -using System.Runtime.InteropServices; namespace System.Collections.Generic { diff --git a/BeefLibs/corlib/src/System/DateTimeOffset.bf b/BeefLibs/corlib/src/System/DateTimeOffset.bf index d02c00c3..3d3ad8d7 100644 --- a/BeefLibs/corlib/src/System/DateTimeOffset.bf +++ b/BeefLibs/corlib/src/System/DateTimeOffset.bf @@ -8,7 +8,6 @@ namespace System { using System; using System.Threading; using System.Globalization; - using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using System.Diagnostics.Contracts; diff --git a/BeefLibs/corlib/src/System/Double.bf b/BeefLibs/corlib/src/System/Double.bf index 5293e110..31f524e4 100644 --- a/BeefLibs/corlib/src/System/Double.bf +++ b/BeefLibs/corlib/src/System/Double.bf @@ -6,7 +6,6 @@ namespace System { using System; using System.Globalization; - using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using System.Diagnostics.Contracts; using System.Diagnostics; diff --git a/BeefLibs/corlib/src/System/Globalization/CalendarData.bf b/BeefLibs/corlib/src/System/Globalization/CalendarData.bf index c801ed7c..9a56c4dc 100644 --- a/BeefLibs/corlib/src/System/Globalization/CalendarData.bf +++ b/BeefLibs/corlib/src/System/Globalization/CalendarData.bf @@ -6,7 +6,6 @@ namespace System.Globalization { using System; - using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using System.Diagnostics.Contracts; using System.Diagnostics; diff --git a/BeefLibs/corlib/src/System/Globalization/DateTimeFormat.bf b/BeefLibs/corlib/src/System/Globalization/DateTimeFormat.bf index 996c274c..91f3d260 100644 --- a/BeefLibs/corlib/src/System/Globalization/DateTimeFormat.bf +++ b/BeefLibs/corlib/src/System/Globalization/DateTimeFormat.bf @@ -8,7 +8,6 @@ namespace System { using System.Globalization; using System.Collections.Generic; using System.Runtime.CompilerServices; - using System.Runtime.InteropServices; using System.Security; using System.Diagnostics.Contracts; diff --git a/BeefLibs/corlib/src/System/IO/FileOptions.bf b/BeefLibs/corlib/src/System/IO/FileOptions.bf index 683c6f72..bfd49f19 100644 --- a/BeefLibs/corlib/src/System/IO/FileOptions.bf +++ b/BeefLibs/corlib/src/System/IO/FileOptions.bf @@ -3,7 +3,6 @@ // The original source was submitted to https://github.com/Microsoft/referencesource using System; -using System.Runtime.InteropServices; namespace System.IO { diff --git a/BeefLibs/corlib/src/System/Native.bf b/BeefLibs/corlib/src/System/Native.bf index 05604878..6ec4e098 100644 --- a/BeefLibs/corlib/src/System/Native.bf +++ b/BeefLibs/corlib/src/System/Native.bf @@ -1,5 +1,4 @@ using System.IO; -using System.Runtime.InteropServices; namespace System { diff --git a/BeefLibs/corlib/src/System/Nullable.bf b/BeefLibs/corlib/src/System/Nullable.bf index 868c0f30..47afc62f 100644 --- a/BeefLibs/corlib/src/System/Nullable.bf +++ b/BeefLibs/corlib/src/System/Nullable.bf @@ -1,7 +1,6 @@ using System.Reflection; using System.Collections.Generic; using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; using System.Diagnostics; namespace System diff --git a/BeefLibs/corlib/src/System/String.bf b/BeefLibs/corlib/src/System/String.bf index 3382d76e..a5ec0a32 100644 --- a/BeefLibs/corlib/src/System/String.bf +++ b/BeefLibs/corlib/src/System/String.bf @@ -399,11 +399,11 @@ namespace System } } - public int GetHashCode() + static int GetHashCode(char8* ptr, int length) { - int charsLeft = mLength; + int charsLeft = length; int hash = 0; - char8* curPtr = Ptr; + char8* curPtr = ptr; let intSize = sizeof(int); while (charsLeft >= intSize) { @@ -422,6 +422,11 @@ namespace System return hash; } + public int GetHashCode() + { + return GetHashCode(Ptr, mLength); + } + public override void ToString(String strBuffer) { strBuffer.Append(this); @@ -2495,7 +2500,7 @@ namespace System } } - public struct StringView : Span, IFormattable, IPrintable + public struct StringView : Span, IFormattable, IPrintable, IOpEquals, IHashable { public this() { @@ -2579,6 +2584,11 @@ namespace System } } + public int GetHashCode() + { + return String.[Friend]GetHashCode(mPtr, mLength); + } + public override void ToString(String strBuffer) { strBuffer.Append(mPtr, mLength); @@ -2840,11 +2850,13 @@ namespace System return String.UnQuoteString(Ptr, Length, outString); } + [NoDiscard] public StringView Substring(int pos) { return .(this, pos); } + [NoDiscard] public StringView Substring(int pos, int length) { return .(this, pos, length); diff --git a/BeefLibs/corlib/src/System/TimeZoneInfo.bf b/BeefLibs/corlib/src/System/TimeZoneInfo.bf index 3d62c930..87c28d40 100644 --- a/BeefLibs/corlib/src/System/TimeZoneInfo.bf +++ b/BeefLibs/corlib/src/System/TimeZoneInfo.bf @@ -34,7 +34,6 @@ namespace System { using System.Globalization; using System.IO; using System.Runtime.CompilerServices; - using System.Runtime.InteropServices; using System.Security; using System.Text; using System.Threading; diff --git a/BeefLibs/corlib/src/System/Windows.bf b/BeefLibs/corlib/src/System/Windows.bf index 81cba9b8..825163a5 100644 --- a/BeefLibs/corlib/src/System/Windows.bf +++ b/BeefLibs/corlib/src/System/Windows.bf @@ -1,7 +1,6 @@ #if BF_PLATFORM_WINDOWS using System.IO; -using System.Runtime.InteropServices; using System.Collections.Generic; using System.Text; @@ -9,7 +8,6 @@ namespace System { class Windows { - public struct COM_IUnknown { public enum ClsContext : uint32 @@ -1245,6 +1243,9 @@ namespace System public static extern IntBool GetFileMUIPath(uint32 dwFlags, char16* pcwszFilePath, char16* pwszLanguage, uint32* pcchLanguage, char16* pwszFileMUIPath, uint32* pcchFileMUIPath, uint64* pululEnumerator); + [CLink, StdCall] + public static extern HInstance LoadLibraryW(char16* libFileName); + [CLink, StdCall] public static extern HInstance LoadLibraryExW(char16* libFileName, HModule hFile, uint32 dwFlags); diff --git a/BeefRT/BeefDbg/BeefDbg.vcxproj b/BeefRT/BeefDbg/BeefDbg.vcxproj index fef23340..ed515f77 100644 --- a/BeefRT/BeefDbg/BeefDbg.vcxproj +++ b/BeefRT/BeefDbg/BeefDbg.vcxproj @@ -1,6 +1,22 @@  + + Debug Static CStatic + Win32 + + + Debug Static CStatic + x64 + + + Debug Static + Win32 + + + Debug Static + x64 + Debug Win32 @@ -9,6 +25,22 @@ Debug x64 + + Release Static CStatic + Win32 + + + Release Static CStatic + x64 + + + Release Static + Win32 + + + Release Static + x64 + Release Win32 @@ -31,12 +63,36 @@ v141 Unicode + + DynamicLibrary + true + v141 + Unicode + + + DynamicLibrary + true + v141 + Unicode + DynamicLibrary true v141 Unicode + + StaticLibrary + true + v141 + Unicode + + + StaticLibrary + true + v141 + Unicode + DynamicLibrary false @@ -44,6 +100,20 @@ true Unicode + + StaticLibrary + false + v141 + true + Unicode + + + StaticLibrary + false + v141 + true + Unicode + DynamicLibrary false @@ -51,6 +121,20 @@ true Unicode + + StaticLibrary + false + v141 + true + Unicode + + + StaticLibrary + false + v141 + true + Unicode + @@ -66,55 +150,119 @@ true + true + true true + true + true true + true + true true + true + true true + true + true true + true + true true + true + true true + true + true true + true + true true + true + true true + true + true true + true + true true + true + true true + true + true true + true + true true + true + true true + true + true true + true + true true + true + true true + true + true true + true + true true + true + true true + true + true true + true + true true + true + true true + true + true true + true + true true + true + true true + true + true true + true + true true + true + true true + true + true @@ -124,9 +272,17 @@ true + true + true true + true + true true + true + true true + true + true @@ -135,12 +291,28 @@ + + + + + + + + + + + + + + + + @@ -160,9 +332,17 @@ true + true + true true + true + true true + true + true true + true + true @@ -240,45 +420,152 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Beef$(BeefFilesVersion)Dbg64_d $(SolutionDir)\ide\dist\ + + Beef$(BeefFilesVersion)Dbg64_ssd + $(SolutionDir)\ide\dist\ + + + Beef$(BeefFilesVersion)Dbg64_sd + $(SolutionDir)\ide\dist\ + Beef$(BeefFilesVersion)Dbg64 $(SolutionDir)\ide\dist\ false + + Beef$(BeefFilesVersion)Dbg64_ss + $(SolutionDir)\ide\dist\ + false + + + Beef$(BeefFilesVersion)Dbg64_s + $(SolutionDir)\ide\dist\ + false + $(SolutionDir)\ide\dist\ Beef$(BeefFilesVersion)Dbg32_d + + $(SolutionDir)\ide\dist\ + Beef$(BeefFilesVersion)Dbg32_ssd + + + $(SolutionDir)\ide\dist\ + Beef$(BeefFilesVersion)Dbg32_sd + $(SolutionDir)\ide\dist\ Beef$(BeefFilesVersion)Dbg32 + + $(SolutionDir)\ide\dist\ + Beef$(BeefFilesVersion)Dbg32_ss + + + $(SolutionDir)\ide\dist\ + Beef$(BeefFilesVersion)Dbg32_s + Level3 Disabled - BP_DISABLED;BF_NO_BFAPP;BFRT_DYNAMIC;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + BFRTDBG;BP_DISABLED;BF_NO_BFAPP;BFRT_DYNAMIC;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) .;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows MultiThreadedDebug + ProgramDatabase + + + Windows + DebugFull + 0x00DB0000 + false + + + + + + + + + Level3 + Disabled + BFRTDBG;BP_DISABLED;BF_NO_BFAPP;BFRT_DYNAMIC;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + .;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows + MultiThreadedDebug + ProgramDatabase + + + Windows + DebugFull + 0x00DB0000 + false + + + + + + + + + Level3 + Disabled + BFRTDBG;BP_DISABLED;BF_NO_BFAPP;BFRT_DYNAMIC;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + .;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows + MultiThreadedDebug + ProgramDatabase Windows @@ -295,7 +582,7 @@ Level3 Disabled - BP_DISABLED;BF_NO_BFAPP;BFRT_DYNAMIC;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + BFRTDBG;BP_DISABLED;BF_NO_BFAPP;BFRT_DYNAMIC;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) .;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows @@ -313,6 +600,54 @@ + + + + + Level3 + Disabled + BFRTDBG;BP_DISABLED;BF_NO_BFAPP;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + .;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows + + + false + MultiThreadedDebug + + + Windows + DebugFull + $(SolutionDir)\ide\dist\$(TargetName).dll + $(SolutionDir)\ide\dist\$(TargetName).lib + false + true + + + + + + + + + Level3 + Disabled + BFRTDBG;BP_DISABLED;BF_NO_BFAPP;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + .;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows + + + false + MultiThreadedDebugDLL + + + Windows + DebugFull + $(SolutionDir)\ide\dist\$(TargetName).dll + $(SolutionDir)\ide\dist\$(TargetName).lib + false + true + + + + Level3 @@ -321,9 +656,50 @@ MaxSpeed true true - BP_DISABLED;BF_NO_BFAPP;BFRT_DYNAMIC;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + BFRTDBG;BP_DISABLED;BF_NO_BFAPP;BFRT_DYNAMIC;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) .;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows MultiThreaded + false + + + Windows + DebugFull + true + true + + + + + Level3 + + + MaxSpeed + true + true + BFRTDBG;BP_DISABLED;BF_NO_BFAPP;BFRT_DYNAMIC;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + .;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows + MultiThreaded + false + + + Windows + DebugFull + true + true + + + + + Level3 + + + MaxSpeed + true + true + BFRTDBG;BP_DISABLED;BF_NO_BFAPP;BFRT_DYNAMIC;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + .;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows + MultiThreadedDLL + false Windows @@ -340,7 +716,7 @@ MaxSpeed true true - BP_DISABLED;BF_NO_BFAPP;BFRT_DYNAMIC;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + BFRTDBG;BP_DISABLED;BF_NO_BFAPP;BFRT_DYNAMIC;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) .;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows false MultiThreaded @@ -354,6 +730,50 @@ $(SolutionDir)\ide\dist\$(TargetName).lib + + + Level3 + + + MaxSpeed + true + true + BFRTDBG;BP_DISABLED;BF_NO_BFAPP;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + .;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows + false + MultiThreaded + + + Windows + DebugFull + true + true + $(SolutionDir)\ide\dist\$(TargetName).dll + $(SolutionDir)\ide\dist\$(TargetName).lib + + + + + Level3 + + + MaxSpeed + true + true + BFRTDBG;BP_DISABLED;BF_NO_BFAPP;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + .;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows + false + MultiThreadedDLL + + + Windows + DebugFull + true + true + $(SolutionDir)\ide\dist\$(TargetName).dll + $(SolutionDir)\ide\dist\$(TargetName).lib + + diff --git a/BeefRT/BeefRT.vcxproj b/BeefRT/BeefRT.vcxproj index 79beb101..ae055d27 100644 --- a/BeefRT/BeefRT.vcxproj +++ b/BeefRT/BeefRT.vcxproj @@ -478,6 +478,7 @@ MultiThreadedDebugDLL false false + ProgramDatabase Windows @@ -497,6 +498,7 @@ MultiThreadedDebugDLL false false + ProgramDatabase Windows @@ -516,6 +518,7 @@ MultiThreadedDebug false false + ProgramDatabase Windows @@ -534,7 +537,7 @@ false - MultiThreadedDebugDLL + MultiThreadedDebug stdcpp17 false diff --git a/BeefRT/dbg/DbgInternal.cpp b/BeefRT/dbg/DbgInternal.cpp index f243d392..1b25d4c9 100644 --- a/BeefRT/dbg/DbgInternal.cpp +++ b/BeefRT/dbg/DbgInternal.cpp @@ -2,23 +2,15 @@ #define HEAPHOOK #include - -//#include #include #include #include -//#include //#define OBJECT_GUARD_END_SIZE 8 #define OBJECT_GUARD_END_SIZE 0 //#define BF_USE_STOMP_ALLOC 1 -//extern "C" -//{ -//#include "gperftools/stacktrace.h" -//} - #ifdef _MSC_VER #include #pragma intrinsic(_ReturnAddress) @@ -36,8 +28,8 @@ USING_NS_BF; #ifdef BF_PLATFORM_WINDOWS -bf::System::Runtime::BfRtCallbacks gBfRtCallbacks; -BfRtFlags gBfRtFlags = (BfRtFlags)0; +bf::System::Runtime::BfRtCallbacks gBfRtDbgCallbacks; +BfRtFlags gBfRtDbgFlags = (BfRtFlags)0; #endif namespace bf @@ -47,8 +39,6 @@ namespace bf class Object; class Exception; - //System::Threading::Thread* gMainThread; - class Internal { public: @@ -169,7 +159,7 @@ Beefy::StringT<0> gDbgErrorString; extern DbgRawAllocData sEmptyAllocData; extern DbgRawAllocData sObjectAllocData; -#define SETUP_ERROR(str, skip) gDbgErrorString = str; gBfRtCallbacks.DebugMessageData_SetupError(str, skip) +#define SETUP_ERROR(str, skip) gDbgErrorString = str; gBfRtDbgCallbacks.DebugMessageData_SetupError(str, skip) #ifdef BF_PLATFORM_WINDOWS #define BF_CAPTURE_STACK(skipCount, outFrames, wantCount) (int)RtlCaptureStackBackTrace(skipCount, wantCount, (void**)outFrames, NULL) @@ -198,10 +188,15 @@ void bf::System::Runtime::Dbg_Init(int version, int flags, BfRtCallbacks* callba BfpSystem_FatalError(StrFormat("BeefDbg build version '%d' does not match requested version '%d'", BFRT_VERSION, version).c_str(), "BEEF FATAL ERROR"); } - gBfRtCallbacks = *callbacks; - gBfRtFlags = (BfRtFlags)flags; + if (gBfRtDbgCallbacks.Alloc != NULL) + { + BfpSystem_FatalError(StrFormat("BeefDbg already initialized. Multiple executable modules in the same process cannot dynamically link to the Beef debug runtime.").c_str(), "BEEF FATAL ERROR"); + } + + gBfRtDbgCallbacks = *callbacks; + gBfRtDbgFlags = (BfRtFlags)flags; #ifdef BF_GC_SUPPORTED - gGCDbgData.mDbgFlags = gBfRtFlags; + gGCDbgData.mDbgFlags = gBfRtDbgFlags; #endif } @@ -215,8 +210,8 @@ void* bf::System::Runtime::Dbg_GetCrashInfoFunc() void Internal::Dbg_MarkObjectDeleted(bf::System::Object* object) { - BF_ASSERT((gBfRtFlags & BfRtFlags_ObjectHasDebugFlags) != 0); - if ((gBfRtFlags & BfRtFlags_ObjectHasDebugFlags) != 0) + BF_ASSERT((gBfRtDbgFlags & BfRtFlags_ObjectHasDebugFlags) != 0); + if ((gBfRtDbgFlags & BfRtFlags_ObjectHasDebugFlags) != 0) object->mObjectFlags = (BfObjectFlags)((object->mObjectFlags & ~BfObjectFlag_StackAlloc) | BfObjectFlag_Deleted); #ifdef BF_GC_SUPPORTED gBFGC.ObjectDeleteRequested(object); @@ -293,10 +288,10 @@ intptr Internal::Dbg_PrepareStackTrace(intptr baseAllocSize, intptr maxStackTrac bf::System::Object* Internal::Dbg_ObjectAlloc(bf::System::Reflection::TypeInstance* typeInst, intptr size) { - BF_ASSERT((gBfRtFlags & BfRtFlags_ObjectHasDebugFlags) != 0); + BF_ASSERT((gBfRtDbgFlags & BfRtFlags_ObjectHasDebugFlags) != 0); Object* result; int allocSize = BF_ALIGN(size, typeInst->mInstAlign); - uint8* allocBytes = (uint8*)BfObjectAllocate(allocSize, typeInst->GetType()); + uint8* allocBytes = (uint8*)BfObjectAllocate(allocSize, typeInst->_GetType()); // int dataOffset = (int)(sizeof(intptr) * 2); // memset(allocBytes + dataOffset, 0, size - dataOffset); result = (bf::System::Object*)allocBytes; @@ -322,7 +317,7 @@ bf::System::Object* Internal::Dbg_ObjectAlloc(bf::System::ClassVData* classVData intptr allocSize = size; bool largeAllocInfo = false; - if ((gBfRtFlags & BfRtFlags_ObjectHasDebugFlags) != 0) + if ((gBfRtDbgFlags & BfRtFlags_ObjectHasDebugFlags) != 0) { if (maxStackTraceDepth > 1) { @@ -343,7 +338,7 @@ bf::System::Object* Internal::Dbg_ObjectAlloc(bf::System::ClassVData* classVData #endif bf::System::Object* result; - if ((gBfRtFlags & BfRtFlags_LeakCheck) != 0) + if ((gBfRtDbgFlags & BfRtFlags_LeakCheck) != 0) { allocSize = BF_ALIGN(allocSize, align); uint8* allocBytes = (uint8*)BfObjectAllocate(allocSize, classVData->mType); @@ -362,21 +357,21 @@ bf::System::Object* Internal::Dbg_ObjectAlloc(bf::System::ClassVData* classVData sAllocSizes[classVData->mType->mTypeId] += size; result = (bf::System::Object*)(allocPtr + 16); #else - if ((gBfRtFlags & BfRtFlags_DebugAlloc) != 0) + if ((gBfRtDbgFlags & BfRtFlags_DebugAlloc) != 0) { uint8* allocBytes = (uint8*)BfRawAllocate(allocSize, &sObjectAllocData, NULL, 0); result = (bf::System::Object*)allocBytes; } else { - uint8* allocBytes = (uint8*)gBfRtCallbacks.Alloc(allocSize); + uint8* allocBytes = (uint8*)gBfRtDbgCallbacks.Alloc(allocSize); result = (bf::System::Object*)allocBytes; } #endif } #ifndef BFRT_NODBGFLAGS - if ((gBfRtFlags & BfRtFlags_ObjectHasDebugFlags) != 0) + if ((gBfRtDbgFlags & BfRtFlags_ObjectHasDebugFlags) != 0) { // The order is very important here- // Once we set mDbgAllocInfo, the memory will be recognized by the GC as being a valid object. @@ -429,7 +424,7 @@ bf::System::Object* Internal::Dbg_ObjectAlloc(bf::System::ClassVData* classVData void Internal::Dbg_ObjectStackInit(bf::System::Object* result, bf::System::ClassVData* classVData) { - BF_ASSERT((gBfRtFlags & BfRtFlags_ObjectHasDebugFlags) != 0); + BF_ASSERT((gBfRtDbgFlags & BfRtFlags_ObjectHasDebugFlags) != 0); result->mClassVData = (intptr)classVData | (intptr)BfObjectFlag_StackAlloc; #ifndef BFRT_NODBGFLAGS @@ -468,7 +463,7 @@ static void SetupDbgAllocInfo(bf::System::Object* result, intptr origSize) void Internal::Dbg_ObjectCreated(bf::System::Object* result, intptr size, bf::System::ClassVData* classVData) { - BF_ASSERT((gBfRtFlags & BfRtFlags_ObjectHasDebugFlags) != 0); + BF_ASSERT((gBfRtDbgFlags & BfRtFlags_ObjectHasDebugFlags) != 0); #ifndef BFRT_NODBGFLAGS BF_ASSERT_REL((result->mClassVData & ~(BfObjectFlag_Allocated | BfObjectFlag_Mark3)) == (intptr)classVData); result->mDbgAllocInfo = (intptr)BF_RETURN_ADDRESS; @@ -477,7 +472,7 @@ void Internal::Dbg_ObjectCreated(bf::System::Object* result, intptr size, bf::Sy void Internal::Dbg_ObjectCreatedEx(bf::System::Object* result, intptr origSize, bf::System::ClassVData* classVData) { - BF_ASSERT((gBfRtFlags & BfRtFlags_ObjectHasDebugFlags) != 0); + BF_ASSERT((gBfRtDbgFlags & BfRtFlags_ObjectHasDebugFlags) != 0); #ifndef BFRT_NODBGFLAGS BF_ASSERT_REL((result->mClassVData & ~(BfObjectFlag_Allocated | BfObjectFlag_Mark3)) == (intptr)classVData); SetupDbgAllocInfo(result, origSize); @@ -486,7 +481,7 @@ void Internal::Dbg_ObjectCreatedEx(bf::System::Object* result, intptr origSize, void Internal::Dbg_ObjectAllocated(bf::System::Object* result, intptr size, bf::System::ClassVData* classVData) { - BF_ASSERT((gBfRtFlags & BfRtFlags_ObjectHasDebugFlags) != 0); + BF_ASSERT((gBfRtDbgFlags & BfRtFlags_ObjectHasDebugFlags) != 0); result->mClassVData = (intptr)classVData; #ifndef BFRT_NODBGFLAGS result->mDbgAllocInfo = (intptr)BF_RETURN_ADDRESS; @@ -495,14 +490,14 @@ void Internal::Dbg_ObjectAllocated(bf::System::Object* result, intptr size, bf:: void Internal::Dbg_ObjectAllocatedEx(bf::System::Object* result, intptr origSize, bf::System::ClassVData* classVData) { - BF_ASSERT((gBfRtFlags & BfRtFlags_ObjectHasDebugFlags) != 0); + BF_ASSERT((gBfRtDbgFlags & BfRtFlags_ObjectHasDebugFlags) != 0); result->mClassVData = (intptr)classVData; SetupDbgAllocInfo(result, origSize); } void Internal::Dbg_ObjectPreDelete(bf::System::Object* object) { - BF_ASSERT((gBfRtFlags & BfRtFlags_ObjectHasDebugFlags) != 0); + BF_ASSERT((gBfRtDbgFlags & BfRtFlags_ObjectHasDebugFlags) != 0); #ifndef BFRT_NODBGFLAGS const char* errorPtr = NULL; @@ -539,7 +534,7 @@ void Internal::Dbg_ObjectPreDelete(bf::System::Object* object) errorStr += StrFormat(" (%s)0x%@\n", typeName.c_str(), object); SETUP_ERROR(errorStr.c_str(), 2); BF_DEBUG_BREAK(); - gBfRtCallbacks.DebugMessageData_Fatal(); + gBfRtDbgCallbacks.DebugMessageData_Fatal(); return; } #endif @@ -547,7 +542,7 @@ void Internal::Dbg_ObjectPreDelete(bf::System::Object* object) void Internal::Dbg_ObjectPreCustomDelete(bf::System::Object* object) { - BF_ASSERT((gBfRtFlags & BfRtFlags_ObjectHasDebugFlags) != 0); + BF_ASSERT((gBfRtDbgFlags & BfRtFlags_ObjectHasDebugFlags) != 0); const char* errorPtr = NULL; @@ -566,7 +561,7 @@ void Internal::Dbg_ObjectPreCustomDelete(bf::System::Object* object) errorStr += StrFormat(" (%s)0x%@\n", typeName.c_str(), object); SETUP_ERROR(errorStr.c_str(), 2); BF_DEBUG_BREAK(); - gBfRtCallbacks.DebugMessageData_Fatal(); + gBfRtDbgCallbacks.DebugMessageData_Fatal(); return; } } diff --git a/BeefRT/dbg/gc.cpp b/BeefRT/dbg/gc.cpp index 4ac5d451..68cc6a2b 100644 --- a/BeefRT/dbg/gc.cpp +++ b/BeefRT/dbg/gc.cpp @@ -34,7 +34,7 @@ #include "gc.h" #ifdef BF_GC_SUPPORTED - + #include #include "BeefySysLib/Common.h" #include "BeefySysLib/BFApp.h" @@ -180,12 +180,12 @@ void BFGC::MarkMembers(bf::System::Object* obj) if (((obj->mObjectFlags & BF_OBJECTFLAG_DELETED) != 0) && (!mMarkingDeleted)) { mMarkingDeleted = true; - gBfRtCallbacks.Object_GCMarkMembers(obj); + gBfRtDbgCallbacks.Object_GCMarkMembers(obj); mMarkingDeleted = false; } else { - gBfRtCallbacks.Object_GCMarkMembers(obj); + gBfRtDbgCallbacks.Object_GCMarkMembers(obj); } } @@ -636,7 +636,7 @@ BFGC::BFGC() mGCThread = NULL; - gGCDbgData.mDbgFlags = gBfRtFlags; + gGCDbgData.mDbgFlags = gBfRtDbgFlags; ThreadCache::InitTSD(); if (UNLIKELY(Static::pageheap() == NULL)) ThreadCache::InitModule(); gGCDbgData.mObjRootPtr = Static::pageheap()->pagemap_.root_; @@ -767,7 +767,7 @@ void BFCheckObjectSize(bf::System::Object* obj, int size) void BFGC::ConservativeScan(void* startAddr, int length) { - if ((gBfRtFlags & BfRtFlags_ObjectHasDebugFlags) == 0) + if ((gBfRtDbgFlags & BfRtFlags_ObjectHasDebugFlags) == 0) return; BFLOG2(GCLog::EVENT_CONSERVATIVE_SCAN, (intptr)startAddr, (intptr)startAddr + length); @@ -877,7 +877,7 @@ bool BFGC::HandlePendingGCData() void BFGC::SweepSpan(tcmalloc_obj::Span* span, int expectedStartPage) { - if ((gBfRtFlags & BfRtFlags_ObjectHasDebugFlags) == 0) + if ((gBfRtDbgFlags & BfRtFlags_ObjectHasDebugFlags) == 0) return; if (span->location != tcmalloc_obj::Span::IN_USE) @@ -980,7 +980,7 @@ void BFGC::SweepSpan(tcmalloc_obj::Span* span, int expectedStartPage) mSweepInfo.mLeakObjects.push_back(obj); } - BFLOG2(GCLog::EVENT_LEAK, (intptr)obj, (intptr)obj->GetType()); + BFLOG2(GCLog::EVENT_LEAK, (intptr)obj, (intptr)obj->_GetType()); #ifdef BF_GC_LOG_ENABLED gGCLog.Write(); #endif @@ -1160,8 +1160,8 @@ void BFGC::ProcessSweepInfo() //TODO: Testing! //OutputDebugStrF(gDbgErrorString.c_str()); - gBfRtCallbacks.SetErrorString(gDbgErrorString.c_str()); - gBfRtCallbacks.DebugMessageData_SetupError(errorStr.c_str(), 1); + gBfRtDbgCallbacks.SetErrorString(gDbgErrorString.c_str()); + gBfRtDbgCallbacks.DebugMessageData_SetupError(errorStr.c_str(), 1); BF_DEBUG_BREAK(); } @@ -1614,7 +1614,7 @@ void BFGC::FinishCollect() { //OutputDebugStrF("Collected %d objects\n", mFinalizeList.size()); - if ((gBfRtFlags & BfRtFlags_ObjectHasDebugFlags) == 0) + if ((gBfRtDbgFlags & BfRtFlags_ObjectHasDebugFlags) == 0) return; mLastFreeCount = 0; @@ -1711,7 +1711,7 @@ void BFGC::FinishCollect() { // Temporarily remove object flags so GetType() won't fail obj->mObjectFlags = BfObjectFlag_None; - bf::System::Type* type = obj->GetType(); + bf::System::Type* type = obj->_GetType(); //auto pairVal = sizeMap.insert(std::make_pair(type, 0)); //int newSize = pairVal.first->second + objSize; int* sizePtr = NULL; @@ -2046,7 +2046,7 @@ void BFGC::ObjReportHandleSpan(tcmalloc_obj::Span* span, int expectedStartPage, int objectFlags = obj->mObjectFlags; if ((objectFlags & BF_OBJECTFLAG_DELETED) == 0) { - bf::System::Type* type = obj->GetType(); + bf::System::Type* type = obj->_GetType(); //auto pairVal = sizeMap.insert(std::make_pair(type, 0)); //int newSize = pairVal.first->second + elementSize; //pairVal.first->second = newSize; diff --git a/BeefRT/dbg/gc.h b/BeefRT/dbg/gc.h index e18e29ae..cb2d45f9 100644 --- a/BeefRT/dbg/gc.h +++ b/BeefRT/dbg/gc.h @@ -436,15 +436,7 @@ namespace bf { private: BFRT_EXPORT static void Init(); - BFRT_EXPORT static void Run(); - static void MarkAllStaticMembers() - { - gBfRtCallbacks.GC_MarkAllStaticMembers(); - } - static bool CallRootCallbacks() - { - return gBfRtCallbacks.GC_CallRootCallbacks(); - } + BFRT_EXPORT static void Run(); BFRT_EXPORT static void ReportTLSMember(intptr tlsIndex, void* ptr, void* markFunc); BFRT_EXPORT static void StopCollecting(); BFRT_EXPORT static void AddStackMarkableObject(Object* obj); @@ -460,11 +452,11 @@ namespace bf //static void ToLeakString(Object* obj, String* strBuffer); static void DoMarkAllStaticMembers() { - MarkAllStaticMembers(); + BFRTCALLBACKS.GC_MarkAllStaticMembers(); } static bool DoCallRootCallbacks() { - return CallRootCallbacks(); + return BFRTCALLBACKS.GC_CallRootCallbacks(); } BFRT_EXPORT static void SetAutoCollectPeriod(intptr periodMS); BFRT_EXPORT static void SetCollectFreeThreshold(intptr freeBytes); diff --git a/BeefRT/dbg/gc_raw.cpp b/BeefRT/dbg/gc_raw.cpp index 2d933ce0..053d0d8b 100644 --- a/BeefRT/dbg/gc_raw.cpp +++ b/BeefRT/dbg/gc_raw.cpp @@ -1,4 +1,3 @@ - #define _WIN32_WINNT _WIN32_WINNT_WIN8 // This spits out interesting stats periodically to the console @@ -74,7 +73,7 @@ void BFGC::RawInit() void BFGC::RawMarkSpan(tcmalloc_raw::Span* span, int expectedStartPage) { - if ((gBfRtFlags & BfRtFlags_ObjectHasDebugFlags) == 0) + if ((gBfRtDbgFlags & BfRtFlags_ObjectHasDebugFlags) == 0) return; if (span->location != tcmalloc_raw::Span::IN_USE) @@ -278,7 +277,7 @@ void BFGC::RawReportHandleSpan(tcmalloc_raw::Span* span, int expectedStartPage, if (rawAllocData->mType != NULL) { int typeSize; - if ((gBfRtFlags & BfRtFlags_ObjectHasDebugFlags) != 0) + if ((gBfRtDbgFlags & BfRtFlags_ObjectHasDebugFlags) != 0) typeSize = rawAllocData->mType->mSize; else typeSize = ((bf::System::Type_NOFLAGS*)rawAllocData->mType)->mSize; @@ -449,8 +448,8 @@ void BFGC::RawShutdown() BF_ASSERT(mSweepInfo.mLeakCount > 0); - gBfRtCallbacks.SetErrorString(gDbgErrorString.c_str()); - gBfRtCallbacks.DebugMessageData_SetupError(errorStr.c_str(), 0); + gBfRtDbgCallbacks.SetErrorString(gDbgErrorString.c_str()); + gBfRtDbgCallbacks.DebugMessageData_SetupError(errorStr.c_str(), 0); BF_DEBUG_BREAK(); } else diff --git a/BeefRT/rt/BfObjects.h b/BeefRT/rt/BfObjects.h index bb9329eb..3c064327 100644 --- a/BeefRT/rt/BfObjects.h +++ b/BeefRT/rt/BfObjects.h @@ -121,8 +121,16 @@ namespace bf } } -extern bf::System::Runtime::BfRtCallbacks gBfRtCallbacks; -extern BfRtFlags gBfRtFlags; +#ifdef BFRTDBG +#define BFRTCALLBACKS gBfRtDbgCallbacks +#define BFRTFLAGS gBfRtDbgFlags +#else +#define BFRTCALLBACKS gBfRtCallbacks +#define BFRTFLAGS gBfRtFlags +#endif + +extern bf::System::Runtime::BfRtCallbacks BFRTCALLBACKS; +extern BfRtFlags BFRTFLAGS; namespace bf { @@ -155,9 +163,9 @@ namespace bf }; #endif - Type* GetType() + Type* _GetType() { - return gBfRtCallbacks.Object_GetType(this); + return BFRTCALLBACKS.Object_GetType(this); } Type* GetTypeSafe() @@ -275,7 +283,7 @@ namespace bf const char* CStr() { - return gBfRtCallbacks.String_ToCStr(this); + return BFRTCALLBACKS.String_ToCStr(this); } }; } diff --git a/BeefRT/rt/Internal.cpp b/BeefRT/rt/Internal.cpp index f400d142..82ddb297 100644 --- a/BeefRT/rt/Internal.cpp +++ b/BeefRT/rt/Internal.cpp @@ -261,6 +261,11 @@ void bf::System::Runtime::Init(int version, int flags, BfRtCallbacks* callbacks) BfpSystem_Init(BFP_VERSION, sysInitFlags); BfpSystem_AddCrashInfoFunc(GetCrashInfo); + if (gBfRtCallbacks.Alloc != NULL) + { + BfpSystem_FatalError(StrFormat("BeefRT already initialized. Multiple executable modules in the same process cannot dynamically link to the Beef runtime.").c_str(), "BEEF FATAL ERROR"); + } + if (version != BFRT_VERSION) { BfpSystem_FatalError(StrFormat("BeefRT build version '%d' does not match requested version '%d'", BFRT_VERSION, version).c_str(), "BEEF FATAL ERROR"); diff --git a/BeefRT/rt/Object.cpp b/BeefRT/rt/Object.cpp index 05981d2b..f2f3e09d 100644 --- a/BeefRT/rt/Object.cpp +++ b/BeefRT/rt/Object.cpp @@ -4,19 +4,19 @@ USING_NS_BF; Beefy::String bf::System::Object::GetTypeName() { - String* strObj = gBfRtCallbacks.String_Alloc(); - Type* type = GetType(); - gBfRtCallbacks.Type_GetFullName(type, strObj); + String* strObj = BFRTCALLBACKS.String_Alloc(); + Type* type = _GetType(); + BFRTCALLBACKS.Type_GetFullName(type, strObj); Beefy::String str = strObj->CStr(); - gBfRtCallbacks.Object_Delete(strObj); + BFRTCALLBACKS.Object_Delete(strObj); return str; } Beefy::String bf::System::Type::GetFullName() { - String* strObj = gBfRtCallbacks.String_Alloc(); - gBfRtCallbacks.Type_GetFullName(this, strObj); + String* strObj = BFRTCALLBACKS.String_Alloc(); + BFRTCALLBACKS.Type_GetFullName(this, strObj); Beefy::String str = strObj->CStr(); - gBfRtCallbacks.Object_Delete(strObj); + BFRTCALLBACKS.Object_Delete(strObj); return str; } diff --git a/BeefRT/rt/Thread.h b/BeefRT/rt/Thread.h index 5acf3ee1..f7942783 100644 --- a/BeefRT/rt/Thread.h +++ b/BeefRT/rt/Thread.h @@ -70,27 +70,27 @@ namespace bf static Thread* Alloc() { - return gBfRtCallbacks.Thread_Alloc(); + return BFRTCALLBACKS.Thread_Alloc(); } BfInternalThread* GetInternalThread() { - return gBfRtCallbacks.Thread_GetInternalThread(this); + return BFRTCALLBACKS.Thread_GetInternalThread(this); } BfDbgInternalThread* Dbg_GetInternalThread() { - return (BfDbgInternalThread*)gBfRtCallbacks.Thread_GetInternalThread(this); + return (BfDbgInternalThread*)BFRTCALLBACKS.Thread_GetInternalThread(this); } void SetInternalThread(BfInternalThread* internalThread) { - gBfRtCallbacks.Thread_SetInternalThread(this, internalThread); + BFRTCALLBACKS.Thread_SetInternalThread(this, internalThread); } int GetMaxStackSize() { - return gBfRtCallbacks.Thread_GetMaxStackSize(this); + return BFRTCALLBACKS.Thread_GetMaxStackSize(this); } }; } diff --git a/BeefTools/BeefInstall/BeefProj.toml b/BeefTools/BeefInstall/BeefProj.toml deleted file mode 100644 index 538a1118..00000000 --- a/BeefTools/BeefInstall/BeefProj.toml +++ /dev/null @@ -1,11 +0,0 @@ -FileVersion = 1 - -[Project] -Name = "BeefInstall" -StartupObject = "BeefInstall.Program" - -[ProjectFolder] - -[[ProjectFolder.Items]] -Type = "Source" -Path = "../../IDE/src/util/Zip.bf" diff --git a/BeefTools/BeefInstall/BeefSpace.toml b/BeefTools/BeefInstall/BeefSpace.toml deleted file mode 100644 index dd17dd2b..00000000 --- a/BeefTools/BeefInstall/BeefSpace.toml +++ /dev/null @@ -1,6 +0,0 @@ -FileVersion = 1 -Projects = {BeefInstall = {Path = "."}} -Unlocked = ["corlib"] - -[Workspace] -StartupProject = "BeefInstall" diff --git a/BeefTools/BeefInstall/BeefSpace_User.toml b/BeefTools/BeefInstall/BeefSpace_User.toml deleted file mode 100644 index a8ad3555..00000000 --- a/BeefTools/BeefInstall/BeefSpace_User.toml +++ /dev/null @@ -1,136 +0,0 @@ -FileVersion = 1 -LastConfig = "Debug" -LastPlatform = "Win64" -RecentFilesList = ["c:\\Beef\\BeefTools\\BeefInstall\\src\\Program.bf", "c:\\Beef\\IDE\\src\\util\\Zip.bf", "c:\\beef\\BeefLibs\\corlib\\src\\System\\String.bf"] - -[MainWindow] -X = 148 -Y = 85 -Width = 1724 -Height = 1830 - -[MainDockingFrame] -Type = "DockingFrame" -SplitType = 2 - -[[MainDockingFrame.DockedWidgets]] -RequestedWidth = 350.0 -RequestedHeight = 200.0 -SizePriority = 200.0 -Type = "DockingFrame" -SplitType = 1 - -[[MainDockingFrame.DockedWidgets.DockedWidgets]] -RequestedWidth = 200.0 -RequestedHeight = 200.0 -Type = "TabbedView" - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -Active = true -TabLabel = "Workspace" -TabWidth = 115.0 -Type = "ProjectPanel" - -[[MainDockingFrame.DockedWidgets.DockedWidgets]] -IsFillWidget = true -Permanent = true -RequestedWidth = 150.0 -RequestedHeight = 150.0 -SizePriority = 150.0 -DefaultDocumentsTabbedView = true -Type = "TabbedView" - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -TabLabel = "String.bf" -TabWidth = 89.0 -Type = "SourceViewPanel" -FilePath = "c:\\beef\\BeefLibs\\corlib\\src\\System\\String.bf" -CursorPos = 41778 -VertPos = 24600.0 -ProjectName = "corlib" - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -TabLabel = "Zip.bf" -TabWidth = 63.0 -Type = "SourceViewPanel" -FilePath = "c:\\Beef\\IDE\\src\\util\\Zip.bf" -CursorPos = 3000 -VertPos = 540.0 -ProjectName = "BeefInstall" - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -Active = true -TabLabel = "Program.bf" -TabWidth = 96.0 -Type = "SourceViewPanel" -FilePath = "c:\\Beef\\BeefTools\\BeefInstall\\src\\Program.bf" -CursorPos = 1398 -ProjectName = "BeefInstall" - -[[MainDockingFrame.DockedWidgets]] -RequestedWidth = 250.0 -RequestedHeight = 250.0 -Type = "DockingFrame" -SplitType = 1 - -[[MainDockingFrame.DockedWidgets.DockedWidgets]] -RequestedWidth = 250.0 -RequestedHeight = 250.0 -SizePriority = 0.5 -Type = "TabbedView" - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -TabLabel = "Memory" -TabWidth = 99.0 -Type = "MemoryPanel" -AutoResize = "Auto_Mul8" -RequestedWidth = 300.0 - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -TabLabel = "Watch" -TabWidth = 86.0 -Type = "WatchPanel" -Columns = [{Width = 200.0}, {Width = 200.0}, {Width = 200.0}] - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -Active = true -TabLabel = "Auto" -TabWidth = 77.0 -Type = "AutoWatchPanel" -Columns = [{Width = 200.0}, {Width = 200.0}, {Width = 200.0}] - -[[MainDockingFrame.DockedWidgets.DockedWidgets]] -RequestedWidth = 250.0 -RequestedHeight = 250.0 -SizePriority = 0.5 -Type = "TabbedView" - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -TabLabel = "Find Results" -TabWidth = 119.0 -Type = "FindResultsPanel" - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -TabLabel = "Threads" -TabWidth = 97.0 -Type = "ThreadPanel" - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -TabLabel = "Call Stack" -TabWidth = 105.0 -Type = "CallStackPanel" - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -TabLabel = "Immediate" -TabWidth = 111.0 -Type = "ImmediatePanel" - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -Active = true -TabLabel = "Output" -TabWidth = 90.0 -Type = "OutputPanel" - -[DebuggerDisplayTypes.""] -IntDisplayType = "Default" -MmDisplayType = "Default" diff --git a/BeefTools/BeefInstall/Stub/BeefProj.toml b/BeefTools/BeefInstall/Stub/BeefProj.toml new file mode 100644 index 00000000..9f9ece73 --- /dev/null +++ b/BeefTools/BeefInstall/Stub/BeefProj.toml @@ -0,0 +1,25 @@ +FileVersion = 1 + +[Project] +Name = "Stub" +StartupObject = "BIStub.Program" + +[Configs.Debug.Win64] +TargetDirectory = "$(WorkspaceDir)/../dist" +TargetName = "$(ProjectName)_d" +BeefLibType = "Static" + +[Configs.Release.Win64] +TargetDirectory = "$(WorkspaceDir)/../dist" + +[Configs.Paranoid.Win64] +TargetDirectory = "$(WorkspaceDir)/../dist" + +[Configs.Test.Win64] +TargetDirectory = "$(WorkspaceDir)/../dist" + +[ProjectFolder] + +[[ProjectFolder.Items]] +Type = "Source" +Path = "../../../IDE/src/util/Zip.bf" diff --git a/BeefTools/BeefInstall/Stub/BeefSpace.toml b/BeefTools/BeefInstall/Stub/BeefSpace.toml new file mode 100644 index 00000000..20dde47b --- /dev/null +++ b/BeefTools/BeefInstall/Stub/BeefSpace.toml @@ -0,0 +1,11 @@ +FileVersion = 1 +Projects = {Stub = {Path = "."}} +Unlocked = ["corlib"] + +[Workspace] +StartupProject = "Stub" + +[Configs.Debug.Win64] +AllocType = "CRT" +EnableObjectDebugFlags = false +IntermediateType = "ObjectAndIRCode" diff --git a/BeefTools/BeefInstall/src/CabFile.bf b/BeefTools/BeefInstall/Stub/src/CabFile.bf similarity index 99% rename from BeefTools/BeefInstall/src/CabFile.bf rename to BeefTools/BeefInstall/Stub/src/CabFile.bf index 51338475..4a8526ca 100644 --- a/BeefTools/BeefInstall/src/CabFile.bf +++ b/BeefTools/BeefInstall/Stub/src/CabFile.bf @@ -1,6 +1,7 @@ using System; using System.IO; -namespace BeefInstall + +namespace System.Windows { class CabFile { diff --git a/BeefTools/BeefInstall/Stub/src/PEFile.bf b/BeefTools/BeefInstall/Stub/src/PEFile.bf new file mode 100644 index 00000000..7a8131ea --- /dev/null +++ b/BeefTools/BeefInstall/Stub/src/PEFile.bf @@ -0,0 +1,236 @@ +using System; + +namespace System.Windows +{ + class PEFile + { + public const uint16 PE_MACHINE_X86 = 0x14c; + public const uint16 PE_MACHINE_X64 = 0x8664; + + [CRepr] + public struct PEHeader + { + public uint16 e_magic; // Magic number + public uint16 e_cblp; // uint8s on last page of file + public uint16 e_cp; // Pages in file + public uint16 e_crlc; // Relocations + public uint16 e_cparhdr; // Size of header in paragraphs + public uint16 e_minalloc; // Minimum extra paragraphs needed + public uint16 e_maxalloc; // Maximum extra paragraphs needed + public uint16 e_ss; // Initial (relative) SS value + public uint16 e_sp; // Initial SP value + public uint16 e_csum; // Checksum + public uint16 e_ip; // Initial IP value + public uint16 e_cs; // Initial (relative) CS value + public uint16 e_lfarlc; // File address of relocation table + public uint16 e_ovno; // Overlay number + public uint16[4] e_res; // Reserved uint16s + public uint16 e_oemid; // OEM identifier (for e_oeminfo) + public uint16 e_oeminfo; // OEM information; e_oemid specific + public uint16[10] e_res2; // Reserved uint16s + public int32 e_lfanew; // File address of new exe header + }; + + + [CRepr] + public struct PEFileHeader + { + public uint16 mMachine; + public uint16 mNumberOfSections; + public uint32 mTimeDateStamp; + public uint32 mPointerToSymbolTable; + public uint32 mNumberOfSymbols; + public uint16 mSizeOfOptionalHeader; + public uint16 mCharacteristics; + }; + + [CRepr] + public struct PEImportObjectHeader + { + public uint16 mSig1; + public uint16 mSig2; + public uint16 mVersion; + public uint16 mMachine; + public uint32 mTimeDateStamp; + public uint32 mDataSize; + public uint16 mHint; + public uint16 mType; + }; + + [CRepr] + public struct PEDataDirectory + { + public uint32 mVirtualAddress; + public uint32 mSize; + }; + + [CRepr] + public struct PEOptionalHeader32 + { + // + // Standard fields. + // + + public uint16 mMagic; + public uint8 mMajorLinkerVersion; + public uint8 mMinorLinkerVersion; + public uint32 mSizeOfCode; + public uint32 mSizeOfInitializedData; + public uint32 mSizeOfUninitializedData; + public uint32 mAddressOfEntryPoint; + public uint32 mBaseOfCode; + public uint32 mBaseOfData; + + // + // NT additional fields. + // + + public uint32 mImageBase; + public uint32 mSectionAlignment; + public uint32 mFileAlignment; + public uint16 mMajorOperatingSystemVersion; + public uint16 mMinorOperatingSystemVersion; + public uint16 mMajorImageVersion; + public uint16 mMinorImageVersion; + public uint16 mMajorSubsystemVersion; + public uint16 mMinorSubsystemVersion; + public uint32 mReserved1; + public uint32 mSizeOfImage; + public uint32 mSizeOfHeaders; + public uint32 mCheckSum; + public uint16 mSubsystem; + public uint16 mDllCharacteristics; + public uint32 mSizeOfStackReserve; + public uint32 mSizeOfStackCommit; + public uint32 mSizeOfHeapReserve; + public uint32 mSizeOfHeapCommit; + public uint32 mLoaderFlags; + public uint32 mNumberOfRvaAndSizes; + public PEDataDirectory[16] mDataDirectory; + }; + + [CRepr] + public struct PEOptionalHeader64 + { + // + // Standard fields. + // + + public uint16 mMagic; + public uint8 mMajorLinkerVersion; + public uint8 mMinorLinkerVersion; + public uint32 mSizeOfCode; + public uint32 mSizeOfInitializedData; + public uint32 mSizeOfUninitializedData; + public uint32 mAddressOfEntryPoint; + public uint32 mBaseOfCode; + + // + // NT additional fields. + // + + public uint64 mImageBase; + public uint32 mSectionAlignment; + public uint32 mFileAlignment; + public uint16 mMajorOperatingSystemVersion; + public uint16 mMinorOperatingSystemVersion; + public uint16 mMajorImageVersion; + public uint16 mMinorImageVersion; + public uint16 mMajorSubsystemVersion; + public uint16 mMinorSubsystemVersion; + public uint32 mReserved1; + public uint32 mSizeOfImage; + public uint32 mSizeOfHeaders; + public uint32 mCheckSum; + public uint16 mSubsystem; + public uint16 mDllCharacteristics; + public uint64 mSizeOfStackReserve; + public uint64 mSizeOfStackCommit; + public uint64 mSizeOfHeapReserve; + public uint64 mSizeOfHeapCommit; + public uint32 mLoaderFlags; + public uint32 mNumberOfRvaAndSizes; + public PEDataDirectory[16] mDataDirectory; + }; + + [CRepr] + struct PE_NTHeaders32 + { + uint32 mSignature; + PEFileHeader mFileHeader; + PEOptionalHeader32 mOptionalHeader; + }; + + [CRepr] + public struct PE_NTHeaders64 + { + public uint32 mSignature; + public PEFileHeader mFileHeader; + public PEOptionalHeader64 mOptionalHeader; + }; + + const int IMAGE_SIZEOF_SHORT_NAME = 8; + + [CRepr] + public struct PESectionHeader + { + public char8[IMAGE_SIZEOF_SHORT_NAME] mName; + public uint32 mVirtualSize; + public uint32 mVirtualAddress; + public uint32 mSizeOfRawData; + public uint32 mPointerToRawData; + public uint32 mPointerToRelocations; + public uint32 mPointerToLineNumbers; + public uint16 mNumberOfRelocations; + public uint16 mNumberOfLineNumbers; + public uint32 mCharacteristics; + }; + + [CRepr] + struct COFFRelocation + { + uint32 mVirtualAddress; + uint32 mSymbolTableIndex; + uint16 mType; + }; + + [CRepr] + struct PE_SymInfo + { + [Union] + public struct Name + { + public char8[8] mName; + public int32[2] mNameOfs; + } + + public Name mName; + + /*union + { + char mName[8]; + int32 mNameOfs[2]; + };*/ + + public int32 mValue; + public uint16 mSectionNum; + public uint16 mType; + public int8 mStorageClass; + public int8 mNumOfAuxSymbols; + }; + + [CRepr] + struct PE_SymInfoAux + { + public uint32 mLength; + public uint16 mNumberOfRelocations; + public uint16 mNumberOfLinenumbers; + public uint32 mCheckSum; + public uint16 mNumber; + public uint8 mSelection; + public char8 mUnused; + public char8 mUnused2; + public char8 mUnused3; + }; + } +} diff --git a/BeefTools/BeefInstall/Stub/src/Program.bf b/BeefTools/BeefInstall/Stub/src/Program.bf new file mode 100644 index 00000000..e5bf82e0 --- /dev/null +++ b/BeefTools/BeefInstall/Stub/src/Program.bf @@ -0,0 +1,179 @@ +using System; +using IDE.Util; +using System.IO; +using System.Windows; + +namespace BIStub +{ + class Program + { + bool mFailed; + + void Fail(StringView str) + { + if (mFailed) + return; + mFailed = true; + Windows.MessageBoxA(default, scope String..AppendF("ERROR: {}", str), "FATAL ERROR", Windows.MB_ICONHAND); + } + + bool HandleCommandLineParam(String key, String value) + { + return false; + } + + void UnhandledCommandLine(String key, String value) + { + + } + + void ParseCommandLine(String[] args) + { + for (var str in args) + { + int eqPos = str.IndexOf('='); + if (eqPos == -1) + { + if (!HandleCommandLineParam(str, null)) + UnhandledCommandLine(str, null); + } + else + { + var cmd = scope String(str, 0, eqPos); + var param = scope String(str, eqPos + 1); + if (!HandleCommandLineParam(cmd, param)) + UnhandledCommandLine(cmd, param); + } + } + } + + Result ExtractTo(ZipFile zipFile, StringView destDir, StringView subStr) + { + String fileName = scope .(); + String destPath = scope .(); + + for (int i < zipFile.GetNumFiles()) + { + ZipFile.Entry entry = scope .(); + if (zipFile.SelectEntry(i, entry) case .Err) + continue; + + fileName.Clear(); + entry.GetFileName(fileName); + + if (!fileName.StartsWith(subStr)) + continue; + + destPath.Clear(); + destPath.Append(destDir); + destPath.Append('/'); + destPath.Append(fileName); + + if (entry.IsDirectory) + { + if (Directory.CreateDirectory(destPath) case .Err) + return .Err; + } + else + { + if (entry.ExtractToFile(destPath) case .Err) + return .Err; + } + } + + return .Ok; + } + + void CheckPE() + { + let module = Windows.GetModuleHandleW(null); + uint8* moduleData = (uint8*)(int)module; + PEFile.PEHeader* header = (.)moduleData; + + PEFile.PE_NTHeaders64* hdr64 = (.)(moduleData + header.e_lfanew); + if (hdr64.mFileHeader.mMachine == PEFile.PE_MACHINE_X64) + { + int fileEnd = 0; + + for (int sectIdx < hdr64.mFileHeader.mNumberOfSections) + { + PEFile.PESectionHeader* sectHdrHead = (.)((uint8*)(hdr64 + 1)) + sectIdx; + fileEnd = Math.Max(fileEnd, sectHdrHead.mPointerToRawData + sectHdrHead.mSizeOfRawData); + } + + + } + } + + public function void InstallFunc(StringView dest, StringView filter); + public function int ProgressFunc(); + public function void CancelFunc(); + + public function void StartFunc(InstallFunc installFunc, ProgressFunc progressFunc, CancelFunc cancelFunc); + + static void UI_Install(StringView dest, StringView filter) + { + + } + + static int UI_GetProgress() + { + return 0; + } + + static void UI_Cancel() + { + + } + + void StartUI(StringView dir) + { + String destLib = scope .(); + destLib.Append(dir); + destLib.Append("/../dist/StubUI_d.dll"); + + var lib = Windows.LoadLibraryW(destLib.ToScopedNativeWChar!()); + if (lib.IsInvalid) + { + Fail(scope String()..AppendF("Failed to load installer UI '{}'", destLib)); + return; + } + + StartFunc startFunc = (.)Windows.GetProcAddress(lib, "Start"); + if (startFunc == null) + { + Fail(scope String()..AppendF("Failed to initialize installer UI '{}'", destLib)); + return; + } + + startFunc(=> UI_Install, => UI_GetProgress, => UI_Cancel); + } + + void Run() + { + String cwd = scope .(); + Directory.GetCurrentDirectory(cwd); + StartUI(cwd); + + CheckPE(); + + ZipFile zipFile = scope .(); + zipFile.Open(@"c:\\temp\\build_1827.zip"); + ExtractTo(zipFile, @"c:\temp\unzip", .()); + + CabFile cabFile = scope .(); + cabFile.Init(); + cabFile.Copy(); + } + + static int Main(String[] args) + { + + Program pg = new Program(); + pg.ParseCommandLine(args); + pg.Run(); + delete pg; + return 0; + } + } +} diff --git a/BeefTools/BeefInstall/StubUI/Beef042Dbg64.dll b/BeefTools/BeefInstall/StubUI/Beef042Dbg64.dll new file mode 100644 index 00000000..4eae2288 Binary files /dev/null and b/BeefTools/BeefInstall/StubUI/Beef042Dbg64.dll differ diff --git a/BeefTools/BeefInstall/StubUI/Beef042RT64.dll b/BeefTools/BeefInstall/StubUI/Beef042RT64.dll new file mode 100644 index 00000000..f5e8bd3a Binary files /dev/null and b/BeefTools/BeefInstall/StubUI/Beef042RT64.dll differ diff --git a/BeefTools/BeefInstall/StubUI/BeefProj.toml b/BeefTools/BeefInstall/StubUI/BeefProj.toml new file mode 100644 index 00000000..da98affb --- /dev/null +++ b/BeefTools/BeefInstall/StubUI/BeefProj.toml @@ -0,0 +1,24 @@ +FileVersion = 1 +Dependencies = {corlib = "*", Beefy2D = "*"} + +[Project] +Name = "StubUI" +TargetType = "BeefDynLib" +StartupObject = "Program" +DefaultNamespace = "BIStubUI" + +[Configs.Debug.Win64] +TargetDirectory = "$(WorkspaceDir)/../dist" +TargetName = "$(ProjectName)_d" +OtherLinkFlags = "$(LinkFlags) BeefySysLib64_d.lib" +PostBuildCmds = ["Sleep(1000)", "cmd.exe /c echo Hey!", "CopyFilesIfNewer(\"$(WorkspaceDir)/../../../IDE/dist/BeefySysLib*.*\", \"$(WorkspaceDir)/../dist\")"] +DebugCommand = "$(WorkspaceDir)\\..\\dist\\Stub_d.exe" + +[Configs.Release.Win64] +TargetDirectory = "$(WorkspaceDir)/../dist" + +[Configs.Paranoid.Win64] +TargetDirectory = "$(WorkspaceDir)/../dist" + +[Configs.Test.Win64] +TargetDirectory = "$(WorkspaceDir)/../dist" diff --git a/BeefTools/BeefInstall/StubUI/BeefSpace.toml b/BeefTools/BeefInstall/StubUI/BeefSpace.toml new file mode 100644 index 00000000..bb37a711 --- /dev/null +++ b/BeefTools/BeefInstall/StubUI/BeefSpace.toml @@ -0,0 +1,10 @@ +FileVersion = 1 +Projects = {StubUI = {Path = "."}, Beefy2D = "*"} +Unlocked = ["corlib"] + +[Workspace] +StartupProject = "StubUI" + +[Configs.Debug.Win64] +AllocType = "CRT" +IntermediateType = "ObjectAndIRCode" diff --git a/BeefTools/BeefInstall/StubUI/StubUI_d.dll b/BeefTools/BeefInstall/StubUI/StubUI_d.dll new file mode 100644 index 00000000..73af9b01 Binary files /dev/null and b/BeefTools/BeefInstall/StubUI/StubUI_d.dll differ diff --git a/BeefTools/BeefInstall/StubUI/StubUI_d.dll.build.txt b/BeefTools/BeefInstall/StubUI/StubUI_d.dll.build.txt new file mode 100644 index 00000000..bc462c38 --- /dev/null +++ b/BeefTools/BeefInstall/StubUI/StubUI_d.dll.build.txt @@ -0,0 +1,2 @@ +IDE Process 43756 +-out:c:\Beef\BeefTools\BeefInstall\StubUI\StubUI_d.dll -dll -implib:"c:\Beef\BeefTools\BeefInstall\StubUI\StubUI_d.lib" c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/StubUI/BIStubUI_Program.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/DELEGATE_void_PTR_char8_outPtr_PTR_int32_outSize_PTR_System_Platform_Result_outR__.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/GLOBALS_.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Array.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Array1_System_Collections_Generic_HashSet_System_String_Slot.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Array1_System_Globalization_CalendarData.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Array1_System_Object.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Array1_System_String.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Array1_char16.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Array1_char8.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Array1_int.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Array1_int32.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_BitConverter.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Boolean.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_CallStackAddr.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Char16.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Char32.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Char8.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_ClassVData.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Collections_Generic_HashSet_System_String.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Collections_Generic_HashSet_System_String_Enumerator.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Collections_Generic_HashSet_System_String_Slot.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Collections_Generic_List_System_GC_RootCallback.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Collections_Generic_List_System_GC_RootCallback_Enumerator.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Collections_Generic_List_System_Object.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Collections_Generic_List_System_Object_Enumerator.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Collections_Generic_List_System_String.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Collections_Generic_List_System_String_Enumerator.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_CompilerSettings.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_DateTime.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_DateTimeKind.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_DayOfWeek.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_DbgRawAllocData.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Delegate.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Diagnostics_Debug.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Double.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Enum.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Event_System_GC_RootCallback.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Event_System_GC_RootCallback_Enumerator.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Function.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_GC.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_GC_RootCallback.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Globalization_Calendar.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Globalization_CalendarAlgorithmType.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Globalization_CalendarData.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Globalization_CalendarWeekRule.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Globalization_CultureData.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Globalization_CultureInfo.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Globalization_DateTimeFormatFlags.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Globalization_DateTimeFormatInfo.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Globalization_MonthNameStyles.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Globalization_NumberFormatInfo.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Globalization_NumberStyles.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Globalization_OwnedString.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Guid.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Int.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Int32.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Int32_ParseError.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Int64.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Int64_ParseError.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Int_ParseError.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Internal.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Math.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_MidpointRounding.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Nullable_System_Reflection_FieldInfo.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Object.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Platform.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Platform_BfpCritSect.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Platform_BfpDynLib.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Platform_BfpEvent.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Platform_BfpEventFlags.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Platform_BfpEventResult.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Platform_BfpFile.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Platform_BfpFileAttributes.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Platform_BfpFileCopyKind.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Platform_BfpFileCreateFlags.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Platform_BfpFileCreateKind.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Platform_BfpFileResult.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Platform_BfpFileSeekKind.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Platform_BfpFileStdKind.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Platform_BfpFileWatcher.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Platform_BfpFileWatcherFlags.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Platform_BfpFindFileData.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Platform_BfpFindFileFlags.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Platform_BfpKillFlags.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Platform_BfpLibResult.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Platform_BfpProcess.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Platform_BfpProcessResult.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Platform_BfpSpawn.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Platform_BfpSpawnFlags.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Platform_BfpSpawnResult.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Platform_BfpSysDirectoryKind.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Platform_BfpSystemResult.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Platform_BfpTimeStamp.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Platform_Result.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Reflection_ArrayType.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Reflection_BindingFlags.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Reflection_FieldFlags.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Reflection_FieldInfo.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Reflection_FieldInfo_Enumerator.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Reflection_FieldInfo_Error.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Reflection_MethodFlags.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Reflection_MethodInfo.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Reflection_MethodInfo_CallError.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Reflection_MethodInfo_Enumerator.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Reflection_PointerType.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Reflection_SizedArrayType.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Reflection_SpecializedGenericType.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Reflection_TypeFlags.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Reflection_TypeId.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Reflection_TypeInstance.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Reflection_TypeInstance_FieldData.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Reflection_TypeInstance_FieldSplatData.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Reflection_TypeInstance_MethodData.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Reflection_TypeInstance_ParamData.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Reflection_TypeInstance_ParamFlags.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Reflection_UnspecializedGenericType.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Reflection_UnspecializedGenericType_GenericParam.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Result_PTR_System_GC_RootCallback.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Result_PTR_System_Object.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Result_PTR_System_String.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Result_PTR_char8.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Result_PTR_void.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Result_System_DateTime.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Result_System_DayOfWeek.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Result_System_GC_RootCallback.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Result_System_Guid.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Result_System_Object.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Result_System_Reflection_FieldInfo.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Result_System_Reflection_MethodInfo.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Result_System_Reflection_MethodInfo_System_Type_MethodError.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Result_System_String.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Result_System_StringView.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Result_System_TimeSpan.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Result_System_Variant.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Result_System_Variant_System_Reflection_MethodInfo_CallError.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Result_bool.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Result_char32.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Result_char8.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Result_double.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Result_int.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Result_int32_System_Int32_ParseError.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Result_int64.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Result_int64_System_Int64_ParseError.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Result_int_System_Int_ParseError.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Result_uint64_System_UInt64_ParseError.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Result_void.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Result_void_System_Platform_Result.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Result_void_System_Reflection_FieldInfo_Error.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Runtime.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Runtime_BfDebugMessageData.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Runtime_BfDebugMessageData_MessageType.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Runtime_BfRtCallbacks.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Runtime_RtCrashReportKind.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Runtime_RtFlags.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Span_System_String.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Span_char16.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Span_char8.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Span_int32.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_String.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_StringComparison.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_StringSplitEnumerator.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_StringSplitOptions.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_StringView.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_String_CreateFlags.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_String_RawEnumerator.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_String_UTF8Enumerator.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Threading_Interlocked.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Threading_Interlocked_AtomicOrdering.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Threading_Interlocked_FenceAtomicOrdering.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Threading_Interlocked_LoadAtomicOrdering.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Threading_Interlocked_RMWAtomicOrdering.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Threading_Interlocked_StoreAtomicOrdering.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Threading_Monitor.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Threading_Monitor_MonitorLockInstance.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Threading_ParameterizedThreadStart.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Threading_Thread.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Threading_ThreadPriority.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Threading_ThreadStart.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Threading_ThreadState.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Threading_Thread_RuntimeThreadInit.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_TimeSpan.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Type.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_TypeCode.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Type_MethodError.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_UInt64.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_UInt64_ParseError.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_UnicodeNormalizationOptions.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_ValueType.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Variant.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/System_Void.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_U14@partialResult_int.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_U14@partialResult_int32.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_U14@partialResult_int64.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_U14@partialResult_uint64.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_U2@c_char32U4@idx_intU4@len_int.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_U2@c_char32U4@len_int.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_U4@err_System_Int32_ParseError.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_U4@err_System_Int64_ParseError.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_U4@err_System_Int_ParseError.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_U4@err_System_Platform_Result.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_U4@err_System_Reflection_FieldInfo_Error.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_U4@err_System_Reflection_MethodInfo_CallError.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_U4@err_System_Type_MethodError.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_U4@err_System_UInt64_ParseError.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_U4@err_void.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_U4@val_PTR_System_GC_RootCallback.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_U4@val_PTR_System_Object.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_U4@val_PTR_System_String.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_U4@val_PTR_char8.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_U4@val_PTR_void.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_U4@val_System_DateTime.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_U4@val_System_DayOfWeek.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_U4@val_System_GC_RootCallback.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_U4@val_System_Guid.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_U4@val_System_Object.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_U4@val_System_Reflection_FieldInfo.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_U4@val_System_Reflection_MethodInfo.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_U4@val_System_String.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_U4@val_System_StringView.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_U4@val_System_TimeSpan.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_U4@val_System_Variant.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_U4@val_bool.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_U4@val_char32.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_U4@val_char8.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_U4@val_double.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_U4@val_int.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_U4@val_int32.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_U4@val_int64.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_U4@val_uint64.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_U4@val_void.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_U9@paramIdx_int32.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_U9@startIdx_intU7@length_int.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_char32_int.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/corlib/TUPLE_char32_int_int.obj c:\Beef\BeefTools\BeefInstall\StubUI/build/Debug_Win64/StubUI/vdata.obj -defaultlib:libcmtd -nologo -incremental:no -pdb:c:\Beef\BeefTools\BeefInstall\StubUI\StubUI_d.pdb -debug -opt:noref -libpath:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.18362.0\um\x64" -libpath:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.18362.0\ucrt\x64" -libpath:"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\lib\x64" -libpath:"c:\beef\ide\dist\lib\x64" -libpath:c:\Beef\BeefTools\BeefInstall\StubUI Beef042RT64.lib Beef042Dbg64.lib \ No newline at end of file diff --git a/BeefTools/BeefInstall/StubUI/StubUI_d.exp b/BeefTools/BeefInstall/StubUI/StubUI_d.exp new file mode 100644 index 00000000..5cb3af9a Binary files /dev/null and b/BeefTools/BeefInstall/StubUI/StubUI_d.exp differ diff --git a/BeefTools/BeefInstall/StubUI/StubUI_d.lib b/BeefTools/BeefInstall/StubUI/StubUI_d.lib new file mode 100644 index 00000000..999486ee Binary files /dev/null and b/BeefTools/BeefInstall/StubUI/StubUI_d.lib differ diff --git a/BeefTools/BeefInstall/StubUI/StubUI_d.pdb b/BeefTools/BeefInstall/StubUI/StubUI_d.pdb new file mode 100644 index 00000000..0e5a6b90 Binary files /dev/null and b/BeefTools/BeefInstall/StubUI/StubUI_d.pdb differ diff --git a/BeefTools/BeefInstall/StubUI/src/BIApp.bf b/BeefTools/BeefInstall/StubUI/src/BIApp.bf new file mode 100644 index 00000000..19a26bcf --- /dev/null +++ b/BeefTools/BeefInstall/StubUI/src/BIApp.bf @@ -0,0 +1,41 @@ +using System; +using Beefy; +using Beefy.widgets; + +namespace BIStubUI +{ + class BIApp : BFApp + { + public function void InstallFunc(StringView dest, StringView filter); + public function int ProgressFunc(); + public function void CancelFunc(); + + public InstallFunc mInstallFunc; + public ProgressFunc mProgressFunc; + public CancelFunc mCancelFunc; + + Widget mRootWidget; + WidgetWindow mMainWindow; + + const int cWidth = 700; + const int cHeight = 700; + + public override void Init() + { + base.Init(); + + BFWindow.Flags windowFlags = BFWindow.Flags.Border | BFWindow.Flags.SysMenu | //| BFWindow.Flags.CaptureMediaKeys | + BFWindow.Flags.Caption | BFWindow.Flags.Minimize | BFWindow.Flags.QuitOnClose; + + mRootWidget = new Widget(); + mMainWindow = new WidgetWindow(null, "Beef Installer", 0, 0, cWidth, cHeight, windowFlags, mRootWidget); + mMainWindow.SetMinimumSize(480, 360); + mMainWindow.mIsMainWindow = true; + } + } + + static + { + public static BIApp gApp; + } +} diff --git a/BeefTools/BeefInstall/StubUI/src/Program.bf b/BeefTools/BeefInstall/StubUI/src/Program.bf new file mode 100644 index 00000000..c7d22d49 --- /dev/null +++ b/BeefTools/BeefInstall/StubUI/src/Program.bf @@ -0,0 +1,38 @@ +using System; +using System.Diagnostics; + +namespace BIStubUI +{ + class Program + { + public static this() + { + Debug.WriteLine("Initializing StubUI"); + } + + public static ~this() + { + Debug.WriteLine("Deinitializing StubUI"); + } + + [Export] + public static void Start(BIApp.InstallFunc installFunc, BIApp.ProgressFunc progressFunc, BIApp.CancelFunc cancelFunc) + { + gApp = new BIApp(); + gApp.mInstallFunc = installFunc; + gApp.mProgressFunc = progressFunc; + gApp.mCancelFunc = cancelFunc; + gApp.Run(); + } + + public static void Hello() + { + + } + + public static int Main(String[] args) + { + return 0; + } + } +} diff --git a/BeefTools/BeefInstall/src/Program.bf b/BeefTools/BeefInstall/src/Program.bf deleted file mode 100644 index da357c3b..00000000 --- a/BeefTools/BeefInstall/src/Program.bf +++ /dev/null @@ -1,96 +0,0 @@ -using System; -using IDE.Util; -using System.IO; - -namespace BeefInstall -{ - class Program - { - bool HandleCommandLineParam(String key, String value) - { - return false; - } - - void UnhandledCommandLine(String key, String value) - { - - } - - void ParseCommandLine(String[] args) - { - for (var str in args) - { - int eqPos = str.IndexOf('='); - if (eqPos == -1) - { - if (!HandleCommandLineParam(str, null)) - UnhandledCommandLine(str, null); - } - else - { - var cmd = scope String(str, 0, eqPos); - var param = scope String(str, eqPos + 1); - if (!HandleCommandLineParam(cmd, param)) - UnhandledCommandLine(cmd, param); - } - } - } - - Result ExtractTo(ZipFile zipFile, StringView destDir, StringView subStr) - { - String fileName = scope .(); - String destPath = scope .(); - - for (int i < zipFile.GetNumFiles()) - { - ZipFile.Entry entry = scope .(); - if (zipFile.SelectEntry(i, entry) case .Err) - continue; - - fileName.Clear(); - entry.GetFileName(fileName); - - if (!fileName.StartsWith(subStr)) - continue; - - destPath.Clear(); - destPath.Append(destDir); - destPath.Append('/'); - destPath.Append(fileName); - - if (entry.IsDirectory) - { - if (Directory.CreateDirectory(destPath) case .Err) - return .Err; - } - else - { - if (entry.ExtractToFile(destPath) case .Err) - return .Err; - } - } - - return .Ok; - } - - void Run() - { - ZipFile zipFile = scope .(); - zipFile.Open(@"c:\\temp\\build_1827.zip"); - ExtractTo(zipFile, @"c:\temp\unzip", .()); - - CabFile cabFile = scope .(); - cabFile.Init(); - cabFile.Copy(); - } - - static int Main(String[] args) - { - Program pg = new Program(); - pg.ParseCommandLine(args); - pg.Run(); - delete pg; - return 0; - } - } -} diff --git a/BeefySysLib/BeefySysLib.vcxproj b/BeefySysLib/BeefySysLib.vcxproj index c1a7365b..b264e7c0 100644 --- a/BeefySysLib/BeefySysLib.vcxproj +++ b/BeefySysLib/BeefySysLib.vcxproj @@ -247,6 +247,7 @@ WIN32;_DEBUG;_WINDOWS;BFSYSLIB_STATIC;%(PreprocessorDefinitions) ./; ./platform/win/; third_party/agg-2.4/include; third_party/agg-2.4/include/platform/win32; third_party/; third_party/libffi/i686-pc-cygwin; third_party/libffi/i686-pc-cygwin/include; third_party/libffi/include MultiThreadedDebug + false Windows diff --git a/IDE/BeefProj.toml b/IDE/BeefProj.toml index 7b0541b9..9cd34f24 100644 --- a/IDE/BeefProj.toml +++ b/IDE/BeefProj.toml @@ -27,7 +27,7 @@ TargetDirectory = "$(WorkspaceDir)/dist" TargetName = "BeefIDE_d" OtherLinkFlags = "$(LinkFlags) Comdlg32.lib kernel32.lib user32.lib advapi32.lib shell32.lib IDEHelper64_d.lib BeefySysLib64_d.lib" CLibType = "Dynamic" -DebugCommandArguments = "-proddir=C:\\Beef\\BeefTools\\BeefInstall" +DebugCommandArguments = "-open=c:\\proj\\TestCPP\\TestCPP.bfdbg" DebugWorkingDirectory = "c:\\Beef\\IDE\\Tests\\EmptyTest" EnvironmentVars = ["_NO_DEBUG_HEAP=1"] diff --git a/IDE/BeefSpace_User.toml b/IDE/BeefSpace_User.toml index 8454d090..9dcca02f 100644 --- a/IDE/BeefSpace_User.toml +++ b/IDE/BeefSpace_User.toml @@ -1,13 +1,14 @@ FileVersion = 1 LastConfig = "Debug" LastPlatform = "Win64" -RecentFilesList = ["c:\\beef\\ide\\src\\util\\Zip.bf", "c:\\beef\\ide\\src\\ui\\AutoComplete.bf"] +RecentFilesList = ["c:\\beef\\ide\\src\\IDEApp.bf", "c:\\beef\\IDEHelper\\DebugManager.cpp", "c:\\beef\\IDEHelper\\Compiler\\BfModule.cpp", "c:\\beef\\IDEHelper\\Compiler\\BfCompiler.cpp", "c:\\beef\\ide\\src\\BuildContext.bf", "c:\\beef\\beefrt\\dbg\\gc.cpp", "c:\\beef\\ide\\src\\ScriptManager.bf", "c:\\beef\\ide\\src\\Project.bf", "c:\\beef\\ide\\src\\CommandQueueManager.bf", "c:\\Beef\\BeefLibs\\corlib\\src\\System\\String.bf"] +StepFilters = ["System.StringView.operator System.StringView"] [MainWindow] -X = 679 -Y = 504 -Width = 2487 -Height = 1554 +X = 1021 +Y = 227 +Width = 2206 +Height = 1810 [MainDockingFrame] Type = "DockingFrame" @@ -41,39 +42,346 @@ DefaultDocumentsTabbedView = true Type = "TabbedView" [[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -Active = true -TabLabel = "Zip.bf" -TabWidth = 73.0 +TabLabel = "DebugManager.cpp" +TabWidth = 156.0 Type = "SourceViewPanel" -FilePath = "c:\\beef\\ide\\src\\util\\Zip.bf" -CursorPos = 2802 -VertPos = 780.0 +FilePath = "c:\\beef\\IDEHelper\\DebugManager.cpp" +CursorPos = 15042 +VertPos = 8490.0 +ProjectName = "IDEHelper" + +[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] +TabLabel = "CommandQueueManager.bf" +TabWidth = 205.0 +Type = "SourceViewPanel" +FilePath = "c:\\beef\\ide\\src\\CommandQueueManager.bf" +CursorPos = 896 +VertPos = 1170.0 ProjectName = "IDE" +[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] +TabLabel = "ProjectProperties.bf" +TabWidth = 145.0 +Type = "SourceViewPanel" +FilePath = "c:\\beef\\ide\\src\\ui\\ProjectProperties.bf" +CursorPos = 1930 +VertPos = 270.0 +ProjectName = "IDE" + +[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] +TabLabel = "ProjectPanel.bf" +TabWidth = 116.0 +Type = "SourceViewPanel" +FilePath = "c:\\beef\\ide\\src\\ui\\ProjectPanel.bf" +CursorPos = 58964 +VertPos = 25350.0 +ProjectName = "IDE" + +[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] +TabLabel = "Directory.bf" +TabWidth = 98.0 +Type = "SourceViewPanel" +FilePath = "c:\\Beef\\BeefLibs\\corlib\\src\\System\\IO\\Directory.bf" +CursorPos = 294 +ProjectName = "corlib" + [[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] TabLabel = "AutoComplete.bf" -TabWidth = 138.0 +TabWidth = 128.0 Type = "SourceViewPanel" FilePath = "c:\\beef\\ide\\src\\ui\\AutoComplete.bf" -CursorPos = 3588 -VertPos = 2205.0 +CursorPos = 5948 +VertPos = 3060.0 ProjectName = "IDE" [[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -TabLabel = "Disassembly" -TabWidth = 122.0 -Type = "DisassemblyPanel" +TabLabel = "Stopwatch.bf" +TabWidth = 105.0 +Type = "SourceViewPanel" +FilePath = "c:\\Beef\\BeefLibs\\corlib\\src\\System\\Diagnostics\\Stopwatch.bf" +CursorPos = 309 +ProjectName = "corlib" + +[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] +TabLabel = "IComparable.bf" +TabWidth = 120.0 +Type = "SourceViewPanel" +FilePath = "c:\\Beef\\BeefLibs\\corlib\\src\\System\\IComparable.bf" +CursorPos = 404 +ProjectName = "corlib" + +[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] +TabLabel = "Dictionary.bf" +TabWidth = 103.0 +Type = "SourceViewPanel" +FilePath = "c:\\Beef\\BeefLibs\\corlib\\src\\System\\Collections\\Generic\\Dictionary.bf" +CursorPos = 13141 +ProjectName = "corlib" + +[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] +TabLabel = "Workspace.bf" +TabWidth = 110.0 +Type = "SourceViewPanel" +FilePath = "c:\\beef\\ide\\src\\Workspace.bf" +CursorPos = 10820 +VertPos = 5745.0 +ProjectName = "IDE" + +[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] +TabLabel = "Project.bf" +TabWidth = 85.0 +Type = "SourceViewPanel" +FilePath = "c:\\beef\\ide\\src\\Project.bf" +CursorPos = 31286 +VertPos = 16875.0 +ProjectName = "IDE" + +[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] +TabLabel = "gc.cpp" +TabWidth = 69.0 +Type = "SourceViewPanel" +FilePath = "c:\\beef\\beefrt\\dbg\\gc.cpp" +CursorPos = 29571 +VertPos = 16845.0 + +[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] +TabLabel = "String.bf" +TabWidth = 79.0 +Type = "SourceViewPanel" +FilePath = "c:\\Beef\\BeefLibs\\corlib\\src\\System\\String.bf" +CursorPos = 20322 +VertPos = 11775.0 +ProjectName = "corlib" + +[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] +TabLabel = "ImmediatePanel.bf" +TabWidth = 137.0 +Type = "SourceViewPanel" +FilePath = "c:\\beef\\ide\\src\\ui\\ImmediatePanel.bf" +CursorPos = 1248 +ProjectName = "IDE" + +[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] +TabLabel = "StatusBar.bf" +TabWidth = 98.0 +Type = "SourceViewPanel" +FilePath = "c:\\beef\\ide\\src\\ui\\StatusBar.bf" +CursorPos = 11876 +ProjectName = "IDE" + +[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] +TabLabel = "ImmediateWidget.bf" +TabWidth = 148.0 +Type = "SourceViewPanel" +FilePath = "c:\\beef\\ide\\src\\ui\\ImmediateWidget.bf" +CursorPos = 10575 +VertPos = 4425.0 +ProjectName = "IDE" + +[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] +TabLabel = "ScriptManager.bf" +TabWidth = 130.0 +Type = "SourceViewPanel" +FilePath = "c:\\beef\\ide\\src\\ScriptManager.bf" +CursorPos = 46372 +VertPos = 29080.0 +ProjectName = "IDE" + +[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] +TabLabel = "ListView.bf" +TabWidth = 91.0 +Type = "SourceViewPanel" +FilePath = "c:\\beef\\BeefLibs\\Beefy2D\\src\\widgets\\ListView.bf" +CursorPos = 24610 +ProjectName = "Beefy2D" + +[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] +TabLabel = "EditWidget.bf" +TabWidth = 109.0 +Type = "SourceViewPanel" +FilePath = "c:\\beef\\BeefLibs\\Beefy2D\\src\\widgets\\EditWidget.bf" +CursorPos = 70859 +ProjectName = "Beefy2D" + +[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] +TabLabel = "OpenFileInSolutionDialog.bf" +TabWidth = 191.0 +Type = "SourceViewPanel" +FilePath = "c:\\beef\\ide\\src\\ui\\OpenFileInSolutionDialog.bf" +CursorPos = 3378 +ProjectName = "IDE" + +[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] +TabLabel = "InstalledProjectDialog.bf" +TabWidth = 171.0 +Type = "SourceViewPanel" +FilePath = "c:\\beef\\ide\\src\\ui\\InstalledProjectDialog.bf" +CursorPos = 2662 +ProjectName = "IDE" + +[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] +TabLabel = "ClassViewPanel.bf" +TabWidth = 133.0 +Type = "SourceViewPanel" +FilePath = "c:\\beef\\ide\\src\\ui\\ClassViewPanel.bf" +CursorPos = 10536 +ProjectName = "IDE" + +[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] +TabLabel = "BinaryDataWidget.bf" +TabWidth = 149.0 +Type = "SourceViewPanel" +FilePath = "c:\\beef\\ide\\src\\ui\\BinaryDataWidget.bf" +CursorPos = 87580 +ProjectName = "IDE" + +[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] +TabLabel = "BfIRBuilder.cpp" +TabWidth = 116.0 +Type = "SourceViewPanel" +FilePath = "c:\\beef\\IDEHelper\\Compiler\\BfIRBuilder.cpp" +CursorPos = 132547 +ProjectName = "IDEHelper" + +[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] +TabLabel = "BfIRCodeGen.cpp" +TabWidth = 131.0 +Type = "SourceViewPanel" +FilePath = "c:\\beef\\IDEHelper\\Compiler\\BfIRCodeGen.cpp" +CursorPos = 124783 +ProjectName = "IDEHelper" + +[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] +TabLabel = "memory" +TabWidth = 78.0 +Type = "SourceViewPanel" +FilePath = "c:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Professional\\VC\\Tools\\MSVC\\14.21.27702\\include\\memory" +CursorPos = 68115 + +[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] +TabLabel = "Verifier.cpp" +TabWidth = 96.0 +Type = "SourceViewPanel" +FilePath = "c:\\Beef\\extern\\llvm-project_8_0_0\\llvm\\lib\\IR\\Verifier.cpp" +CursorPos = 189261 + +[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] +TabLabel = "BfExprEvaluator.cpp" +TabWidth = 145.0 +Type = "SourceViewPanel" +FilePath = "c:\\beef\\IDEHelper\\Compiler\\BfExprEvaluator.cpp" +CursorPos = 395532 +ProjectName = "IDEHelper" + +[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] +TabLabel = "BfModule.cpp" +TabWidth = 111.0 +Type = "SourceViewPanel" +FilePath = "c:\\beef\\IDEHelper\\Compiler\\BfModule.cpp" +CursorPos = 701696 +VertPos = 303765.0 +ProjectName = "IDEHelper" + +[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] +TabLabel = "Result.bf" +TabWidth = 80.0 +Type = "SourceViewPanel" +FilePath = "c:\\Beef\\BeefLibs\\corlib\\src\\System\\Result.bf" +CursorPos = 699 +ProjectName = "corlib" + +[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] +TabLabel = "LegacyPassManager.cpp" +TabWidth = 173.0 +Type = "SourceViewPanel" +FilePath = "c:\\Beef\\extern\\llvm-project_8_0_0\\llvm\\lib\\IR\\LegacyPassManager.cpp" +CursorPos = 56552 + +[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] +TabLabel = "LexicalScopes.cpp" +TabWidth = 135.0 +Type = "SourceViewPanel" +FilePath = "c:\\Beef\\extern\\llvm-project_8_0_0\\llvm\\lib\\CodeGen\\LexicalScopes.cpp" +CursorPos = 6263 + +[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] +TabLabel = "TimeZoneInfo.bf" +TabWidth = 124.0 +Type = "SourceViewPanel" +FilePath = "c:\\Beef\\BeefLibs\\corlib\\src\\System\\TimeZoneInfo.bf" +CursorPos = 118021 +ProjectName = "corlib" + +[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] +TabLabel = "Windows.bf" +TabWidth = 98.0 +Type = "SourceViewPanel" +FilePath = "c:\\Beef\\BeefLibs\\corlib\\src\\System\\Windows.bf" +CursorPos = 40234 +ProjectName = "corlib" + +[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] +TabLabel = "Platform.cpp" +TabWidth = 104.0 +Type = "SourceViewPanel" +FilePath = "c:\\beef\\BeefySysLib\\platform\\win\\Platform.cpp" +CursorPos = 59719 +ProjectName = "BeefySysLib" + +[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] +TabLabel = "BfCompiler.bf" +TabWidth = 108.0 +Type = "SourceViewPanel" +FilePath = "c:\\beef\\ide\\src\\Compiler\\BfCompiler.bf" +CursorPos = 7397 +ProjectName = "IDE" + +[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] +TabLabel = "BfCompiler.cpp" +TabWidth = 118.0 +Type = "SourceViewPanel" +FilePath = "c:\\beef\\IDEHelper\\Compiler\\BfCompiler.cpp" +CursorPos = 181147 +VertPos = 82605.0 +ProjectName = "IDEHelper" + +[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] +TabLabel = "WinDebugger.cpp" +TabWidth = 135.0 +Type = "SourceViewPanel" +FilePath = "c:\\beef\\IDEHelper\\WinDebugger.cpp" +CursorPos = 120268 +ProjectName = "Debugger64" + +[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] +TabLabel = "BuildContext.bf" +TabWidth = 117.0 +Type = "SourceViewPanel" +FilePath = "c:\\beef\\ide\\src\\BuildContext.bf" +CursorPos = 3642 +VertPos = 1395.0 +ProjectName = "IDE" + +[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] +Active = true +TabLabel = "IDEApp.bf" +TabWidth = 88.0 +Type = "SourceViewPanel" +FilePath = "c:\\beef\\ide\\src\\IDEApp.bf" +CursorPos = 320852 +VertPos = 158655.0 +ProjectName = "IDE" [[MainDockingFrame.DockedWidgets]] RequestedWidth = 250.0 -RequestedHeight = 553.0 +RequestedHeight = 408.0 Type = "DockingFrame" SplitType = 1 [[MainDockingFrame.DockedWidgets.DockedWidgets]] RequestedWidth = 250.0 RequestedHeight = 250.0 -SizePriority = 0.443346 +SizePriority = 0.4483547 Type = "TabbedView" [[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] @@ -99,7 +407,7 @@ TabLabel = "Watch" TabWidth = 86.0 Type = "WatchPanel" Columns = [{Width = 306.0}, {Width = 675.0}, {Width = 200.0}] -Items = [""] +Items = ["this", "instIdx", "mcBlock", "bfProject", "gApp", ""] [[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] TabLabel = "Auto" @@ -110,7 +418,7 @@ Columns = [{Width = 200.0}, {Width = 442.0}, {Width = 200.0}] [[MainDockingFrame.DockedWidgets.DockedWidgets]] RequestedWidth = 910.0 RequestedHeight = 793.0 -SizePriority = 0.203422 +SizePriority = 0.1984133 Type = "TabbedView" [[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] @@ -146,6 +454,31 @@ TabLabel = "Output" TabWidth = 90.0 Type = "OutputPanel" +[[Breakpoints]] +File = "c:\\Beef\\extern\\llvm-project_8_0_0\\llvm\\lib\\IR\\Verifier.cpp" +Line = 4875 +Column = 6 + +[[Breakpoints]] +File = "c:\\Beef\\extern\\llvm-project_8_0_0\\llvm\\lib\\IR\\Verifier.cpp" +Line = 214 +Column = 4 + +[[Breakpoints]] +File = "c:\\beef\\ide\\src\\Workspace.bf" +Line = 661 +Column = 3 + +[[Bookmarks]] +File = "c:\\beef\\ide\\src\\BuildContext.bf" +Line = 465 +Column = 6 + +[[Bookmarks]] +File = "c:\\beef\\ide\\src\\BuildContext.bf" +Line = 465 +Column = 6 + [DebuggerDisplayTypes.""] -IntDisplayType = "Default" +IntDisplayType = "Hexadecimal" MmDisplayType = "Default" diff --git a/IDE/Tests/BugW001/BeefProj.toml b/IDE/Tests/BugW001/BeefProj.toml new file mode 100644 index 00000000..36b8e196 --- /dev/null +++ b/IDE/Tests/BugW001/BeefProj.toml @@ -0,0 +1,5 @@ +FileVersion = 1 + +[Project] +Name = "BugW001" +StartupObject = "BugW001.Program" diff --git a/IDE/Tests/BugW001/BeefSpace.toml b/IDE/Tests/BugW001/BeefSpace.toml new file mode 100644 index 00000000..a3e5083d --- /dev/null +++ b/IDE/Tests/BugW001/BeefSpace.toml @@ -0,0 +1,8 @@ +FileVersion = 1 +Projects = {BugW001 = {Path = "."}} + +[Workspace] +StartupProject = "BugW001" + +[Configs.Debug.Win64] +BfOptimizationLevel = "O0" diff --git a/IDE/Tests/BugW001/scripts/Test.txt b/IDE/Tests/BugW001/scripts/Test.txt new file mode 100644 index 00000000..44d5a7ca --- /dev/null +++ b/IDE/Tests/BugW001/scripts/Test.txt @@ -0,0 +1,9 @@ +# This tests extensions on Result, where the void* operator would be double-declared in the IR + +ShowFile("src/Program.bf") +GotoText("//Main_Start") +ToggleBreakpoint() +RunWithCompiling() + +ToggleCommentAt("Result_Get") +Compile() \ No newline at end of file diff --git a/IDE/Tests/BugW001/src/Program.bf b/IDE/Tests/BugW001/src/Program.bf new file mode 100644 index 00000000..594632ed --- /dev/null +++ b/IDE/Tests/BugW001/src/Program.bf @@ -0,0 +1,18 @@ +#pragma warning disable 168 + +using System; + +namespace BugW001 +{ + class Program + { + static void Main() + { + //Main_Start + Result result = .(); + /*Result_Get + void* vp = result; + */ + } + } +} diff --git a/IDE/mintest/BeefSpace.toml b/IDE/mintest/BeefSpace.toml index 6442203f..be668c8f 100644 --- a/IDE/mintest/BeefSpace.toml +++ b/IDE/mintest/BeefSpace.toml @@ -10,6 +10,7 @@ IntermediateType = "ObjectAndIRCode" ConfigSelections = {mintest2 = {Enabled = false}} [Configs.Debug.Win64] +BfOptimizationLevel = "O0" IntermediateType = "ObjectAndIRCode" COptimizationLevel = "Og" diff --git a/IDE/mintest/minlib/src/System/Attribute.bf b/IDE/mintest/minlib/src/System/Attribute.bf index 3954f60a..f631b1af 100644 --- a/IDE/mintest/minlib/src/System/Attribute.bf +++ b/IDE/mintest/minlib/src/System/Attribute.bf @@ -291,33 +291,6 @@ namespace System public bool Profile; } - namespace Runtime.InteropServices - { - public enum CallingConvention - { - Winapi = 1, - Cdecl = 2, - StdCall = 3, - ThisCall = 4, - FastCall = 5, - - Default = Cdecl - } - - [AttributeUsage(AttributeTargets.Method /*3*/)] - public struct DllImportAttribute : Attribute - { - public this(String dllName) - { - CallingConvention = .Default; - CLink = false; - } - - public CallingConvention CallingConvention; - public bool CLink; - } - } - public struct ImportAttribute : Attribute { public this(String libName) @@ -325,6 +298,11 @@ namespace System } } + public struct ExportAttribute : Attribute + { + + } + [AttributeUsage(AttributeTargets.StaticField | AttributeTargets.Field, .NotInherited)] public struct ThreadStaticAttribute : Attribute { diff --git a/IDE/mintest/minlib/src/System/Collections/Generic/List.bf b/IDE/mintest/minlib/src/System/Collections/Generic/List.bf index 57bcb3b7..ecfc0d2b 100644 --- a/IDE/mintest/minlib/src/System/Collections/Generic/List.bf +++ b/IDE/mintest/minlib/src/System/Collections/Generic/List.bf @@ -7,7 +7,6 @@ #endif using System; -using System.Runtime; using System.Diagnostics; using System.Diagnostics.Contracts; using System.Threading; diff --git a/IDE/mintest/minlib/src/System/Collections/IEnumerator.bf b/IDE/mintest/minlib/src/System/Collections/IEnumerator.bf index 378b90dc..0a9ad699 100644 --- a/IDE/mintest/minlib/src/System/Collections/IEnumerator.bf +++ b/IDE/mintest/minlib/src/System/Collections/IEnumerator.bf @@ -1,5 +1,4 @@ using System; -using System.Runtime.InteropServices; namespace System.Collections { diff --git a/IDE/mintest/minlib/src/System/Double.bf b/IDE/mintest/minlib/src/System/Double.bf index e906b382..e3da0e03 100644 --- a/IDE/mintest/minlib/src/System/Double.bf +++ b/IDE/mintest/minlib/src/System/Double.bf @@ -19,7 +19,6 @@ namespace System ///#if GENERICS_WORK /// using System.Numerics; ///#endif - using System.Runtime.InteropServices; using System.Diagnostics.Contracts; public struct Double : double, IHashable, IOpComparable, IOpNegatable, ICanBeNaN /*: IComparable, IFormattable, IConvertible diff --git a/IDE/mintest/minlib/src/System/Math.bf b/IDE/mintest/minlib/src/System/Math.bf index f340838f..47254eaa 100644 --- a/IDE/mintest/minlib/src/System/Math.bf +++ b/IDE/mintest/minlib/src/System/Math.bf @@ -16,7 +16,6 @@ namespace System { //This class contains only static members and doesn't require serialization. using System; - using System.Runtime; using System.Diagnostics.Contracts; using System.Diagnostics; diff --git a/IDE/mintest/minlib/src/System/Nullable.bf b/IDE/mintest/minlib/src/System/Nullable.bf index 7828e88e..6638b3f3 100644 --- a/IDE/mintest/minlib/src/System/Nullable.bf +++ b/IDE/mintest/minlib/src/System/Nullable.bf @@ -1,6 +1,5 @@ using System.Reflection; using System.Collections.Generic; -using System.Runtime.InteropServices; using System.Diagnostics; namespace System diff --git a/IDE/mintest/minlib/src/System/Threading/Monitor.bf b/IDE/mintest/minlib/src/System/Threading/Monitor.bf index 629dbca9..47a4ad46 100644 --- a/IDE/mintest/minlib/src/System/Threading/Monitor.bf +++ b/IDE/mintest/minlib/src/System/Threading/Monitor.bf @@ -20,7 +20,6 @@ namespace System.Threading { using System; - using System.Runtime; using System.Threading; using System.Diagnostics.Contracts; using System.Diagnostics; diff --git a/IDE/mintest/mintest.bfuser b/IDE/mintest/mintest.bfuser deleted file mode 100644 index 14b6bd13..00000000 --- a/IDE/mintest/mintest.bfuser +++ /dev/null @@ -1,387 +0,0 @@ -LastConfig = "Debug" -LastPlatform = "Win64" -RecentFilesList = ["c:\\beef\\ide\\mintest\\src\\main2.cs", "c:\\beef\\ide\\mintest\\src\\main3.cs", "c:\\beef\\ide\\mintest\\src\\main.cs", "c:\\beef\\ide\\mintest\\minlib\\src\\System\\String.cs", "c:\\beef\\ide\\mintest\\minlib\\src\\System\\Collections\\Generic\\List.bf", "c:\\beef\\ide\\mintest\\minlib\\src\\System\\Array.cs", "c:\\beef\\ide\\mintest\\minlib\\src\\System\\IComparable.cs", "c:\\beef\\ide\\mintest\\minlib\\src\\System\\Collections\\Generic\\Dictionary.bf", "c:\\beef\\ide\\mintest\\minlib\\src\\System\\Object.cs", "Disassembly"] - -[MainWindow] -X = 128 -Y = 166 -Width = 2434 -Height = 1847 - -[MainDockingFrame] -Type = "DockingFrame" -SplitType = 2 - -[[MainDockingFrame.DockedWidgets]] -RequestedWidth = 250.000000 -RequestedHeight = 1133.000000 -SizePriority = 1133.000000 -Type = "DockingFrame" -SplitType = 1 - -[[MainDockingFrame.DockedWidgets.DockedWidgets]] -RequestedWidth = 263.000000 -RequestedHeight = 250.000000 -SizePriority = 0.000000 -Type = "TabbedView" - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -TabLabel = "Workspace" -TabWidth = 95.000000 -Type = "ProjectPanel" - -[[MainDockingFrame.DockedWidgets.DockedWidgets]] -IsFillWidget = true -RequestedWidth = 1639.000000 -RequestedHeight = 150.000000 -SizePriority = 1639.000000 -DefaultDocumentsTabbedView = true -Type = "TabbedView" - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -TabLabel = "Contracts.cs" -TabWidth = 110.000000 -Type = "SourceViewPanel" -FilePath = "c:\\beef\\ide\\mintest\\minlib\\src\\System\\Diagnostics\\Contracts\\Contracts.cs" -CursorPos = 2270 -VertPos = 0.000000 -ProjectName = "minlib" - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -TabLabel = "internal.cpp" -TabWidth = 108.000000 -Type = "SourceViewPanel" -FilePath = "c:\\beef\\beefrt\\rt\\internal.cpp" -CursorPos = 20281 -VertPos = 0.000000 - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -TabLabel = "main4.cs" -TabWidth = 90.000000 -Type = "SourceViewPanel" -FilePath = "c:\\beef\\ide\\mintest\\mintest2\\src\\main4.cs" -CursorPos = 182 -VertPos = 0.000000 -ProjectName = "mintest2" - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -TabLabel = "Internal.cs" -TabWidth = 98.000000 -Type = "SourceViewPanel" -FilePath = "c:\\beef\\ide\\mintest\\minlib\\src\\System\\Internal.cs" -CursorPos = 2881 -VertPos = 0.000000 -ProjectName = "minlib" - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -TabLabel = "Array.cs" -TabWidth = 86.000000 -Type = "SourceViewPanel" -FilePath = "c:\\beef\\ide\\mintest\\minlib\\src\\System\\Array.cs" -CursorPos = 608 -VertPos = 0.000000 -ProjectName = "minlib" - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -TabLabel = "Variant.cs" -TabWidth = 96.000000 -Type = "SourceViewPanel" -FilePath = "c:\\beef\\ide\\mintest\\minlib\\src\\System\\Variant.cs" -CursorPos = 4292 -VertPos = 0.000000 -ProjectName = "minlib" - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -TabLabel = "String.cs" -TabWidth = 89.000000 -Type = "SourceViewPanel" -FilePath = "c:\\beef\\ide\\mintest\\minlib\\src\\System\\String.cs" -CursorPos = 10914 -VertPos = 0.000000 -ProjectName = "minlib" - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -TabLabel = "Runtime.bf" -TabWidth = 102.000000 -Type = "SourceViewPanel" -FilePath = "c:\\beef\\ide\\mintest\\minlib\\src\\System\\Runtime.bf" -CursorPos = 2021 -VertPos = 0.000000 -ProjectName = "minlib" - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -TabLabel = "List.bf" -TabWidth = 74.000000 -Type = "SourceViewPanel" -FilePath = "c:\\beef\\ide\\mintest\\minlib\\src\\System\\Collections\\Generic\\List.bf" -CursorPos = 9410 -VertPos = 0.000000 -ProjectName = "minlib" - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -TabLabel = "Event.bf" -TabWidth = 86.000000 -Type = "SourceViewPanel" -FilePath = "c:\\beef\\ide\\mintest\\minlib\\src\\System\\Event.bf" -CursorPos = 743 -VertPos = 0.000000 -ProjectName = "minlib" - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -TabLabel = "IEnumerator.cs" -TabWidth = 125.000000 -Type = "SourceViewPanel" -FilePath = "c:\\beef\\ide\\mintest\\minlib\\src\\System\\Collections\\IEnumerator.cs" -CursorPos = 464 -VertPos = 0.000000 -ProjectName = "minlib" - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -TabLabel = "Type.cs" -TabWidth = 83.000000 -Type = "SourceViewPanel" -FilePath = "c:\\beef\\ide\\mintest\\minlib\\src\\System\\Type.cs" -CursorPos = 1538 -VertPos = 0.000000 -ProjectName = "minlib" - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -TabLabel = "Disassembly" -TabWidth = 112.000000 -Type = "DisassemblyPanel" - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -TabLabel = "Object.cs" -TabWidth = 93.000000 -Type = "SourceViewPanel" -FilePath = "c:\\beef\\ide\\mintest\\minlib\\src\\System\\Object.cs" -CursorPos = 452 -VertPos = 0.000000 -ProjectName = "minlib" - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -TabLabel = "main2.cs" -TabWidth = 90.000000 -Type = "SourceViewPanel" -FilePath = "c:\\beef\\ide\\mintest\\src\\main2.cs" -CursorPos = 2845 -VertPos = 3060.000000 -ProjectName = "mintest" - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -TabLabel = "main3.cs" -TabWidth = 90.000000 -Type = "SourceViewPanel" -FilePath = "c:\\beef\\ide\\mintest\\src\\main3.cs" -CursorPos = 1954 -VertPos = 0.000000 -ProjectName = "mintest" - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -TabLabel = "main.cs" -TabWidth = 83.000000 -Type = "SourceViewPanel" -FilePath = "c:\\beef\\ide\\mintest\\src\\main.cs" -CursorPos = 4383 -VertPos = 0.000000 -ProjectName = "mintest" - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -TabLabel = "Nullable.cs" -TabWidth = 103.000000 -Type = "SourceViewPanel" -FilePath = "c:\\beef\\ide\\mintest\\minlib\\src\\System\\Nullable.cs" -CursorPos = 623 -VertPos = 0.000000 -ProjectName = "minlib" - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -TabLabel = "GC.cs" -TabWidth = 72.000000 -Type = "SourceViewPanel" -FilePath = "c:\\beef\\ide\\mintest\\minlib\\src\\System\\GC.cs" -CursorPos = 1934 -VertPos = 0.000000 -ProjectName = "minlib" - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -TabLabel = "testdll.cpp" -TabWidth = 100.000000 -Type = "SourceViewPanel" -FilePath = "c:\\beef\\beeftools\\testdll\\testdll.cpp" -CursorPos = 939 -VertPos = 0.000000 - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -TabLabel = "stdio.h" -TabWidth = 79.000000 -Type = "SourceViewPanel" -FilePath = "c:\\program files (x86)\\windows kits\\10\\include\\10.0.16299.0\\ucrt\\stdio.h" -CursorPos = 27765 -VertPos = 0.000000 - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -TabLabel = "Profiler.bf" -TabWidth = 96.000000 -Type = "SourceViewPanel" -FilePath = "c:\\beef\\ide\\mintest\\minlib\\src\\System\\Diagnostics\\Profiler.bf" -CursorPos = 450 -VertPos = 0.000000 -ProjectName = "minlib" - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -TabLabel = "Dictionary.bf" -TabWidth = 113.000000 -Type = "SourceViewPanel" -FilePath = "c:\\beef\\ide\\mintest\\minlib\\src\\System\\Collections\\Generic\\Dictionary.bf" -CursorPos = 3575 -VertPos = 0.000000 -ProjectName = "minlib" - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -TabLabel = "IComparable.cs" -TabWidth = 130.000000 -Type = "SourceViewPanel" -FilePath = "c:\\beef\\ide\\mintest\\minlib\\src\\System\\IComparable.cs" -CursorPos = 75 -VertPos = 0.000000 -ProjectName = "minlib" - -[[MainDockingFrame.DockedWidgets.DockedWidgets]] -RequestedWidth = 291.000000 -RequestedHeight = 250.000000 -SizePriority = 0.000000 -Type = "TabbedView" - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -TabLabel = "Properties" -TabWidth = 90.000000 -Type = "PropertiesPanel" - -[[MainDockingFrame.DockedWidgets]] -RequestedWidth = 250.000000 -RequestedHeight = 540.000000 -SizePriority = 0.000000 -Type = "DockingFrame" -SplitType = 1 - -[[MainDockingFrame.DockedWidgets.DockedWidgets]] -RequestedWidth = 920.000000 -RequestedHeight = 250.000000 -SizePriority = 0.396523 -Type = "TabbedView" - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -TabLabel = "Auto" -TabWidth = 150.000000 -Type = "AutoWatchPanel" -Items = ["args", "str", ""] - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs.Columns]] -Width = 225.000000 - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs.Columns]] -Width = 498.000000 - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs.Columns]] -Width = 275.000000 - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -TabLabel = "Watch" -TabWidth = 150.000000 -Type = "WatchPanel" -Items = ["args", "z", ""] - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs.Columns]] -Width = 264.000000 - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs.Columns]] -Width = 984.000000 - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs.Columns]] -Width = 275.000000 - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -TabLabel = "Memory" -TabWidth = 150.000000 -Type = "MemoryPanel" - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -TabLabel = "Breakpoints" -TabWidth = 150.000000 -Type = "BreakpointPanel" - -[[MainDockingFrame.DockedWidgets.DockedWidgets]] -RequestedWidth = 777.000000 -RequestedHeight = 250.000000 -SizePriority = 0.603477 -Type = "TabbedView" - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -TabLabel = "Threads" -TabWidth = 150.000000 -Type = "ThreadPanel" - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -TabLabel = "Immediate" -TabWidth = 150.000000 -Type = "ImmediatePanel" - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -TabLabel = "Output" -TabWidth = 150.000000 -Type = "OutputPanel" - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -TabLabel = "Find Results" -TabWidth = 150.000000 -Type = "FindResultsPanel" - -[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]] -TabLabel = "Call Stack" -TabWidth = 150.000000 -Type = "CallStackPanel" - -[[Bookmarks]] -File = "c:\\beef\\IDE\\mintest\\main.cs" -Line = 306 -Column = 3 - -[[Bookmarks]] -File = "c:\\beef\\IDE\\mintest\\main.cs" -Line = 56 -Column = 2 - -[[Bookmarks]] -File = "c:\\beef\\IDE\\mintest\\main2.cs" -Line = 8 -Column = 0 - -[[Bookmarks]] -File = "c:\\beef\\IDE\\mintest\\main3.cs" -Line = 177 -Column = 2 - -[DebuggerDisplayTypes] - -[DebuggerDisplayTypes.""] -IntDisplayType = "Hexadecimal" -MmDisplayType = "Default" - -[[StepFilters]] -Filter = "System::Internal::ThrowIndexOutOfRange" - -[[StepFilters]] -Filter = "BfObjectStackInit" - -[[StepFilters]] -Filter = "[].this" - -[[StepFilters]] -Filter = "std::basic_string<>::basic_string<>" - -[[StepFilters]] -Filter = "System.StringView.this" - -[[StepFilters]] -Filter = "TestA::TestA" diff --git a/IDE/mintest/src/main.bf b/IDE/mintest/src/main.bf index b79417cc..acb4fd0a 100644 --- a/IDE/mintest/src/main.bf +++ b/IDE/mintest/src/main.bf @@ -15,7 +15,6 @@ using System; using System.Threading; using System.Collections.Generic; using System.Diagnostics; -using System.Runtime.InteropServices; using System.Diagnostics; using System.Collections.Generic; using System.Collections; @@ -178,13 +177,18 @@ namespace Hey.Dude.Bro public static int Main(String[] args) { - while (true) + Blurg.Hey(); + + /*while (true) { int a = 0; } int* iPtr = null; - *iPtr = 123; + *iPtr = 123;*/ + + GC.SetAutoCollectPeriod(20); + Thread.Sleep(1000); String str = scope .("Boops!"); int len = str.GetLength(); @@ -196,7 +200,7 @@ namespace Hey.Dude.Bro //Thread.Sleep(500); - Test2(1, 2, 3, 4); + //Test2(1, 2, 3, 4); thread.Join(); diff --git a/IDE/mintest/src/main2.bf b/IDE/mintest/src/main2.bf index e69de29b..1f15fa26 100644 --- a/IDE/mintest/src/main2.bf +++ b/IDE/mintest/src/main2.bf @@ -0,0 +1,7 @@ +class Snorf +{ + struct Bloog + { + int mA; + } +} diff --git a/IDE/mintest/src/main3.bf b/IDE/mintest/src/main3.bf index 281a7cdd..dbddf695 100644 --- a/IDE/mintest/src/main3.bf +++ b/IDE/mintest/src/main3.bf @@ -80,13 +80,6 @@ class ClassF : ClassE } -class Snorf -{ - public static void Borf(ClassD cd) - { - cd.Poo(); - } -} [NoDiscard("Use this value!")] struct TestStruct @@ -97,70 +90,33 @@ struct TestStruct class Blurg { - public static void UseTS(TestStruct ts) + [Export, CLink, StdCall] + public static void Poof() { - int c = ts.mA; + PrintF("Poofs!\n"); } - [NoDiscard("Why you no use me?")] - public static int UseMe() + [Export, CLink, StdCall] + public static void Poof2() { - return 999; - } - - public static TestStruct UseIt() - { - return .(); - } - - mixin FartOut(int a) - { - a = 0; - - //let c = 1; - //c = 3; - //int b = 123; - //int c = 99; + PrintF("Poofs2!\n"); } public static void Hey() { - mixin Fart(int a) - { - //a = 0; - //int b = 123; - //int c = 99; - } + Snorf sn = scope .(); - /*int c = 222; - Fart!(c);*/ + Result voidPtrResult = default; - //int __CRASH_AUTOVARIABLE__ = 123; - - //UseIt(); - - //UseMe(); - - //int a; + //void* val = voidPtrResult; - for (int i < 10) - { - int a = 0; - } + //Result ts = .Ok(.()); - TestStruct ts = .(); - ts.mA = 111; - ts.mB = 222; - UseTS(ts); + //let val = ts.Get(); + //Snorf.Bloog bl = .(); - ClassD cd = null; - //let str = cd.mStr; - - -#if A || B - ClassC cc = scope .(); -#endif + //Poof(); } } diff --git a/IDE/src/BuildContext.bf b/IDE/src/BuildContext.bf new file mode 100644 index 00000000..d740a753 --- /dev/null +++ b/IDE/src/BuildContext.bf @@ -0,0 +1,1062 @@ +using System.Collections.Generic; +using System; +using IDE.Compiler; +using System.IO; +using System.Diagnostics; +using Beefy; +using IDE.util; + +namespace IDE +{ + class BuildContext + { + public Project mHotProject; + public Workspace.Options mWorkspaceOptions; + public Dictionary mImpLibMap = new .() ~ + { + for (let val in _.Values) + delete val; + delete _; + }; + public ScriptManager mScriptManager ~ delete _; + + public bool Failed + { + get + { + if (mScriptManager != null) + return mScriptManager.mFailed; + return false; + } + } + + public enum CustomBuildCommandResult + { + NoCommands, + HadCommands, + Failed + } + + public CustomBuildCommandResult QueueProjectCustomBuildCommands(Project project, String targetPath, Project.BuildCommandTrigger trigger, List cmdList) + { + if (cmdList.IsEmpty) + return .NoCommands; + + if (trigger == .Never) + return .NoCommands; + + if ((trigger == .IfFilesChanged) && (!project.mForceCustomCommands)) + { + int64 highestDateTime = 0; + + int64 targetDateTime = File.GetLastWriteTime(targetPath).Get().ToFileTime(); + + bool forceRebuild = false; + + for (var depName in project.mDependencies) + { + var depProject = gApp.mWorkspace.FindProject(depName.mProjectName); + if (depProject != null) + { + if (depProject.mLastDidBuild) + forceRebuild = true; + } + } + + project.WithProjectItems(scope [&] (projectItem) => + { + var projectSource = projectItem as ProjectSource; + var importPath = scope String(); + projectSource.GetFullImportPath(importPath); + Result fileDateTime = File.GetLastWriteTime(importPath); + if (fileDateTime case .Ok) + { + let date = fileDateTime.Get().ToFileTime(); + /*if (date > targetDateTime) + Console.WriteLine("Custom build higher time: {0}", importPath);*/ + highestDateTime = Math.Max(highestDateTime, date); + } + }); + + if ((highestDateTime <= targetDateTime) && (!forceRebuild)) + return .NoCommands; + + project.mLastDidBuild = true; + } + + Workspace.Options workspaceOptions = gApp.GetCurWorkspaceOptions(); + Project.Options options = gApp.GetCurProjectOptions(project); + + bool didCommands = false; + + let targetName = scope String("Project ", project.mProjectName); + + //Console.WriteLine("Executing custom command {0} {1} {2}", highestDateTime, targetDateTime, forceRebuild); + for (let origCustomCmd in cmdList) + { + bool isCommand = false; + for (let c in origCustomCmd.RawChars) + { + if ((c == '\"') || (c == '$')) + break; + if (c == '(') + isCommand = true; + } + + String customCmd = scope String(); + + if (isCommand) + { + customCmd.Append(origCustomCmd); + } + else + { + customCmd.Append("%exec "); + gApp.ResolveConfigString(workspaceOptions, project, options, origCustomCmd, "custom command", customCmd); + } + + if (customCmd.IsWhiteSpace) + continue; + + if (mScriptManager == null) + { + mScriptManager = new .(); + mScriptManager.mProjectName = new String(project.mProjectName); + mScriptManager.mAllowCompiling = true; + mScriptManager.mSoftFail = true; + mScriptManager.mVerbosity = gApp.mVerbosity; + didCommands = true; + } + + mScriptManager.QueueCommands(customCmd, project.mProjectName, .NoLines); + continue; + } + + if (didCommands) + { + mScriptManager.QueueCommands(scope String()..AppendF("%targetComplete {}", project.mProjectName), targetName, .NoLines); + + let targetCompleteCmd = new IDEApp.TargetCompletedCmd(project); + targetCompleteCmd.mIsReady = false; + gApp.mExecutionQueue.Add(targetCompleteCmd); + project.mNeedsTargetRebuild = true; + } + + return didCommands ? .HadCommands : .Failed; + } + + bool QueueProjectGNULink(Project project, String targetPath, Workspace.Options workspaceOptions, Project.Options options, String objectsArg) + { + bool isDebug = gApp.mConfigName.IndexOf("Debug", true) != -1; + +#if BF_PLATFORM_WINDOWS + String llvmDir = scope String(IDEApp.sApp.mInstallDir); + IDEUtils.FixFilePath(llvmDir); + llvmDir.Append("llvm/"); +#else + String llvmDir = ""; +#endif + + //String error = scope String(); + + bool isExe = project.mGeneralOptions.mTargetType != Project.TargetType.BeefLib; + if (isExe) + { + String linkLine = scope String(isDebug ? "-g " : "-g -O2 "); //-O2 -Rpass=inline + //(doClangCPP ? "-lc++abi " : "") + + + linkLine.Append("-o "); + IDEUtils.AppendWithOptionalQuotes(linkLine, targetPath); + linkLine.Append(" "); + + /*if (options.mBuildOptions.mLinkerType == Project.LinkerType.GCC) + { + // ... + } + else + { + linkLine.Append("--target="); + GetTargetName(workspaceOptions, linkLine); + linkLine.Append(" "); + }*/ + + if ((project.mGeneralOptions.mTargetType == Project.TargetType.BeefWindowsApplication) || + (project.mGeneralOptions.mTargetType == Project.TargetType.C_WindowsApplication)) + { + linkLine.Append("-mwindows "); + } + + linkLine.Append("-no-pie "); + + linkLine.Append(objectsArg); + + //var destDir = scope String(); + //Path.GetDirectoryName(); + + //TODO: Make an option + if (options.mBuildOptions.mCLibType == Project.CLibType.Static) + { + linkLine.Append("-static-libgcc -static-libstdc++ "); + } + else + { +#if BF_PLATFORM_WINDOWS + String[] mingwFiles; + String fromDir; + if (workspaceOptions.mMachineType == Workspace.MachineType.x86) + { + fromDir = scope:: String(llvmDir, "i686-w64-mingw32/bin/"); + mingwFiles = scope:: String[] { "libgcc_s_dw2-1.dll", "libstdc++-6.dll" }; + } + else + { + fromDir = scope:: String(llvmDir, "x86_64-w64-mingw32/bin/"); + mingwFiles = scope:: String[] { "libgcc_s_seh-1.dll", "libstdc++-6.dll", "libwinpthread-1.dll" }; + } + for (var mingwFile in mingwFiles) + { + String fromPath = scope String(fromDir, mingwFile); + //string toPath = projectBuildDir + "/" + mingwFile; + String toPath = scope String(); + Path.GetDirectoryPath(targetPath, toPath); + toPath.Append("/", mingwFile); + if (!File.Exists(toPath)) + { + if (File.Copy(fromPath, toPath) case .Err) + { + gApp.OutputLineSmart("ERROR: Failed to copy mingw file {0}", fromPath); + return false; + } + } + } +#endif + } + + List depProjectList = scope List(); + gApp.GetDependentProjectList(project, depProjectList); + if (depProjectList.Count > 0) + { + for (var dep in project.mDependencies) + { + var depProject = gApp.mWorkspace.FindProject(dep.mProjectName); + if (depProject == null) + { + gApp.OutputLine("Failed to locate dependent library: {0}", dep.mProjectName); + return false; + } + else + { + /*if (depProject.mNeedsTargetRebuild) + project.mNeedsTargetRebuild = true;*/ + + var depOptions = gApp.GetCurProjectOptions(depProject); + + if (depOptions.mClangObjectFiles != null) + { + var argBuilder = scope IDEApp.ArgBuilder(linkLine, true); + + for (var fileName in depOptions.mClangObjectFiles) + { + //AppendWithOptionalQuotes(linkLine, fileName); + argBuilder.AddFileName(fileName); + argBuilder.AddSep(); + } + } + + + /*String depLibTargetPath = scope String(); + ResolveConfigString(depProject, depOptions, "$(TargetPath)", error, depLibTargetPath); + IDEUtils.FixFilePath(depLibTargetPath); + + String depDir = scope String(); + Path.GetDirectoryName(depLibTargetPath, depDir); + String depFileName = scope String(); + Path.GetFileNameWithoutExtension(depLibTargetPath, depFileName); + + AppendWithOptionalQuotes(linkLine, depLibTargetPath); + linkLine.Append(" ");*/ + } + } + } + +#if BF_PLATFORM_WINDOWS + String gccExePath = "c:/mingw/bin/g++.exe"; + String clangExePath = scope String(llvmDir, "bin/clang++.exe"); +#else + String gccExePath = "/usr/bin/c++"; + String clangExePath = scope String("/usr/bin/c++"); +#endif + + if (project.mNeedsTargetRebuild) + { + if (File.Delete(targetPath) case .Err) + { + gApp.OutputLine("Failed to delete {0}", targetPath); + return false; + } + + if (workspaceOptions.mToolsetType == .GNU) + { + if (workspaceOptions.mMachineType == Workspace.MachineType.x86) + { + } + else + { + IDEUtils.AppendWithOptionalQuotes(linkLine, scope String("-L", llvmDir, "/x86_64-w64-mingw32/lib")); + linkLine.Append(" "); + IDEUtils.AppendWithOptionalQuotes(linkLine, scope String("-L", llvmDir, "/lib/gcc/x86_64-w64-mingw32/5.2.0")); + linkLine.Append(" "); + } + } + else // Microsoft + { + if (workspaceOptions.mMachineType == Workspace.MachineType.x86) + { + //linkLine.Append("-L\"C:\\Program Files (x86)\\Windows Kits\\10\\Lib\\10.0.10586.0\\ucrt\\x86\" "); + for (var libPath in gApp.mSettings.mVSSettings.mLib32Paths) + { + linkLine.AppendF("-L\"{0}\" ", libPath); + } + } + else + { + /*linkLine.Append("-L\"C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\lib\\amd64\" "); + linkLine.Append("-L\"C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\atlmfc\\lib\\amd64\" "); + linkLine.Append("-L\"C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.14393.0\\ucrt\\x64\" "); + linkLine.Append("-L\"C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.14393.0\\um\\x64\" ");*/ + for (var libPath in gApp.mSettings.mVSSettings.mLib64Paths) + { + linkLine.AppendF("-L\"{0}\" ", libPath); + } + } + } + + if (options.mBuildOptions.mOtherLinkFlags.Length != 0) + { + var linkFlags = scope String(); + gApp.ResolveConfigString(workspaceOptions, project, options, options.mBuildOptions.mOtherLinkFlags, "link flags", linkFlags); + linkLine.Append(linkFlags, " "); + } + + String compilerExePath = (workspaceOptions.mToolsetType == .GNU) ? gccExePath : clangExePath; + String workingDir = scope String(); + if (!llvmDir.IsEmpty) + { + workingDir.Append(llvmDir, "bin"); + } + else + { + workingDir.Append(gApp.mInstallDir); + } + + var runCmd = gApp.QueueRun(compilerExePath, linkLine, workingDir, .UTF8); + runCmd.mOnlyIfNotFailed = true; + var tagetCompletedCmd = new IDEApp.TargetCompletedCmd(project); + tagetCompletedCmd.mOnlyIfNotFailed = true; + gApp.mExecutionQueue.Add(tagetCompletedCmd); + + String logStr = scope String(); + logStr.AppendF("IDE Process {0}\r\n", Platform.BfpProcess_GetCurrentId()); + logStr.Append(linkLine); + String targetLogPath = scope String(targetPath, ".build.txt"); + Utils.WriteTextFile(targetLogPath, logStr); + + project.mLastDidBuild = true; + } + } + + return true; + } + + public static void GetPdbPath(String targetPath, Workspace.Options workspaceOptions, Project.Options options, String outPdbPath) + { + int lastDotPos = targetPath.LastIndexOf('.'); + outPdbPath.Append(targetPath, 0, lastDotPos); + if (workspaceOptions.mToolsetType == .LLVM) + outPdbPath.Append("_lld"); + outPdbPath.Append(".pdb"); + } + + public static void GetRtLibNames(Workspace.Options workspaceOptions, Project.Options options, bool dynName, String outRt, String outDbg) + { + if ((!dynName) || (options.mBuildOptions.mBeefLibType != .Static)) + { + outRt.Append("Beef", IDEApp.sRTVersionStr, "RT"); + outRt.Append((workspaceOptions.mMachineType == .x86) ? "32" : "64"); + switch (options.mBuildOptions.mBeefLibType) + { + case .Dynamic: + case .DynamicDebug: outRt.Append("_d"); + case .Static: + switch (options.mBuildOptions.mCLibType) + { + case .None: + case .Dynamic, .SystemMSVCRT: outRt.Append("_s"); + case .DynamicDebug: outRt.Append("_sd"); + case .Static: outRt.Append("_ss"); + case .StaticDebug: outRt.Append("_ssd"); + } + } + outRt.Append(dynName ? ".dll" : ".lib"); + } + + if ((workspaceOptions.mEnableObjectDebugFlags) || (workspaceOptions.mAllocType == .Debug)) + { + outDbg.Append("Beef", IDEApp.sRTVersionStr, "Dbg"); + outDbg.Append((workspaceOptions.mMachineType == .x86) ? "32" : "64"); + if (options.mBuildOptions.mBeefLibType == .DynamicDebug) + outDbg.Append("_d"); + outDbg.Append(dynName ? ".dll" : ".lib"); + } + + /*if ((workspaceOptions.mEnableObjectDebugFlags) && + ((!dynName) || (options.mBuildOptions.mBeefLibType != .Static))) + { + outDbg.Append("Beef", IDEApp.sRTVersionStr, "Dbg"); + outDbg.Append((workspaceOptions.mMachineType == .x86) ? "32" : "64"); + switch (options.mBuildOptions.mBeefLibType) + { + case .Dynamic: + case .DynamicDebug: outDbg.Append("_d"); + case .Static: + switch (options.mBuildOptions.mCLibType) + { + case .None: + case .Dynamic, .SystemMSVCRT: outDbg.Append("_s"); + case .DynamicDebug: outDbg.Append("_sd"); + case .Static: outDbg.Append("_ss"); + case .StaticDebug: outDbg.Append("_ssd"); + } + } + outDbg.Append(dynName ? ".dll" : ".lib"); + }*/ + } + + bool QueueProjectMSLink(Project project, String targetPath, String configName, Workspace.Options workspaceOptions, Project.Options options, String objectsArg) + { + String llvmDir = scope String(IDEApp.sApp.mInstallDir); + IDEUtils.FixFilePath(llvmDir); + llvmDir.Append("llvm/"); + + TestManager.ProjectInfo testProjectInfo = null; + if (gApp.mTestManager != null) + testProjectInfo = gApp.mTestManager.GetProjectInfo(project); + + bool isExe = (project.mGeneralOptions.mTargetType != Project.TargetType.BeefLib) || (testProjectInfo != null); + if (isExe) + { + String linkLine = scope String(); + + linkLine.Append("-out:"); + IDEUtils.AppendWithOptionalQuotes(linkLine, targetPath); + linkLine.Append(" "); + + if (testProjectInfo != null) + linkLine.Append("-subsystem:console "); + else if (project.mGeneralOptions.mTargetType == .BeefWindowsApplication) + linkLine.Append("-subsystem:windows "); + else if (project.mGeneralOptions.mTargetType == .C_WindowsApplication) + linkLine.Append("-subsystem:console "); + else if (project.mGeneralOptions.mTargetType == .BeefDynLib) + { + linkLine.Append("-dll "); + + if (targetPath.EndsWith(".dll", .InvariantCultureIgnoreCase)) + { + linkLine.Append("-implib:\""); + linkLine.Append(targetPath, 0, targetPath.Length - 4); + linkLine.Append(".lib\" "); + } + } + + linkLine.Append(objectsArg); + + //var destDir = scope String(); + //Path.GetDirectoryName(); + + //TODO: Allow selecting lib file. Check date when copying instead of just ALWAYS copying... + LibBlock: + { + List stdLibFileNames = scope .(2); + String fromDir; + + fromDir = scope String(gApp.mInstallDir); + + bool AddLib(String dllName) + { + stdLibFileNames.Add(dllName); + + String fromPath = scope String(fromDir, dllName); + String toPath = scope String(); + Path.GetDirectoryPath(targetPath, toPath); + toPath.Append("/", dllName); + if (File.CopyIfNewer(fromPath, toPath) case .Err) + { + gApp.OutputLine("Failed to copy lib file {0}", fromPath); + return false; + } + return true; + } + + String rtName = scope String(); + String dbgName = scope String(); + GetRtLibNames(workspaceOptions, options, true, rtName, dbgName); + if (!rtName.IsEmpty) + if (!AddLib(rtName)) + return false; + if (!dbgName.IsEmpty) + if (!AddLib(dbgName)) + return false; + switch (workspaceOptions.mAllocType) + { + case .JEMalloc: + if (!AddLib("jemalloc.dll")) + return false; + default: + } + } + + List depProjectList = scope List(); + gApp.GetDependentProjectList(project, depProjectList); + if (depProjectList.Count > 0) + { + for (var dep in project.mDependencies) + { + var depProject = gApp.mWorkspace.FindProject(dep.mProjectName); + if (depProject == null) + { + gApp.OutputLine("Failed to locate dependent library: {0}", dep.mProjectName); + return false; + } + else + { + /*if (depProject.mNeedsTargetRebuild) + project.mNeedsTargetRebuild = true;*/ + + var depOptions = gApp.GetCurProjectOptions(depProject); + if (depOptions != null) + { + if (depOptions.mClangObjectFiles != null) + { + var argBuilder = scope IDEApp.ArgBuilder(linkLine, true); + + for (var fileName in depOptions.mClangObjectFiles) + { + //AppendWithOptionalQuotes(linkLine, fileName); + argBuilder.AddFileName(fileName); + argBuilder.AddSep(); + } + } + } + + if (depProject.mGeneralOptions.mTargetType == .BeefDynLib) + { + if (mImpLibMap.TryGetValue(depProject, var libPath)) + { + IDEUtils.AppendWithOptionalQuotes(linkLine, libPath); + linkLine.Append(" "); + } + } + + + /*String depLibTargetPath = scope String(); + ResolveConfigString(depProject, depOptions, "$(TargetPath)", error, depLibTargetPath); + IDEUtils.FixFilePath(depLibTargetPath); + + String depDir = scope String(); + Path.GetDirectoryName(depLibTargetPath, depDir); + String depFileName = scope String(); + Path.GetFileNameWithoutExtension(depLibTargetPath, depFileName); + + AppendWithOptionalQuotes(linkLine, depLibTargetPath); + linkLine.Append(" ");*/ + } + } + } + + if (project.mNeedsTargetRebuild) + { + /*if (File.Delete(targetPath).Failed(true)) + { + OutputLine("Failed to delete {0}", targetPath); + return false; + }*/ + + switch (options.mBuildOptions.mCLibType) + { + case .None: + linkLine.Append("-nodefaultlib "); + case .Dynamic: + //linkLine.Append((workspaceOptions.mMachineType == .x86) ? "-defaultlib:msvcprt " : "-defaultlib:msvcrt "); + linkLine.Append("-defaultlib:msvcrt "); + case .Static: + //linkLine.Append((workspaceOptions.mMachineType == .x86) ? "-defaultlib:libcpmt " : "-defaultlib:libcmt "); + linkLine.Append("-defaultlib:libcmt "); + case .DynamicDebug: + //linkLine.Append((workspaceOptions.mMachineType == .x86) ? "-defaultlib:msvcprtd " : "-defaultlib:msvcrtd "); + linkLine.Append("-defaultlib:msvcrtd "); + case .StaticDebug: + //linkLine.Append((workspaceOptions.mMachineType == .x86) ? "-defaultlib:libcpmtd " : "-defaultlib:libcmtd "); + linkLine.Append("-defaultlib:libcmtd "); + case .SystemMSVCRT: + linkLine.Append("-nodefaultlib "); + + String minRTModName = scope String(); + if ((project.mGeneralOptions.mTargetType == .BeefWindowsApplication) || + (project.mGeneralOptions.mTargetType == .C_WindowsApplication)) + minRTModName.Append("g"); + if (options.mBuildOptions.mBeefLibType == .DynamicDebug) + minRTModName.Append("d"); + if (!minRTModName.IsEmpty) + minRTModName.Insert(0, "_"); + + if (workspaceOptions.mMachineType == .x86) + linkLine.Append(gApp.mInstallDir, @"lib\x86\msvcrt.lib Beef", IDEApp.sRTVersionStr,"MinRT32", minRTModName, ".lib "); + else + linkLine.Append(gApp.mInstallDir, @"lib\x64\msvcrt.lib Beef", IDEApp.sRTVersionStr,"MinRT64", minRTModName, ".lib "); + linkLine.Append("ntdll.lib user32.lib kernel32.lib gdi32.lib winmm.lib shell32.lib ole32.lib rpcrt4.lib chkstk.obj -ignore:4049 -ignore:4217 "); + } + linkLine.Append("-nologo "); + //linkLine.Append("-fixed "); + + // Incremental just seems to be slower for Beef. Test on larger projects to verify + linkLine.Append("-incremental:no "); + + if (options.mBuildOptions.mStackSize > 0) + linkLine.AppendF("-stack:{} ", options.mBuildOptions.mStackSize); + + linkLine.Append("-pdb:"); + let pdbName = scope String(); + GetPdbPath(targetPath, workspaceOptions, options, pdbName); + IDEUtils.AppendWithOptionalQuotes(linkLine, pdbName); + linkLine.Append(" "); + + //TODO: Only add -debug if we have some debug info? + //if (isDebug) + if (workspaceOptions.mEmitDebugInfo != .No) + linkLine.Append("-debug "); + + if (workspaceOptions.mBfOptimizationLevel.IsOptimized()) + //linkLine.Append("-opt:ref -verbose "); + linkLine.Append("-opt:ref "); + else + linkLine.Append("-opt:noref "); + + if (workspaceOptions.mMachineType == .x86) + { + //linkLine.Append("-libpath:\"C:\\Program Files (x86)\\Windows Kits\\10\\Lib\\10.0.10586.0\\ucrt\\x86\" "); + for (var libPath in gApp.mSettings.mVSSettings.mLib32Paths) + { + linkLine.AppendF("-libpath:\"{0}\" ", libPath); + } + linkLine.Append("-libpath:\"", gApp.mInstallDir, "lib\\x86\" "); + } + else + { + /*linkLine.Append("-libpath:\"C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\lib\\amd64\" "); + linkLine.Append("-libpath:\"C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\atlmfc\\lib\\amd64\" "); + linkLine.Append("-libpath:\"C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.14393.0\\ucrt\\x64\" "); + linkLine.Append("-libpath:\"C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.14393.0\\um\\x64\" ");*/ + for (var libPath in gApp.mSettings.mVSSettings.mLib64Paths) + { + linkLine.AppendF("-libpath:\"{0}\" ", libPath); + } + linkLine.Append("-libpath:\"", gApp.mInstallDir, "lib\\x64\" "); + } + + String targetDir = scope String(); + Path.GetDirectoryPath(targetPath, targetDir); + linkLine.Append("-libpath:"); + IDEUtils.AppendWithOptionalQuotes(linkLine, targetDir); + linkLine.Append(" "); + + if (options.mBuildOptions.mOtherLinkFlags.Length != 0) + { + var linkFlags = scope String(); + gApp.ResolveConfigString(workspaceOptions, project, options, options.mBuildOptions.mOtherLinkFlags, "link flags", linkFlags); + linkLine.Append(linkFlags, " "); + } + + let winOptions = project.mWindowsOptions; + /*if (!String.IsNullOrWhiteSpace(project.mWindowsOptions.mManifestFile)) + { + String manifestPath = scope String(); + String error = scope String(); + ResolveConfigString(project, options, winOptions.mManifestFile, error, manifestPath); + if (!manifestPath.IsWhiteSpace) + { + linkLine.Append("/MANIFEST:EMBED /MANIFESTINPUT:"); + IDEUtils.AppendWithOptionalQuotes(linkLine, manifestPath); + linkLine.Append(" "); + } + }*/ + + // Put back + if ((!String.IsNullOrWhiteSpace(project.mWindowsOptions.mIconFile)) || + (!String.IsNullOrWhiteSpace(project.mWindowsOptions.mManifestFile)) || + (winOptions.HasVersionInfo())) + { + String projectBuildDir = scope String(); + gApp.GetProjectBuildDir(project, projectBuildDir); + + String resOutPath = scope String(); + resOutPath.Append(projectBuildDir, "\\Resource.res"); + + String iconPath = scope String(); + gApp.ResolveConfigString(workspaceOptions, project, options, winOptions.mIconFile, "icon file", iconPath); + + // Generate resource + Result CreateResourceFile() + { + ResourceGen resGen = scope ResourceGen(); + if (resGen.Start(resOutPath) case .Err) + { + gApp.OutputErrorLine("Failed to create resource file '{0}'", resOutPath); + return .Err; + } + if (!iconPath.IsWhiteSpace) + { + Path.GetAbsolutePath(scope String(iconPath), project.mProjectDir, iconPath..Clear()); + if (resGen.AddIcon(iconPath) case .Err) + { + gApp.OutputErrorLine("Failed to add icon"); + return .Err; + } + } + + let targetFileName = scope String(); + Path.GetFileName(targetPath, targetFileName); + + if (resGen.AddVersion(winOptions.mDescription, winOptions.mComments, winOptions.mCompany, winOptions.mProduct, + winOptions.mCopyright, winOptions.mFileVersion, winOptions.mProductVersion, targetFileName) case .Err) + { + gApp.OutputErrorLine("Failed to add version"); + return .Err; + } + + String manifestPath = scope String(); + gApp.ResolveConfigString(workspaceOptions, project, options, winOptions.mManifestFile, "manifest file", manifestPath); + if (!manifestPath.IsWhiteSpace) + { + Path.GetAbsolutePath(scope String(manifestPath), project.mProjectDir, manifestPath..Clear()); + if (resGen.AddManifest(manifestPath) case .Err) + { + gApp.OutputErrorLine("Failed to add manifest file"); + return .Err; + } + } + + Try!(resGen.Finish()); + return .Ok; + } + + if (CreateResourceFile() case .Err) + { + gApp.OutputErrorLine("Failed to generate resource file: {0}", resOutPath); + return false; + } + + IDEUtils.AppendWithOptionalQuotes(linkLine, resOutPath); + } + + + //String linkerPath = "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\bin\\amd64\\link.exe"; + + let binPath = (workspaceOptions.mMachineType == .x86) ? gApp.mSettings.mVSSettings.mBin32Path : gApp.mSettings.mVSSettings.mBin64Path; + if (binPath.IsWhiteSpace) + { + gApp.OutputErrorLine("Visual Studio tool path not configured. Check Visual Studio configuration in File\\Preferences\\Settings."); + return false; + } + + String linkerPath = scope String(); + linkerPath.Append(binPath); + linkerPath.Append("/link.exe"); + if (workspaceOptions.mToolsetType == .LLVM) + { + linkerPath.Clear(); + linkerPath.Append(gApp.mInstallDir); + linkerPath.Append(@"llvm\bin\lld-link.exe"); + //linkerPath = @"C:\Program Files\LLVM\bin\lld-link.exe"; + + var ltoType = workspaceOptions.mLTOType; + if (options.mBeefOptions.mLTOType != null) + ltoType = options.mBeefOptions.mLTOType.Value; + + if (ltoType == .Thin) + { + linkLine.Append(" /lldltocache:"); + + String ltoPath = scope String(); + Path.GetDirectoryPath(targetPath, ltoPath); + ltoPath.Append("/ltocache"); + IDEUtils.AppendWithOptionalQuotes(linkLine, ltoPath); + } + } + //String linkerPath = "C:\\Beef\\IDE\\dist\\BeefLink.exe"; + + //QueueRun(compilerExePath, linkLine, @"c:\mingw\bin", (options.mGeneralOptions.mLinkerType == Project.LinkerType.Clang) && (linkLine.Length > 1024)); + //QueueRun(compilerExePath, linkLine, @"c:\mingw\bin", (linkLine.Length > 1024)); + + var runCmd = gApp.QueueRun(linkerPath, linkLine, gApp.mInstallDir, .UTF16WithBom); + runCmd.mOnlyIfNotFailed = true; + var tagetCompletedCmd = new IDEApp.TargetCompletedCmd(project); + tagetCompletedCmd.mOnlyIfNotFailed = true; + gApp.mExecutionQueue.Add(tagetCompletedCmd); + + String logStr = scope String(); + logStr.AppendF("IDE Process {0}\r\n", Platform.BfpProcess_GetCurrentId()); + logStr.Append(linkLine); + String targetLogPath = scope String(targetPath, ".build.txt"); + Utils.WriteTextFile(targetLogPath, logStr); + + project.mLastDidBuild = true; + } + } + + return true; + } + + public bool QueueProjectCompile(Project project, Project hotProject, IDEApp.BuildCompletedCmd completedCompileCmd, List hotFileNames, bool runAfter) + { + project.mLastDidBuild = false; + + TestManager.ProjectInfo testProjectInfo = null; + if (gApp.mTestManager != null) + testProjectInfo = gApp.mTestManager.GetProjectInfo(project); + + var configSelection = gApp.GetCurConfigSelection(project); + Project.Options options = gApp.GetCurProjectOptions(project); + if (options == null) + return true; + + Workspace.Options workspaceOptions = gApp.GetCurWorkspaceOptions(); + BfCompiler bfCompiler = gApp.mBfBuildCompiler; + var bfProject = gApp.mBfBuildSystem.mProjectMap[project]; + bool bfHadOutputChanges; + List bfFileNames = scope List(); + bfCompiler.GetOutputFileNames(bfProject, true, out bfHadOutputChanges, bfFileNames); + defer ClearAndDeleteItems(bfFileNames);//DeleteAndClearItems!(bfFileNames); + if (bfHadOutputChanges) + project.mNeedsTargetRebuild = true; + + List allFileNames = scope List(); + List clangAllObjNames = scope List(); + //List clangObjNames = scope List(); + + gApp.GetClangFiles(project.mRootFolder, allFileNames); + + String workspaceBuildDir = scope String(); + gApp.GetWorkspaceBuildDir(workspaceBuildDir); + String projectBuildDir = scope String(); + gApp.GetProjectBuildDir(project, projectBuildDir); + if (!projectBuildDir.IsEmpty) + Directory.CreateDirectory(projectBuildDir).IgnoreError(); + + //List buildFileNames = new List(); + + String targetPath = scope String(); + + String outputDir = scope String(); + String absOutputDir = scope String(); + + if (testProjectInfo != null) + { + absOutputDir.Append(projectBuildDir); + outputDir = absOutputDir; + targetPath.Append(outputDir, "/", project.mProjectName); +#if BF_PLATFORM_WINDOWS + targetPath.Append(".exe"); +#endif + + Debug.Assert(testProjectInfo.mTestExePath == null); + testProjectInfo.mTestExePath = new String(targetPath); + } + else + { + gApp.ResolveConfigString(workspaceOptions, project, options, options.mBuildOptions.mTargetDirectory, "target directory", outputDir); + Path.GetAbsolutePath(project.mProjectDir, outputDir, absOutputDir); + outputDir = absOutputDir; + gApp.ResolveConfigString(workspaceOptions, project, options, "$(TargetPath)", "target path", targetPath); + } + IDEUtils.FixFilePath(targetPath); + if (!File.Exists(targetPath)) + { + project.mNeedsTargetRebuild = true; + + String targetDir = scope String(); + Path.GetDirectoryPath(targetPath, targetDir); + if (!targetDir.IsEmpty) + Directory.CreateDirectory(targetDir).IgnoreError(); + } + + if (project.mGeneralOptions.mTargetType == .BeefDynLib) + { + if (targetPath.EndsWith(".dll", .InvariantCultureIgnoreCase)) + { + String libPath = new .(); + libPath.Append(targetPath, 0, targetPath.Length - 4); + libPath.Append(".lib"); + mImpLibMap.Add(project, libPath); + } + } + + switch (QueueProjectCustomBuildCommands(project, targetPath, runAfter ? options.mBuildOptions.mBuildCommandsOnRun : options.mBuildOptions.mBuildCommandsOnCompile, options.mBuildOptions.mPostBuildCmds)) + { + case .NoCommands: + case .HadCommands: + case .Failed: + completedCompileCmd.mFailed = true; + } + + if (project.mGeneralOptions.mTargetType == .CustomBuild) + { + return true; + } + +#if IDE_C_SUPPORT + bool buildAll = false; + String buildStringFilePath = scope String(); + mDepClang.GetBuildStringFileName(projectBuildDir, project, buildStringFilePath); + String newBuildString = scope String(); + GetClangBuildString(project, options, workspaceOptions, true, newBuildString); + String clangBuildString = scope String(); + GetClangBuildString(project, options, workspaceOptions, false, clangBuildString); + newBuildString.Append("|", clangBuildString); + + if (mDepClang.mDoDependencyCheck) + { + String prependStr = scope String(); + options.mCOptions.mCompilerType.ToString(prependStr); + prependStr.Append("|"); + newBuildString.Insert(0, prependStr); + String oldBuildString; + mDepClang.mProjectBuildString.TryGetValue(project, out oldBuildString); + + if (oldBuildString == null) + { + oldBuildString = new String(); + File.ReadAllText(buildStringFilePath, oldBuildString).IgnoreError(); + mDepClang.mProjectBuildString[project] = oldBuildString; + } + + if (newBuildString != oldBuildString) + { + buildAll = true; + + if (case .Err = File.WriteAllText(buildStringFilePath, newBuildString)) + OutputLine("Failed to write {0}", buildStringFilePath); + + delete oldBuildString; + mDepClang.mProjectBuildString[project] = new String(newBuildString); + } + } + + using (mDepClang.mMonitor.Enter()) + { + if (options.mClangObjectFiles == null) + options.mClangObjectFiles = new List(); + else + ClearAndDeleteItems(options.mClangObjectFiles); + + for (var projectSource in allFileNames) + { + var fileEntry = mDepClang.GetProjectEntry(projectSource); + Debug.Assert((fileEntry != null) || (!mDepClang.mCompileWaitsForQueueEmpty)); + + String filePath = scope String(); + projectSource.GetFullImportPath(filePath); + String baseName = scope String(); + Path.GetFileNameWithoutExtension(filePath, baseName); + String objName = stack String(); + objName.Append(projectBuildDir, "/", baseName, (options.mCOptions.mGenerateLLVMAsm ? ".ll" : ".obj")); + + if (filePath.Contains("test2.cpp")) + { + NOP!(); + } + + bool needsRebuild = true; + if ((!buildAll) && (fileEntry != null)) + { + mDepClang.SetEntryObjFileName(fileEntry, objName); + mDepClang.SetEntryBuildStringFileName(fileEntry, buildStringFilePath); + needsRebuild = mDepClang.DoesEntryNeedRebuild(fileEntry); + } + if (needsRebuild) + { + if (hotProject != null) + { + OutputLine("Hot swap detected disallowed C/C++ change: {0}", filePath); + return false; + } + + project.mNeedsTargetRebuild = true; + var runCmd = CompileSource(project, workspaceOptions, options, filePath); + runCmd.mParallelGroup = 1; + } + + options.mClangObjectFiles.Add(new String(objName)); + + if (hotProject != null) + continue; + + clangAllObjNames.Add(objName); + + IdSpan sourceCharIdData; + String sourceCode = scope String(); + FindProjectSourceContent(projectSource, out sourceCharIdData, true, sourceCode); + mWorkspace.ProjectSourceCompiled(projectSource, sourceCode, sourceCharIdData); + sourceCharIdData.Dispose(); + + String* fileEntryPtr; + if (completedCompileCmd.mClangCompiledFiles.Add(filePath, out fileEntryPtr)) + *fileEntryPtr = new String(filePath); + } + } +#endif + + String llvmDir = scope String(IDEApp.sApp.mInstallDir); + IDEUtils.FixFilePath(llvmDir); + llvmDir.Append("llvm/"); + + if (hotProject != null) + { + if ((hotProject == project) || (hotProject.HasDependency(project.mProjectName))) + { + for (var fileName in bfFileNames) + hotFileNames.Add(new String(fileName)); + } + + return true; + } + + String objectsArg = scope String(); + var argBuilder = scope IDEApp.ArgBuilder(objectsArg, workspaceOptions.mToolsetType != .GNU); + for (var bfFileName in bfFileNames) + { + argBuilder.AddFileName(bfFileName); + argBuilder.AddSep(); + } + + for (var objName in clangAllObjNames) + { + IDEUtils.AppendWithOptionalQuotes(objectsArg, objName); + objectsArg.Append(" "); + } + + if (workspaceOptions.mToolsetType == .GNU) + { + if (!QueueProjectGNULink(project, targetPath, workspaceOptions, options, objectsArg)) + return false; + } + else // MS + { + if (!QueueProjectMSLink(project, targetPath, configSelection.mConfig, workspaceOptions, options, objectsArg)) + return false; + } + + return true; + } + } +} diff --git a/IDE/src/Clang/ClangCompiler.bf b/IDE/src/Clang/ClangCompiler.bf index 48d2749c..a4fa44c1 100644 --- a/IDE/src/Clang/ClangCompiler.bf +++ b/IDE/src/Clang/ClangCompiler.bf @@ -2,7 +2,6 @@ using System; using System.Collections.Generic; using System.Text; using System.Threading.Tasks; -using System.Runtime.InteropServices; using System.Diagnostics; using System.IO; using Beefy.widgets; diff --git a/IDE/src/Clang/ClangHelper.bf b/IDE/src/Clang/ClangHelper.bf index b03b6cd5..668bbafe 100644 --- a/IDE/src/Clang/ClangHelper.bf +++ b/IDE/src/Clang/ClangHelper.bf @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using System.Runtime.InteropServices; using Beefy.widgets; using IDE.Compiler; diff --git a/IDE/src/Compiler/BfCompiler.bf b/IDE/src/Compiler/BfCompiler.bf index b2cde9e3..48e465f2 100644 --- a/IDE/src/Compiler/BfCompiler.bf +++ b/IDE/src/Compiler/BfCompiler.bf @@ -2,7 +2,6 @@ using System; using System.Collections.Generic; using System.Text; using System.Threading.Tasks; -using System.Runtime.InteropServices; using System.Threading; using System.Diagnostics; using Beefy.widgets; diff --git a/IDE/src/Compiler/BfParser.bf b/IDE/src/Compiler/BfParser.bf index fed6e8af..34338aff 100644 --- a/IDE/src/Compiler/BfParser.bf +++ b/IDE/src/Compiler/BfParser.bf @@ -2,7 +2,6 @@ using System; using System.Collections.Generic; using System.Text; using System.Threading.Tasks; -using System.Runtime.InteropServices; using System.Diagnostics; using Beefy.widgets; using Beefy.utils; diff --git a/IDE/src/Compiler/BfPassInstance.bf b/IDE/src/Compiler/BfPassInstance.bf index 4f64fced..65684f4b 100644 --- a/IDE/src/Compiler/BfPassInstance.bf +++ b/IDE/src/Compiler/BfPassInstance.bf @@ -2,7 +2,6 @@ using System; using System.Collections.Generic; using System.Text; using System.Threading.Tasks; -using System.Runtime.InteropServices; using Beefy.utils; using System.Diagnostics; using System.Threading; diff --git a/IDE/src/Compiler/BfProject.bf b/IDE/src/Compiler/BfProject.bf index e180d011..815ee9d1 100644 --- a/IDE/src/Compiler/BfProject.bf +++ b/IDE/src/Compiler/BfProject.bf @@ -2,7 +2,6 @@ using System; using System.Collections.Generic; using System.Text; using System.Threading.Tasks; -using System.Runtime.InteropServices; using System.Diagnostics; namespace IDE.Compiler diff --git a/IDE/src/Compiler/BfResolvePassData.bf b/IDE/src/Compiler/BfResolvePassData.bf index b0880aeb..bc078f52 100644 --- a/IDE/src/Compiler/BfResolvePassData.bf +++ b/IDE/src/Compiler/BfResolvePassData.bf @@ -2,7 +2,6 @@ using System; using System.Collections.Generic; using System.Text; using System.Threading.Tasks; -using System.Runtime.InteropServices; namespace IDE.Compiler { diff --git a/IDE/src/Compiler/BfSystem.bf b/IDE/src/Compiler/BfSystem.bf index f29eee1c..15d49780 100644 --- a/IDE/src/Compiler/BfSystem.bf +++ b/IDE/src/Compiler/BfSystem.bf @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Text; using System.Threading; using System.Threading.Tasks; -using System.Runtime.InteropServices; using System.Diagnostics; namespace IDE.Compiler diff --git a/IDE/src/Debugger/Breakpoint.bf b/IDE/src/Debugger/Breakpoint.bf index 76278139..eda460a6 100644 --- a/IDE/src/Debugger/Breakpoint.bf +++ b/IDE/src/Debugger/Breakpoint.bf @@ -2,7 +2,6 @@ using System; using System.Collections.Generic; using System.Text; using System.Threading.Tasks; -using System.Runtime.InteropServices; using Beefy.gfx; using Beefy.theme.dark; using System.IO; diff --git a/IDE/src/Debugger/Callbacks.bf b/IDE/src/Debugger/Callbacks.bf index 77b3a7d9..e7c20c98 100644 --- a/IDE/src/Debugger/Callbacks.bf +++ b/IDE/src/Debugger/Callbacks.bf @@ -1,5 +1,4 @@ using System; -using System.Runtime.InteropServices; using IDE; namespace Debugger diff --git a/IDE/src/Debugger/DebugManager.bf b/IDE/src/Debugger/DebugManager.bf index bdf6f25d..bc6909c7 100644 --- a/IDE/src/Debugger/DebugManager.bf +++ b/IDE/src/Debugger/DebugManager.bf @@ -2,7 +2,6 @@ using System; using System.Collections.Generic; using System.Text; using System.Threading.Tasks; -using System.Runtime.InteropServices; using System.Diagnostics; using Beefy.utils; using IDE.util; diff --git a/IDE/src/Debugger/Profiler.bf b/IDE/src/Debugger/Profiler.bf index cbdd6fa9..e8f2492c 100644 --- a/IDE/src/Debugger/Profiler.bf +++ b/IDE/src/Debugger/Profiler.bf @@ -2,7 +2,6 @@ using System; using System.Collections.Generic; using System.Text; using System.Threading.Tasks; -using System.Runtime.InteropServices; using System.Diagnostics; using Beefy.utils; diff --git a/IDE/src/Debugger/StepFilter.bf b/IDE/src/Debugger/StepFilter.bf index 2f17c8e5..280cafb0 100644 --- a/IDE/src/Debugger/StepFilter.bf +++ b/IDE/src/Debugger/StepFilter.bf @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; diff --git a/IDE/src/IDEApp.bf b/IDE/src/IDEApp.bf index 644f4fdd..c78e3155 100644 --- a/IDE/src/IDEApp.bf +++ b/IDE/src/IDEApp.bf @@ -16,7 +16,6 @@ using Beefy.events; using Beefy.geom; using Beefy.res; using System.Diagnostics; -using System.Runtime.InteropServices; using Beefy.utils; using IDE.Debugger; using IDE.Compiler; @@ -207,6 +206,7 @@ namespace IDE public BfSystem mBfBuildSystem ~ delete _; public BfCompiler mBfBuildCompiler; public int mCompileSinceCleanCount; + public BuildContext mBuildContext ~ delete _; #if IDE_C_SUPPORT public ClangCompiler mDepClang ~ delete _; #endif @@ -237,6 +237,7 @@ namespace IDE public bool mTargetHadFirstBreak = false; public bool mTargetStartWithStep = false; public Breakpoint mMainBreakpoint; + public Breakpoint mMainBreakpoint2; public bool mInDisassemblyView; public bool mIsAttachPendingSourceShow; public bool mStepOverExternalFiles; @@ -326,12 +327,12 @@ namespace IDE DeferredOpenKind mDeferredOpen; String mDeferredOpenFileName; - class ExecutionCmd + public class ExecutionCmd { public bool mOnlyIfNotFailed; } - class BuildCompletedCmd : ExecutionCmd + public class BuildCompletedCmd : ExecutionCmd { public Stopwatch mStopwatch ~ delete _; public String mHotProjectName ~ delete _; @@ -369,24 +370,25 @@ namespace IDE public bool mWasCompiled; } - class TargetCompletedCmd : ExecutionCmd + public class TargetCompletedCmd : ExecutionCmd { + public Project mProject; + public bool mIsReady = true; + public this(Project project) { mProject = project; } - - public Project mProject; } - enum ArgsFileKind + public enum ArgsFileKind { None, UTF8, UTF16WithBom } - class ExecutionQueueCmd : ExecutionCmd + public class ExecutionQueueCmd : ExecutionCmd { public String mFileName ~ delete _; public String mArgs ~ delete _; @@ -395,7 +397,7 @@ namespace IDE public ArgsFileKind mUseArgsFile; public int32 mParallelGroup = -1; } - List mExecutionQueue = new List() ~ DeleteContainerAndItems!(_); + public List mExecutionQueue = new List() ~ DeleteContainerAndItems!(_); public class ExecutionInstance { @@ -451,7 +453,7 @@ namespace IDE { get { - return (mExecutionInstances.Count > 0) || (mExecutionQueue.Count > 0); + return (mExecutionInstances.Count > 0) || (mExecutionQueue.Count > 0) || (mBuildContext != null); } } @@ -785,6 +787,7 @@ namespace IDE let data = scope StructuredData(); if (data.Load(filePath) case .Err) { + CreateDefaultLayout(); OutputErrorLine("Failed to load debug session '{}'", filePath); return; } @@ -1829,17 +1832,21 @@ namespace IDE SaveFileDialog dialog = scope .(); let activeWindow = GetActiveWindow(); + let workspaceOptions = GetCurWorkspaceOptions(); let options = GetCurProjectOptions(project); if (!options.mDebugOptions.mCommand.IsWhiteSpace) { + String execCmd = scope .(); + ResolveConfigString(workspaceOptions, project, options, options.mDebugOptions.mCommand, "command", execCmd); + String initialDir = scope .(); - Path.GetDirectoryPath(options.mDebugOptions.mCommand, initialDir); + Path.GetDirectoryPath(execCmd, initialDir); dialog.InitialDirectory = initialDir; dialog.SetFilter("Debug Session (*.bfdbg)|*.bfdbg"); dialog.DefaultExt = ".bfdbg"; String fileName = scope .(); - Path.GetFileName(options.mDebugOptions.mCommand, fileName); + Path.GetFileNameWithoutExtension(execCmd, fileName); if (!fileName.IsEmpty) { fileName.Append(".bfdbg"); @@ -4045,9 +4052,14 @@ namespace IDE if (var processBfCompileCmd = cmd as ProcessBfCompileCmd) { + } + else if (var buildCompleteCmd = cmd as BuildCompletedCmd) + { + } else { + delete cmd; @cmd.Remove(); } } @@ -4057,6 +4069,9 @@ namespace IDE executionInstance.Cancel(); } } + + if ((mBuildContext != null) && (mBuildContext.mScriptManager != null)) + mBuildContext.mScriptManager.Cancel(); } TabbedView FindTabbedView(DockingFrame dockingFrame, int32 xDir, int32 yDir) @@ -6274,6 +6289,14 @@ namespace IDE } else mWorkspace.mDir = fullDir; + case "-open": + String.NewOrSet!(mDeferredOpenFileName, value); + if (mDeferredOpenFileName.EndsWith(".bfdbg", .OrdinalIgnoreCase)) + mDeferredOpen = .DebugSession; + else if (mDeferredOpenFileName.EndsWith(".dmp", .OrdinalIgnoreCase)) + mDeferredOpen = .CrashDump; + else + mDeferredOpen = .File; default: return false; } @@ -6828,7 +6851,7 @@ namespace IDE return null; } - void GetClangFiles(ProjectFolder projectFolder, List clangFiles) + public void GetClangFiles(ProjectFolder projectFolder, List clangFiles) { for (var item in projectFolder.mChildItems) { @@ -6866,7 +6889,7 @@ namespace IDE const int cArgFileThreshold = 0x7800; - ExecutionQueueCmd QueueRun(String fileName, String args, String workingDir, ArgsFileKind argsFileKind = .None) + public ExecutionQueueCmd QueueRun(String fileName, String args, String workingDir, ArgsFileKind argsFileKind = .None) { var executionQueueCmd = new ExecutionQueueCmd(); executionQueueCmd.mFileName = new String(fileName); @@ -7179,7 +7202,21 @@ namespace IDE #endif if ((next is ProcessBfCompileCmd) && (mBfBuildCompiler.HasQueuedCommands() || (waitForBuildClang))) return; - defer(scope) delete next; + /*if (next is BuildCompletedCmd) + { + if (mBuildContext != null) + return; + }*/ + if (let targetCompletedCmd = next as TargetCompletedCmd) + { + if ((mBuildContext == null) || (!mBuildContext.Failed)) + { + if (!targetCompletedCmd.mIsReady) + return; + } + } + + defer delete next; mExecutionQueue.RemoveAt(0); bool ignoreCommand = false; @@ -7244,6 +7281,7 @@ namespace IDE { var targetCompletedCmd = (TargetCompletedCmd)next; targetCompletedCmd.mProject.mNeedsTargetRebuild = false; + targetCompletedCmd.mProject.mForceCustomCommands = false; } else if (next is StartDebugCmd) { @@ -7281,6 +7319,11 @@ namespace IDE if (!completedCompileCmd.mFailed) mDepClang.mDoDependencyCheck = false; #endif + if (mBuildContext != null) + { + if (mBuildContext.Failed) + buildCompletedCmd.mFailed = true; + } CompileResult(buildCompletedCmd.mHotProjectName, !buildCompletedCmd.mFailed); @@ -7966,39 +8009,6 @@ namespace IDE return passInstance; } - void GetRtLibNames(Workspace.Options workspaceOptions, Project.Options options, bool dynName, String outRt, String outDbg) - { - if ((!dynName) || (options.mBuildOptions.mBeefLibType != .Static)) - { - outRt.Append("Beef", sRTVersionStr, "RT"); - outRt.Append((workspaceOptions.mMachineType == .x86) ? "32" : "64"); - switch (options.mBuildOptions.mBeefLibType) - { - case .Dynamic: - case .DynamicDebug: outRt.Append("_d"); - case .Static: - switch (options.mBuildOptions.mCLibType) - { - case .None: - case .Dynamic, .SystemMSVCRT: outRt.Append("_s"); - case .DynamicDebug: outRt.Append("_sd"); - case .Static: outRt.Append("_ss"); - case .StaticDebug: outRt.Append("_ssd"); - } - } - outRt.Append(dynName ? ".dll" : ".lib"); - } - - if ((workspaceOptions.mEnableObjectDebugFlags) || (workspaceOptions.mAllocType == .Debug)) - { - outDbg.Append("Beef", sRTVersionStr, "Dbg"); - outDbg.Append((workspaceOptions.mMachineType == .x86) ? "32" : "64"); - if (options.mBuildOptions.mBeefLibType == .DynamicDebug) - outDbg.Append("_d"); - outDbg.Append(dynName ? ".dll" : ".lib"); - } - } - public bool DoResolveConfigString(Workspace.Options workspaceOptions, Project project, Project.Options options, StringView configString, String error, String result) { int i = result.Length; @@ -8052,9 +8062,11 @@ namespace IDE DoResolveConfigString(workspaceOptions, project, options, options.mBuildOptions.mTargetName, error, newString); #if BF_PLATFORM_WINDOWS - if (project.mGeneralOptions.mTargetType == Project.TargetType.BeefLib) + if (project.mGeneralOptions.mTargetType == .BeefLib) newString.Append(".lib"); - else if (project.mGeneralOptions.mTargetType != Project.TargetType.CustomBuild) + else if (project.mGeneralOptions.mTargetType == .BeefDynLib) + newString.Append(".dll"); + else if (project.mGeneralOptions.mTargetType != .CustomBuild) newString.Append(".exe"); #else if (project.mGeneralOptions.mTargetType == Project.TargetType.BeefLib) @@ -8062,7 +8074,13 @@ namespace IDE #endif } case "ProjectDir": - newString = project.mProjectDir; + if (project.IsDebugSession) + { + newString = scope:: String(); + Path.GetDirectoryPath(project.mProjectPath, newString); + } + else + newString = project.mProjectDir; case "BuildDir": newString = scope:: String(); GetProjectBuildDir(project, newString); @@ -8072,7 +8090,7 @@ namespace IDE #if BF_PLATFORM_WINDOWS String rtName = scope String(); String dbgName = scope String(); - GetRtLibNames(workspaceOptions, options, false, rtName, dbgName); + BuildContext.GetRtLibNames(workspaceOptions, options, false, rtName, dbgName); newString.Append(rtName); if (!dbgName.IsEmpty) newString.Append(" ", dbgName); @@ -8118,14 +8136,18 @@ namespace IDE { case "Configuration": newString = mConfigName; - break; case "Platform": newString = mPlatformName; - break; case "WorkspaceDir": if (mWorkspace.mDir != null) newString = mWorkspace.mDir; - break; + else if (project.IsDebugSession) + { + newString = scope:: String(); + Path.GetDirectoryPath(project.mProjectPath, newString); + } + case "BeefPath": + newString = gApp.mInstallDir; default: } } @@ -8425,238 +8447,6 @@ namespace IDE #endif } - bool QueueProjectGNULink(Project project, String targetPath, Workspace.Options workspaceOptions, Project.Options options, String objectsArg) - { - bool isDebug = mConfigName.IndexOf("Debug", true) != -1; - -#if BF_PLATFORM_WINDOWS - String llvmDir = scope String(IDEApp.sApp.mInstallDir); - IDEUtils.FixFilePath(llvmDir); - llvmDir.Append("llvm/"); -#else - String llvmDir = ""; -#endif - - //String error = scope String(); - - bool isExe = project.mGeneralOptions.mTargetType != Project.TargetType.BeefLib; - if (isExe) - { - String linkLine = scope String(isDebug ? "-g " : "-g -O2 "); //-O2 -Rpass=inline - //(doClangCPP ? "-lc++abi " : "") + - - linkLine.Append("-o "); - IDEUtils.AppendWithOptionalQuotes(linkLine, targetPath); - linkLine.Append(" "); - - /*if (options.mBuildOptions.mLinkerType == Project.LinkerType.GCC) - { - // ... - } - else - { - linkLine.Append("--target="); - GetTargetName(workspaceOptions, linkLine); - linkLine.Append(" "); - }*/ - - if ((project.mGeneralOptions.mTargetType == Project.TargetType.BeefWindowsApplication) || - (project.mGeneralOptions.mTargetType == Project.TargetType.C_WindowsApplication)) - { - linkLine.Append("-mwindows "); - } - - linkLine.Append("-no-pie "); - - linkLine.Append(objectsArg); - - //var destDir = scope String(); - //Path.GetDirectoryName(); - - //TODO: Make an option - if (options.mBuildOptions.mCLibType == Project.CLibType.Static) - { - linkLine.Append("-static-libgcc -static-libstdc++ "); - } - else - { -#if BF_PLATFORM_WINDOWS - String[] mingwFiles; - String fromDir; - if (workspaceOptions.mMachineType == Workspace.MachineType.x86) - { - fromDir = scope:: String(llvmDir, "i686-w64-mingw32/bin/"); - mingwFiles = scope:: String[] { "libgcc_s_dw2-1.dll", "libstdc++-6.dll" }; - } - else - { - fromDir = scope:: String(llvmDir, "x86_64-w64-mingw32/bin/"); - mingwFiles = scope:: String[] { "libgcc_s_seh-1.dll", "libstdc++-6.dll", "libwinpthread-1.dll" }; - } - for (var mingwFile in mingwFiles) - { - String fromPath = scope String(fromDir, mingwFile); - //string toPath = projectBuildDir + "/" + mingwFile; - String toPath = scope String(); - Path.GetDirectoryPath(targetPath, toPath); - toPath.Append("/", mingwFile); - if (!File.Exists(toPath)) - { - if (File.Copy(fromPath, toPath) case .Err) - { - OutputLineSmart("ERROR: Failed to copy mingw file {0}", fromPath); - return false; - } - } - } -#endif - } - - List depProjectList = scope List(); - GetDependentProjectList(project, depProjectList); - if (depProjectList.Count > 0) - { - for (var dep in project.mDependencies) - { - var depProject = mWorkspace.FindProject(dep.mProjectName); - if (depProject == null) - { - OutputLine("Failed to locate dependent library: {0}", dep.mProjectName); - return false; - } - else - { - /*if (depProject.mNeedsTargetRebuild) - project.mNeedsTargetRebuild = true;*/ - - var depOptions = GetCurProjectOptions(depProject); - - if (depOptions.mClangObjectFiles != null) - { - var argBuilder = scope ArgBuilder(linkLine, true); - - for (var fileName in depOptions.mClangObjectFiles) - { - //AppendWithOptionalQuotes(linkLine, fileName); - argBuilder.AddFileName(fileName); - argBuilder.AddSep(); - } - } - - - /*String depLibTargetPath = scope String(); - ResolveConfigString(depProject, depOptions, "$(TargetPath)", error, depLibTargetPath); - IDEUtils.FixFilePath(depLibTargetPath); - - String depDir = scope String(); - Path.GetDirectoryName(depLibTargetPath, depDir); - String depFileName = scope String(); - Path.GetFileNameWithoutExtension(depLibTargetPath, depFileName); - - AppendWithOptionalQuotes(linkLine, depLibTargetPath); - linkLine.Append(" ");*/ - } - } - } - -#if BF_PLATFORM_WINDOWS - String gccExePath = "c:/mingw/bin/g++.exe"; - String clangExePath = scope String(llvmDir, "bin/clang++.exe"); -#else - String gccExePath = "/usr/bin/c++"; - String clangExePath = scope String("/usr/bin/c++"); -#endif - - if (project.mNeedsTargetRebuild) - { - if (File.Delete(targetPath) case .Err) - { - OutputLine("Failed to delete {0}", targetPath); - return false; - } - - if (workspaceOptions.mToolsetType == .GNU) - { - if (workspaceOptions.mMachineType == Workspace.MachineType.x86) - { - } - else - { - IDEUtils.AppendWithOptionalQuotes(linkLine, scope String("-L", llvmDir, "/x86_64-w64-mingw32/lib")); - linkLine.Append(" "); - IDEUtils.AppendWithOptionalQuotes(linkLine, scope String("-L", llvmDir, "/lib/gcc/x86_64-w64-mingw32/5.2.0")); - linkLine.Append(" "); - } - } - else // Microsoft - { - if (workspaceOptions.mMachineType == Workspace.MachineType.x86) - { - //linkLine.Append("-L\"C:\\Program Files (x86)\\Windows Kits\\10\\Lib\\10.0.10586.0\\ucrt\\x86\" "); - for (var libPath in mSettings.mVSSettings.mLib32Paths) - { - linkLine.AppendF("-L\"{0}\" ", libPath); - } - } - else - { - /*linkLine.Append("-L\"C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\lib\\amd64\" "); - linkLine.Append("-L\"C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\atlmfc\\lib\\amd64\" "); - linkLine.Append("-L\"C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.14393.0\\ucrt\\x64\" "); - linkLine.Append("-L\"C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.14393.0\\um\\x64\" ");*/ - for (var libPath in mSettings.mVSSettings.mLib64Paths) - { - linkLine.AppendF("-L\"{0}\" ", libPath); - } - } - } - - if (options.mBuildOptions.mOtherLinkFlags.Length != 0) - { - var linkFlags = scope String(); - ResolveConfigString(workspaceOptions, project, options, options.mBuildOptions.mOtherLinkFlags, "link flags", linkFlags); - linkLine.Append(linkFlags, " "); - } - - String compilerExePath = (workspaceOptions.mToolsetType == .GNU) ? gccExePath : clangExePath; - String workingDir = scope String(); - if (!llvmDir.IsEmpty) - { - workingDir.Append(llvmDir, "bin"); - } - else - { - workingDir.Append(mInstallDir); - } - - var runCmd = QueueRun(compilerExePath, linkLine, workingDir, .UTF8); - runCmd.mOnlyIfNotFailed = true; - var tagetCompletedCmd = new TargetCompletedCmd(project); - tagetCompletedCmd.mOnlyIfNotFailed = true; - mExecutionQueue.Add(tagetCompletedCmd); - - String logStr = scope String(); - logStr.AppendF("IDE Process {0}\r\n", Platform.BfpProcess_GetCurrentId()); - logStr.Append(linkLine); - String targetLogPath = scope String(targetPath, ".build.txt"); - Utils.WriteTextFile(targetLogPath, logStr); - - project.mLastDidBuild = true; - } - } - - return true; - } - - void GetPdbPath(String targetPath, Workspace.Options workspaceOptions, Project.Options options, String outPdbPath) - { - int lastDotPos = targetPath.LastIndexOf('.'); - outPdbPath.Append(targetPath, 0, lastDotPos); - if (workspaceOptions.mToolsetType == .LLVM) - outPdbPath.Append("_lld"); - outPdbPath.Append(".pdb"); - } - void GetTargetPaths(Project project, Workspace.Options workspaceOptions, Project.Options options, List outPaths) { String targetPath = scope String(); @@ -8670,379 +8460,14 @@ namespace IDE if (workspaceOptions.mToolsetType != .GNU) { String pdbPath = scope String(); - GetPdbPath(targetPath, workspaceOptions, options, pdbPath); + BuildContext.GetPdbPath(targetPath, workspaceOptions, options, pdbPath); outPaths.Add(new String(pdbPath)); } } #endif } - bool QueueProjectMSLink(Project project, String targetPath, String configName, Workspace.Options workspaceOptions, Project.Options options, String objectsArg) - { - String llvmDir = scope String(IDEApp.sApp.mInstallDir); - IDEUtils.FixFilePath(llvmDir); - llvmDir.Append("llvm/"); - - TestManager.ProjectInfo testProjectInfo = null; - if (mTestManager != null) - testProjectInfo = mTestManager.GetProjectInfo(project); - - bool isExe = (project.mGeneralOptions.mTargetType != Project.TargetType.BeefLib) || (testProjectInfo != null); - if (isExe) - { - String linkLine = scope String(); - - linkLine.Append("-out:"); - IDEUtils.AppendWithOptionalQuotes(linkLine, targetPath); - linkLine.Append(" "); - - if (testProjectInfo != null) - linkLine.Append("-subsystem:console "); - else if (project.mGeneralOptions.mTargetType == Project.TargetType.BeefWindowsApplication) - linkLine.Append("-subsystem:windows "); - else if (project.mGeneralOptions.mTargetType == Project.TargetType.C_WindowsApplication) - linkLine.Append("-subsystem:console "); - - linkLine.Append(objectsArg); - - //var destDir = scope String(); - //Path.GetDirectoryName(); - - //TODO: Allow selecting lib file. Check date when copying instead of just ALWAYS copying... - LibBlock: - { - List stdLibFileNames = scope .(2); - String fromDir; - - fromDir = scope String(mInstallDir); - - bool AddLib(String dllName) - { - stdLibFileNames.Add(dllName); - - String fromPath = scope String(fromDir, dllName); - String toPath = scope String(); - Path.GetDirectoryPath(targetPath, toPath); - toPath.Append("/", dllName); - if (File.CopyIfNewer(fromPath, toPath) case .Err) - { - OutputLine("Failed to copy lib file {0}", fromPath); - return false; - } - return true; - } - - String rtName = scope String(); - String dbgName = scope String(); - GetRtLibNames(workspaceOptions, options, true, rtName, dbgName); - if (!rtName.IsEmpty) - if (!AddLib(rtName)) - return false; - if (!dbgName.IsEmpty) - if (!AddLib(dbgName)) - return false; - switch (workspaceOptions.mAllocType) - { - case .JEMalloc: - if (!AddLib("jemalloc.dll")) - return false; - default: - } - } - - List depProjectList = scope List(); - GetDependentProjectList(project, depProjectList); - if (depProjectList.Count > 0) - { - for (var dep in project.mDependencies) - { - var depProject = mWorkspace.FindProject(dep.mProjectName); - if (depProject == null) - { - OutputLine("Failed to locate dependent library: {0}", dep.mProjectName); - return false; - } - else - { - /*if (depProject.mNeedsTargetRebuild) - project.mNeedsTargetRebuild = true;*/ - - var depOptions = GetCurProjectOptions(depProject); - if (depOptions != null) - { - if (depOptions.mClangObjectFiles != null) - { - var argBuilder = scope ArgBuilder(linkLine, true); - - for (var fileName in depOptions.mClangObjectFiles) - { - //AppendWithOptionalQuotes(linkLine, fileName); - argBuilder.AddFileName(fileName); - argBuilder.AddSep(); - } - } - } - - - /*String depLibTargetPath = scope String(); - ResolveConfigString(depProject, depOptions, "$(TargetPath)", error, depLibTargetPath); - IDEUtils.FixFilePath(depLibTargetPath); - - String depDir = scope String(); - Path.GetDirectoryName(depLibTargetPath, depDir); - String depFileName = scope String(); - Path.GetFileNameWithoutExtension(depLibTargetPath, depFileName); - - AppendWithOptionalQuotes(linkLine, depLibTargetPath); - linkLine.Append(" ");*/ - } - } - } - - if (project.mNeedsTargetRebuild) - { - /*if (File.Delete(targetPath).Failed(true)) - { - OutputLine("Failed to delete {0}", targetPath); - return false; - }*/ - - switch (options.mBuildOptions.mCLibType) - { - case .None: - linkLine.Append("-nodefaultlib "); - case .Dynamic: - //linkLine.Append((workspaceOptions.mMachineType == .x86) ? "-defaultlib:msvcprt " : "-defaultlib:msvcrt "); - linkLine.Append("-defaultlib:msvcrt "); - case .Static: - //linkLine.Append((workspaceOptions.mMachineType == .x86) ? "-defaultlib:libcpmt " : "-defaultlib:libcmt "); - linkLine.Append("-defaultlib:libcmt "); - case .DynamicDebug: - //linkLine.Append((workspaceOptions.mMachineType == .x86) ? "-defaultlib:msvcprtd " : "-defaultlib:msvcrtd "); - linkLine.Append("-defaultlib:msvcrtd "); - case .StaticDebug: - //linkLine.Append((workspaceOptions.mMachineType == .x86) ? "-defaultlib:libcpmtd " : "-defaultlib:libcmtd "); - linkLine.Append("-defaultlib:libcmtd "); - case .SystemMSVCRT: - linkLine.Append("-nodefaultlib "); - - String minRTModName = scope String(); - if ((project.mGeneralOptions.mTargetType == .BeefWindowsApplication) || - (project.mGeneralOptions.mTargetType == .C_WindowsApplication)) - minRTModName.Append("g"); - if (options.mBuildOptions.mBeefLibType == .DynamicDebug) - minRTModName.Append("d"); - if (!minRTModName.IsEmpty) - minRTModName.Insert(0, "_"); - - if (workspaceOptions.mMachineType == .x86) - linkLine.Append(mInstallDir, @"lib\x86\msvcrt.lib Beef", sRTVersionStr,"MinRT32", minRTModName, ".lib "); - else - linkLine.Append(mInstallDir, @"lib\x64\msvcrt.lib Beef", sRTVersionStr,"MinRT64", minRTModName, ".lib "); - linkLine.Append("ntdll.lib user32.lib kernel32.lib gdi32.lib winmm.lib shell32.lib ole32.lib rpcrt4.lib chkstk.obj -ignore:4049 -ignore:4217 "); - } - linkLine.Append("-nologo "); - //linkLine.Append("-fixed "); - - // Incremental just seems to be slower for Beef. Test on larger projects to verify - linkLine.Append("-incremental:no "); - - if (options.mBuildOptions.mStackSize > 0) - linkLine.AppendF("-stack:{} ", options.mBuildOptions.mStackSize); - - linkLine.Append("-pdb:"); - let pdbName = scope String(); - GetPdbPath(targetPath, workspaceOptions, options, pdbName); - IDEUtils.AppendWithOptionalQuotes(linkLine, pdbName); - linkLine.Append(" "); - - //TODO: Only add -debug if we have some debug info? - //if (isDebug) - if (workspaceOptions.mEmitDebugInfo != .No) - linkLine.Append("-debug "); - - if (workspaceOptions.mBfOptimizationLevel.IsOptimized()) - //linkLine.Append("-opt:ref -verbose "); - linkLine.Append("-opt:ref "); - else - linkLine.Append("-opt:noref "); - - if (workspaceOptions.mMachineType == .x86) - { - //linkLine.Append("-libpath:\"C:\\Program Files (x86)\\Windows Kits\\10\\Lib\\10.0.10586.0\\ucrt\\x86\" "); - for (var libPath in mSettings.mVSSettings.mLib32Paths) - { - linkLine.AppendF("-libpath:\"{0}\" ", libPath); - } - linkLine.Append("-libpath:\"", mInstallDir, "lib\\x86\" "); - } - else - { - /*linkLine.Append("-libpath:\"C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\lib\\amd64\" "); - linkLine.Append("-libpath:\"C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\atlmfc\\lib\\amd64\" "); - linkLine.Append("-libpath:\"C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.14393.0\\ucrt\\x64\" "); - linkLine.Append("-libpath:\"C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.14393.0\\um\\x64\" ");*/ - for (var libPath in mSettings.mVSSettings.mLib64Paths) - { - linkLine.AppendF("-libpath:\"{0}\" ", libPath); - } - linkLine.Append("-libpath:\"", mInstallDir, "lib\\x64\" "); - } - - String targetDir = scope String(); - Path.GetDirectoryPath(targetPath, targetDir); - linkLine.Append("-libpath:"); - IDEUtils.AppendWithOptionalQuotes(linkLine, targetDir); - linkLine.Append(" "); - - if (options.mBuildOptions.mOtherLinkFlags.Length != 0) - { - var linkFlags = scope String(); - ResolveConfigString(workspaceOptions, project, options, options.mBuildOptions.mOtherLinkFlags, "link flags", linkFlags); - linkLine.Append(linkFlags, " "); - } - - let winOptions = project.mWindowsOptions; - /*if (!String.IsNullOrWhiteSpace(project.mWindowsOptions.mManifestFile)) - { - String manifestPath = scope String(); - String error = scope String(); - ResolveConfigString(project, options, winOptions.mManifestFile, error, manifestPath); - if (!manifestPath.IsWhiteSpace) - { - linkLine.Append("/MANIFEST:EMBED /MANIFESTINPUT:"); - IDEUtils.AppendWithOptionalQuotes(linkLine, manifestPath); - linkLine.Append(" "); - } - }*/ - - // Put back - if ((!String.IsNullOrWhiteSpace(project.mWindowsOptions.mIconFile)) || - (!String.IsNullOrWhiteSpace(project.mWindowsOptions.mManifestFile)) || - (winOptions.HasVersionInfo())) - { - String projectBuildDir = scope String(); - GetProjectBuildDir(project, projectBuildDir); - - String resOutPath = scope String(); - resOutPath.Append(projectBuildDir, "\\Resource.res"); - - String iconPath = scope String(); - ResolveConfigString(workspaceOptions, project, options, winOptions.mIconFile, "icon file", iconPath); - - // Generate resource - Result CreateResourceFile() - { - ResourceGen resGen = scope ResourceGen(); - if (resGen.Start(resOutPath) case .Err) - { - OutputErrorLine("Failed to create resource file '{0}'", resOutPath); - return .Err; - } - if (!iconPath.IsWhiteSpace) - { - Path.GetAbsolutePath(scope String(iconPath), project.mProjectDir, iconPath..Clear()); - if (resGen.AddIcon(iconPath) case .Err) - { - OutputErrorLine("Failed to add icon"); - return .Err; - } - } - - let targetFileName = scope String(); - Path.GetFileName(targetPath, targetFileName); - - if (resGen.AddVersion(winOptions.mDescription, winOptions.mComments, winOptions.mCompany, winOptions.mProduct, - winOptions.mCopyright, winOptions.mFileVersion, winOptions.mProductVersion, targetFileName) case .Err) - { - OutputErrorLine("Failed to add version"); - return .Err; - } - - String manifestPath = scope String(); - ResolveConfigString(workspaceOptions, project, options, winOptions.mManifestFile, "manifest file", manifestPath); - if (!manifestPath.IsWhiteSpace) - { - Path.GetAbsolutePath(scope String(manifestPath), project.mProjectDir, manifestPath..Clear()); - if (resGen.AddManifest(manifestPath) case .Err) - { - OutputErrorLine("Failed to add manifest file"); - return .Err; - } - } - - Try!(resGen.Finish()); - return .Ok; - } - - if (CreateResourceFile() case .Err) - { - OutputErrorLine("Failed to generate resource file: {0}", resOutPath); - return false; - } - - IDEUtils.AppendWithOptionalQuotes(linkLine, resOutPath); - } - - - //String linkerPath = "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\bin\\amd64\\link.exe"; - - let binPath = (workspaceOptions.mMachineType == .x86) ? mSettings.mVSSettings.mBin32Path : mSettings.mVSSettings.mBin64Path; - if (binPath.IsWhiteSpace) - { - OutputErrorLine("Visual Studio tool path not configured. Check Visual Studio configuration in File\\Preferences\\Settings."); - return false; - } - - String linkerPath = scope String(); - linkerPath.Append(binPath); - linkerPath.Append("/link.exe"); - if (workspaceOptions.mToolsetType == .LLVM) - { - linkerPath.Clear(); - linkerPath.Append(mInstallDir); - linkerPath.Append(@"llvm\bin\lld-link.exe"); - //linkerPath = @"C:\Program Files\LLVM\bin\lld-link.exe"; - - var ltoType = workspaceOptions.mLTOType; - if (options.mBeefOptions.mLTOType != null) - ltoType = options.mBeefOptions.mLTOType.Value; - - if (ltoType == .Thin) - { - linkLine.Append(" /lldltocache:"); - - String ltoPath = scope String(); - Path.GetDirectoryPath(targetPath, ltoPath); - ltoPath.Append("/ltocache"); - IDEUtils.AppendWithOptionalQuotes(linkLine, ltoPath); - } - } - //String linkerPath = "C:\\Beef\\IDE\\dist\\BeefLink.exe"; - - //QueueRun(compilerExePath, linkLine, @"c:\mingw\bin", (options.mGeneralOptions.mLinkerType == Project.LinkerType.Clang) && (linkLine.Length > 1024)); - //QueueRun(compilerExePath, linkLine, @"c:\mingw\bin", (linkLine.Length > 1024)); - - var runCmd = QueueRun(linkerPath, linkLine, mInstallDir, .UTF16WithBom); - runCmd.mOnlyIfNotFailed = true; - var tagetCompletedCmd = new TargetCompletedCmd(project); - tagetCompletedCmd.mOnlyIfNotFailed = true; - mExecutionQueue.Add(tagetCompletedCmd); - - String logStr = scope String(); - logStr.AppendF("IDE Process {0}\r\n", Platform.BfpProcess_GetCurrentId()); - logStr.Append(linkLine); - String targetLogPath = scope String(targetPath, ".build.txt"); - Utils.WriteTextFile(targetLogPath, logStr); - - project.mLastDidBuild = true; - } - } - - return true; - } - - class ArgBuilder + public class ArgBuilder { String mTarget; bool mDoLongBreak; @@ -9100,367 +8525,12 @@ namespace IDE } } - bool QueueProjectCustomBuildCommands(Project project, String targetPath, Project.BuildCommandTrigger trigger, List cmdList) - { - if (cmdList.IsEmpty) - return true; - - if (trigger == .Never) - return true; - - if (trigger == .IfFilesChanged) - { - int64 highestDateTime = 0; - - int64 targetDateTime = File.GetLastWriteTime(targetPath).Get().ToFileTime(); - - bool forceRebuild = false; - - for (var depName in project.mDependencies) - { - var depProject = mWorkspace.FindProject(depName.mProjectName); - if (depProject != null) - { - if (depProject.mLastDidBuild) - forceRebuild = true; - } - } - - project.WithProjectItems(scope [&] (projectItem) => - { - var projectSource = projectItem as ProjectSource; - var importPath = scope String(); - projectSource.GetFullImportPath(importPath); - Result fileDateTime = File.GetLastWriteTime(importPath); - if (fileDateTime case .Ok) - { - let date = fileDateTime.Get().ToFileTime(); - /*if (date > targetDateTime) - Console.WriteLine("Custom build higher time: {0}", importPath);*/ - highestDateTime = Math.Max(highestDateTime, date); - } - }); - - if ((highestDateTime <= targetDateTime) && (!forceRebuild)) - return true; - - project.mLastDidBuild = true; - } - - Workspace.Options workspaceOptions = GetCurWorkspaceOptions(); - Project.Options options = GetCurProjectOptions(project); - - //Console.WriteLine("Executing custom command {0} {1} {2}", highestDateTime, targetDateTime, forceRebuild); - for (let origCustomCmd in cmdList) - { - var exePath = scope String(); - String customCmd = scope String(); - ResolveConfigString(workspaceOptions, project, options, origCustomCmd, "custom command", customCmd); - int spacePos; - if (customCmd.StartsWith("\"")) - { - spacePos = customCmd.IndexOf('"', 1) + 1; - if (spacePos != -1) - exePath.Append(customCmd, 1, spacePos - 2); - } - else - { - spacePos = customCmd.IndexOf(' '); - if (spacePos != -1) - exePath.Append(customCmd, 0, spacePos); - } - - if ((spacePos == -1) && (!customCmd.IsEmpty)) - { - OutputErrorLine("Invalid custom command '{0}' in project '{1}'", customCmd, project.mProjectName); - return false; - } - - if (spacePos > 0) - { - project.mNeedsTargetRebuild = true; - var exeArgs = scope String(); - exeArgs.Append(customCmd, spacePos + 1); - QueueRun(exePath, exeArgs, IDEApp.sApp.mInstallDir); - mExecutionQueue.Add(new TargetCompletedCmd(project)); - } - } - - return true; - } - - bool QueueProjectCompile(Project project, Project hotProject, BuildCompletedCmd completedCompileCmd, List hotFileNames, bool runAfter) - { - project.mLastDidBuild = false; - - TestManager.ProjectInfo testProjectInfo = null; - if (mTestManager != null) - testProjectInfo = mTestManager.GetProjectInfo(project); - - var configSelection = GetCurConfigSelection(project); - Project.Options options = GetCurProjectOptions(project); - if (options == null) - return true; - - Workspace.Options workspaceOptions = GetCurWorkspaceOptions(); - BfCompiler bfCompiler = mBfBuildCompiler; - var bfProject = mBfBuildSystem.mProjectMap[project]; - bool bfHadOutputChanges; - List bfFileNames = scope List(); - bfCompiler.GetOutputFileNames(bfProject, true, out bfHadOutputChanges, bfFileNames); - defer ClearAndDeleteItems(bfFileNames);//DeleteAndClearItems!(bfFileNames); - if (bfHadOutputChanges) - project.mNeedsTargetRebuild = true; - - List allFileNames = scope List(); - List clangAllObjNames = scope List(); - //List clangObjNames = scope List(); - - GetClangFiles(project.mRootFolder, allFileNames); - - String workspaceBuildDir = scope String(); - GetWorkspaceBuildDir(workspaceBuildDir); - String projectBuildDir = scope String(); - GetProjectBuildDir(project, projectBuildDir); - if (!projectBuildDir.IsEmpty) - Directory.CreateDirectory(projectBuildDir).IgnoreError(); - - //List buildFileNames = new List(); - - String targetPath = scope String(); - - String outputDir = scope String(); - String absOutputDir = scope String(); - - if (testProjectInfo != null) - { - absOutputDir.Append(projectBuildDir); - outputDir = absOutputDir; - targetPath.Append(outputDir, "/", project.mProjectName); -#if BF_PLATFORM_WINDOWS - targetPath.Append(".exe"); -#endif - - Debug.Assert(testProjectInfo.mTestExePath == null); - testProjectInfo.mTestExePath = new String(targetPath); - } - else - { - ResolveConfigString(workspaceOptions, project, options, options.mBuildOptions.mTargetDirectory, "target directory", outputDir); - Path.GetAbsolutePath(project.mProjectDir, outputDir, absOutputDir); - outputDir = absOutputDir; - ResolveConfigString(workspaceOptions, project, options, "$(TargetPath)", "target path", targetPath); - } - IDEUtils.FixFilePath(targetPath); - if (!File.Exists(targetPath)) - { - project.mNeedsTargetRebuild = true; - - String targetDir = scope String(); - Path.GetDirectoryPath(targetPath, targetDir); - if (!targetDir.IsEmpty) - Directory.CreateDirectory(targetDir).IgnoreError(); - } - - if (!QueueProjectCustomBuildCommands(project, targetPath, runAfter ? options.mBuildOptions.mBuildCommandsOnRun : options.mBuildOptions.mBuildCommandsOnCompile, options.mBuildOptions.mPostBuildCmds)) - completedCompileCmd.mFailed = true; - - if (project.mGeneralOptions.mTargetType == Project.TargetType.CustomBuild) - { - /*if (options.mBuildOptions.mPostBuildCmds.IsEmpty) - return true; - - int64 highestDateTime = 0; - - int64 targetDateTime = File.GetLastWriteTime(targetPath).Get().ToFileTime(); - - bool forceRebuild = false; - - for (var depName in project.mDependencies) - { - var depProject = mWorkspace.FindProject(depName.mProjectName); - if (depProject != null) - { - if (depProject.mLastDidBuild) - forceRebuild = true; - } - } - - project.WithProjectItems(scope [&] (projectItem) => - { - var projectSource = projectItem as ProjectSource; - var importPath = scope String(); - projectSource.GetFullImportPath(importPath); - Result fileDateTime = File.GetLastWriteTime(importPath); - if (fileDateTime case .Ok) - { - let date = fileDateTime.Get().ToFileTime(); - /*if (date > targetDateTime) - Console.WriteLine("Custom build higher time: {0}", importPath);*/ - highestDateTime = Math.Max(highestDateTime, date); - } - }); - - if ((highestDateTime > targetDateTime) || (forceRebuild)) - { - QueueProjectCustomBuildCommands(project, options.mBuildOptions.mPostBuildCmds); - project.mLastDidBuild = true; - }*/ - - return true; - } - -#if IDE_C_SUPPORT - bool buildAll = false; - String buildStringFilePath = scope String(); - mDepClang.GetBuildStringFileName(projectBuildDir, project, buildStringFilePath); - String newBuildString = scope String(); - GetClangBuildString(project, options, workspaceOptions, true, newBuildString); - String clangBuildString = scope String(); - GetClangBuildString(project, options, workspaceOptions, false, clangBuildString); - newBuildString.Append("|", clangBuildString); - - if (mDepClang.mDoDependencyCheck) - { - String prependStr = scope String(); - options.mCOptions.mCompilerType.ToString(prependStr); - prependStr.Append("|"); - newBuildString.Insert(0, prependStr); - String oldBuildString; - mDepClang.mProjectBuildString.TryGetValue(project, out oldBuildString); - - if (oldBuildString == null) - { - oldBuildString = new String(); - File.ReadAllText(buildStringFilePath, oldBuildString).IgnoreError(); - mDepClang.mProjectBuildString[project] = oldBuildString; - } - - if (newBuildString != oldBuildString) - { - buildAll = true; - - if (case .Err = File.WriteAllText(buildStringFilePath, newBuildString)) - OutputLine("Failed to write {0}", buildStringFilePath); - - delete oldBuildString; - mDepClang.mProjectBuildString[project] = new String(newBuildString); - } - } - - using (mDepClang.mMonitor.Enter()) - { - if (options.mClangObjectFiles == null) - options.mClangObjectFiles = new List(); - else - ClearAndDeleteItems(options.mClangObjectFiles); - - for (var projectSource in allFileNames) - { - var fileEntry = mDepClang.GetProjectEntry(projectSource); - Debug.Assert((fileEntry != null) || (!mDepClang.mCompileWaitsForQueueEmpty)); - - String filePath = scope String(); - projectSource.GetFullImportPath(filePath); - String baseName = scope String(); - Path.GetFileNameWithoutExtension(filePath, baseName); - String objName = stack String(); - objName.Append(projectBuildDir, "/", baseName, (options.mCOptions.mGenerateLLVMAsm ? ".ll" : ".obj")); - - if (filePath.Contains("test2.cpp")) - { - NOP!(); - } - - bool needsRebuild = true; - if ((!buildAll) && (fileEntry != null)) - { - mDepClang.SetEntryObjFileName(fileEntry, objName); - mDepClang.SetEntryBuildStringFileName(fileEntry, buildStringFilePath); - needsRebuild = mDepClang.DoesEntryNeedRebuild(fileEntry); - } - if (needsRebuild) - { - if (hotProject != null) - { - OutputLine("Hot swap detected disallowed C/C++ change: {0}", filePath); - return false; - } - - project.mNeedsTargetRebuild = true; - var runCmd = CompileSource(project, workspaceOptions, options, filePath); - runCmd.mParallelGroup = 1; - } - - options.mClangObjectFiles.Add(new String(objName)); - - if (hotProject != null) - continue; - - clangAllObjNames.Add(objName); - - IdSpan sourceCharIdData; - String sourceCode = scope String(); - FindProjectSourceContent(projectSource, out sourceCharIdData, true, sourceCode); - mWorkspace.ProjectSourceCompiled(projectSource, sourceCode, sourceCharIdData); - sourceCharIdData.Dispose(); - - String* fileEntryPtr; - if (completedCompileCmd.mClangCompiledFiles.Add(filePath, out fileEntryPtr)) - *fileEntryPtr = new String(filePath); - } - } -#endif - - String llvmDir = scope String(IDEApp.sApp.mInstallDir); - IDEUtils.FixFilePath(llvmDir); - llvmDir.Append("llvm/"); - - if (hotProject != null) - { - if ((hotProject == project) || (hotProject.HasDependency(project.mProjectName))) - { - for (var fileName in bfFileNames) - hotFileNames.Add(new String(fileName)); - } - - return true; - } - - String objectsArg = scope String(); - var argBuilder = scope ArgBuilder(objectsArg, workspaceOptions.mToolsetType != .GNU); - for (var bfFileName in bfFileNames) - { - argBuilder.AddFileName(bfFileName); - argBuilder.AddSep(); - } - - for (var objName in clangAllObjNames) - { - IDEUtils.AppendWithOptionalQuotes(objectsArg, objName); - objectsArg.Append(" "); - } - - if (workspaceOptions.mToolsetType == .GNU) - { - if (!QueueProjectGNULink(project, targetPath, workspaceOptions, options, objectsArg)) - return false; - } - else // MS - { - if (!QueueProjectMSLink(project, targetPath, configSelection.mConfig, workspaceOptions, options, objectsArg)) - return false; - } - - return true; - } - Project FindProject(String projectName) { return mWorkspace.FindProject(projectName); } - bool GetDependentProjectList(Project project, List orderedProjectList, List projectStack = null) + public bool GetDependentProjectList(Project project, List orderedProjectList, List projectStack = null) { var useProjectStack = projectStack; if ((useProjectStack != null) && (useProjectStack.Contains(project))) @@ -9768,9 +8838,14 @@ namespace IDE bool success = true; List hotFileNames = scope List(); defer ClearAndDeleteItems(hotFileNames); + Debug.Assert(mBuildContext == null); + DeleteAndNullify!(mBuildContext); + mBuildContext = new .(); + mBuildContext.mWorkspaceOptions = GetCurWorkspaceOptions(); + for (var project in orderedProjectList) { - if (!QueueProjectCompile(project, hotProject, completedCompileCmd, hotFileNames, runAfter)) + if (!mBuildContext.QueueProjectCompile(project, hotProject, completedCompileCmd, hotFileNames, runAfter)) success = false; } @@ -10240,7 +9315,12 @@ namespace IDE (project.mGeneralOptions.mTargetType == Project.TargetType.BeefWindowsApplication)) mMainBreakpoint = mDebugger.CreateSymbolBreakpoint("-BeefMain"); else + { mMainBreakpoint = mDebugger.CreateSymbolBreakpoint("-main"); +#if BF_PLATFORM_WINDOWS + //mMainBreakpoint2 = mDebugger.CreateSymbolBreakpoint("-WinMain"); +#endif + } } return true; @@ -11162,6 +10242,10 @@ namespace IDE for (var project in mWorkspace.mProjects) { + // Force running the "if files changed" commands + project.mForceCustomCommands = true; + project.mNeedsTargetRebuild = true; + // Don't delete custom build artifacts if (project.mGeneralOptions.mTargetType == .CustomBuild) continue; @@ -11170,6 +10254,8 @@ namespace IDE defer ClearAndDeleteItems(projectFiles); let options = GetCurProjectOptions(project); + if (options == null) + continue; GetTargetPaths(project, workspaceOptions, options, projectFiles); for (let filePath in projectFiles) @@ -11529,8 +10615,16 @@ namespace IDE { BfLog.LogDbg("Deleting mMainBreakpoint 1\n"); // Couldn't bind to main breakpoint, bind to entry point address - mDebugger.DeleteBreakpoint(mMainBreakpoint); - mMainBreakpoint = mDebugger.CreateSymbolBreakpoint("."); // Magic symbol for "entry point" + // "." is the magic symbol for "entry point" + String[] tryNames = scope .("WinMain", "."); + + for (let name in tryNames) + { + mDebugger.DeleteBreakpoint(mMainBreakpoint); + mMainBreakpoint = mDebugger.CreateSymbolBreakpoint("WinMain"); + if ((name == ".") || (mMainBreakpoint.IsBound())) + break; + } } wantsContinue = true; @@ -11661,6 +10755,22 @@ namespace IDE mWantsRehupCallstack = false; } } + + if (mBuildContext != null) + { + bool isCompiling = (!mExecutionInstances.IsEmpty) || (!mExecutionQueue.IsEmpty); + if (mBuildContext.mScriptManager != null) + { + mBuildContext.mScriptManager.Update(); + if ((mBuildContext.mScriptManager.HasQueuedCommands) && (!mBuildContext.mScriptManager.mFailed)) + isCompiling = true; + } + + if (!isCompiling) + { + DeleteAndNullify!(mBuildContext); + } + } } public void ShowPassOutput(BfPassInstance bfPassInstance) diff --git a/IDE/src/IDEUtils.bf b/IDE/src/IDEUtils.bf index d2dc9cb1..8df248b7 100644 --- a/IDE/src/IDEUtils.bf +++ b/IDE/src/IDEUtils.bf @@ -5,7 +5,6 @@ using System.Threading.Tasks; using System.IO; using Beefy.widgets; using Beefy.utils; -using System.Runtime.InteropServices; using Beefy; using Beefy.gfx; using Beefy.theme.dark; diff --git a/IDE/src/Project.bf b/IDE/src/Project.bf index 6f23adfa..c9adff3b 100644 --- a/IDE/src/Project.bf +++ b/IDE/src/Project.bf @@ -13,7 +13,6 @@ using IDE.ui; using IDE.Util; using System.Threading; using System.Diagnostics; -using System.Runtime.InteropServices; namespace IDE { @@ -300,6 +299,9 @@ namespace IDE if (mIncludeKind != .Manual) return .None; + if (mParentFolder.mPath == null) + return .SimpleSource; + var expectPath = scope String(); expectPath.Append(mParentFolder.mPath); expectPath.Append(Path.DirectorySeparatorChar); @@ -829,12 +831,13 @@ namespace IDE public enum TargetType { case BeefConsoleApplication, - BeefWindowsApplication, - BeefLib, - CustomBuild, - C_ConsoleApplication, - C_WindowsApplication, - BeefTest; + BeefWindowsApplication, + BeefLib, + BeefDynLib, + CustomBuild, + C_ConsoleApplication, + C_WindowsApplication, + BeefTest; public bool IsBeef { @@ -843,9 +846,10 @@ namespace IDE switch (this) { case BeefConsoleApplication, - BeefWindowsApplication, - BeefLib, - BeefTest: return true; + BeefWindowsApplication, + BeefLib, + BeefDynLib, + BeefTest: return true; default: return false; } } @@ -1162,6 +1166,7 @@ namespace IDE //public String mLastImportDir = new String() ~ delete _; public bool mHasChanged; public bool mNeedsTargetRebuild; + public bool mForceCustomCommands; public bool mEnabled = true; public bool mLocked; public bool mLockedDefault; diff --git a/IDE/src/ScriptManager.bf b/IDE/src/ScriptManager.bf index c50bf1e8..ff9f8f9d 100644 --- a/IDE/src/ScriptManager.bf +++ b/IDE/src/ScriptManager.bf @@ -15,6 +15,8 @@ namespace IDE { class ScriptManager { + public static ScriptManager sActiveManager; + class Target { public class Cmd @@ -27,20 +29,29 @@ namespace IDE public Dictionary mCmds = new .() ~ DeleteDictionyAndKeysAndItems!(_); } + public enum CmdFlags + { + None, + NoLines + } + public class QueuedCmd { public String mCondition ~ delete _; + public CmdFlags mFlags; public bool mHandled = true; public String mCmd ~ delete _; public String mSrcFile ~ delete _; public int mLineNum = -1; public int mIntParam; + public int mExecIdx; public bool mNoWait; + public Stopwatch mStopWatch ~ delete _; } - ScriptHelper mScriptHelper = new ScriptHelper() ~ delete _; + ScriptHelper mScriptHelper = new ScriptHelper(this) ~ delete _; Target mRoot = new Target() ~ delete _; Dictionary mVars = new .() ~ { @@ -52,13 +63,18 @@ namespace IDE delete _; }; List mCmdList = new .() ~ DeleteContainerAndItems!(_); - bool mFailed; + public bool mFailed; + public bool mCancelled; public QueuedCmd mCurCmd; public Stopwatch mTimeoutStopwatch ~ delete _; public int mTimeoutMS; public String mExpectingError ~ delete _; public bool mHadExpectingError; public int mDoneTicks; + public bool mAllowCompiling; + public bool mSoftFail; + public Verbosity mVerbosity = .Quiet; + public String mProjectName ~ delete _; public bool Failed { @@ -146,9 +162,16 @@ namespace IDE var errStr = scope String(err); if (mCurCmd != null) { - errStr.AppendF(" at line {0} in {1}\n\t{2}", mCurCmd.mLineNum + 1, mCurCmd.mSrcFile, mCurCmd.mCmd); + if (mCurCmd.mFlags.HasFlag(.NoLines)) + errStr.AppendF(" in {}\n\t{}", mCurCmd.mSrcFile, mCurCmd.mCmd); + else + errStr.AppendF(" at line {} in {}\n\t{}", mCurCmd.mLineNum + 1, mCurCmd.mSrcFile, mCurCmd.mCmd); } - gApp.Fail(errStr); + + if (mSoftFail) + gApp.OutputErrorLine(errStr); + else + gApp.Fail(errStr); //TODO: //gApp.mRunningTestScript = false; @@ -165,7 +188,7 @@ namespace IDE mFailed = false; } - public void QueueCommands(StreamReader streamReader, StringView filePath) + public void QueueCommands(StreamReader streamReader, StringView filePath, CmdFlags flags) { int lineNum = 0; @@ -179,6 +202,7 @@ namespace IDE if ((!line.IsEmpty) && (!line.StartsWith("#"))) { QueuedCmd queuedCmd = new .(); + queuedCmd.mFlags = flags; queuedCmd.mSrcFile = new String(filePath); queuedCmd.mLineNum = lineNum; @@ -223,6 +247,13 @@ namespace IDE } } + public void QueueCommands(StringView cmds, StringView filePath, CmdFlags flags) + { + StringStream strStream = scope .(cmds, .Reference); + StreamReader reader = scope .(strStream); + QueueCommands(reader, filePath, flags); + } + public void QueueCommandFile(StringView filePath) { let streamReader = scope StreamReader(); @@ -232,7 +263,7 @@ namespace IDE return; } - QueueCommands(streamReader, filePath); + QueueCommands(streamReader, filePath, .None); } public void SetTimeoutMS(int timeoutMS) @@ -245,14 +276,56 @@ namespace IDE mTimeoutMS = timeoutMS; } - public void Exec(StringView cmdLineView) + public void Exec(StringView cmd) { - var cmdLineView; - cmdLineView.Trim(); + var cmd; + cmd.Trim(); - if ((cmdLineView.StartsWith("#")) || (cmdLineView.IsEmpty)) + if ((cmd.StartsWith("#")) || (cmd.IsEmpty)) return; + if (cmd.StartsWith("%exec ")) + { + mScriptHelper.ExecuteRaw(scope String(cmd, "%exec ".Length)); + return; + } + + if (cmd.StartsWith("%targetComplete ")) + { + let projectName = cmd.Substring("%targetComplete ".Length); + + if (gApp.mExecutionQueue.IsEmpty) + return; + + bool matched = false; + if (var targetCompleteCmd = gApp.mExecutionQueue[0] as IDEApp.TargetCompletedCmd) + { + if (targetCompleteCmd.mProject.mProjectName == projectName) + { + targetCompleteCmd.mIsReady = true; + matched = true; + } + } + + if (!matched) + { + mCurCmd.mHandled = false; + } + return; + } + + if (mCurCmd.mExecIdx == 0) + { + if (mVerbosity >= .Normal) + { + gApp.OutputLine("Executing Command: {}", cmd); + if (mVerbosity >= .Detailed) + { + mCurCmd.mStopWatch = new .(true); + } + } + } + StringView varName = .(); /*int eqPos = cmdLineView.IndexOf('='); @@ -267,20 +340,20 @@ namespace IDE StringView methodName; List args = scope .(); - int parenPos = cmdLineView.IndexOf('('); + int parenPos = cmd.IndexOf('('); if (parenPos != -1) { - methodName = cmdLineView.Substring(0, parenPos); + methodName = cmd.Substring(0, parenPos); methodName.Trim(); - int endParenPos = cmdLineView.LastIndexOf(')'); + int endParenPos = cmd.LastIndexOf(')'); if (endParenPos == -1) { Fail("Missing argument end ')'"); return; } - var postStr = StringView(cmdLineView, endParenPos + 1); + var postStr = StringView(cmd, endParenPos + 1); postStr.Trim(); if ((!postStr.IsEmpty) && (!postStr.StartsWith("#"))) { @@ -288,11 +361,15 @@ namespace IDE return; } + Workspace.Options workspaceOptions = null; + Project project = null; + Project.Options projectOptions = null; + bool inQuotes = false; int startIdx = parenPos; for (int idx = parenPos; idx <= endParenPos; idx++) { - char8 c = cmdLineView[idx]; + char8 c = cmd[idx]; if (c == '\\') { // Skip past slashed strings @@ -305,7 +382,7 @@ namespace IDE } else if (((c == ',') || (c == ')')) && (!inQuotes)) { - StringView argView = cmdLineView.Substring(startIdx + 1, idx - startIdx - 1); + StringView argView = cmd.Substring(startIdx + 1, idx - startIdx - 1); argView.Trim(); if (argView.IsEmpty) @@ -319,9 +396,20 @@ namespace IDE if (str.Contains('$')) { + if (workspaceOptions == null) + { + workspaceOptions = gApp.GetCurWorkspaceOptions(); + if (mProjectName != null) + { + project = gApp.mWorkspace.FindProject(mProjectName); + if (project != null) + projectOptions = gApp.GetCurProjectOptions(project); + } + } + String newStr = scope:: .(); String err = scope .(); - if (!gApp.DoResolveConfigString(null, null, null, str, err, newStr)) + if (!gApp.DoResolveConfigString(workspaceOptions, project, projectOptions, str, err, newStr)) { Fail(scope String()..AppendF("Unknown macro string '{}' in '{}'", err, str)); } @@ -375,7 +463,7 @@ namespace IDE } else { - methodName = cmdLineView; + methodName = cmd; } Target curTarget = mRoot; @@ -539,6 +627,12 @@ namespace IDE return false; } + public void Cancel() + { + mCancelled = true; + ClearAndDeleteItems(mCmdList); + } + public void Update() { if (mFailed) @@ -547,9 +641,10 @@ namespace IDE if ((mTimeoutMS > 0) && (gApp.mRunningTestScript)) { if (mTimeoutStopwatch.ElapsedMilliseconds >= mTimeoutMS) - Fail("Script has timed out: {0}ms", mTimeoutStopwatch.ElapsedMilliseconds); + Fail("Script has timed out: {:0.00}s", mTimeoutStopwatch.ElapsedMilliseconds / 1000.0f); } + ScriptManager.sActiveManager = this; while ((!mCmdList.IsEmpty) && (!mFailed)) { mCurCmd = mCmdList[0]; @@ -568,7 +663,10 @@ namespace IDE if (mCurCmd.mCondition != null) doExec = CheckCondition(mCurCmd.mCondition); if (doExec) + { Exec(mCurCmd.mCmd); + mCurCmd.mExecIdx++; + } if (mCmdList.IsEmpty) break; @@ -576,16 +674,30 @@ namespace IDE if (!mCurCmd.mHandled) break; // Try again next update + if (mCurCmd.mStopWatch != null) + { + mCurCmd.mStopWatch.Stop(); + if (mCurCmd.mStopWatch.ElapsedMilliseconds > 10) + gApp.OutputLine("Command Time: {:0.00}s", mCurCmd.mStopWatch.ElapsedMilliseconds / 1000.0f); + } + mCmdList.RemoveAt(0); delete mCurCmd; mCurCmd = null; } + ScriptManager.sActiveManager = null; } } class ScriptHelper { public EditWidgetContent.LineAndColumn mMarkedPos; + public ScriptManager mScriptManager; + + public this(ScriptManager scriptManager) + { + mScriptManager = scriptManager; + } void FixFilePath(String filePath, ProjectFolder folder) { @@ -632,7 +744,7 @@ namespace IDE if (!File.Exists(outFilePath)) { - gApp.mScriptManager.Fail("Unable to locate project file '{0}'", outFilePath); + ScriptManager.sActiveManager.Fail("Unable to locate project file '{0}'", outFilePath); } } @@ -647,7 +759,7 @@ namespace IDE if (!File.Exists(outFilePath)) { - gApp.mScriptManager.Fail("Unable to locate file '{0}'", outFilePath); + ScriptManager.sActiveManager.Fail("Unable to locate file '{0}'", outFilePath); } } @@ -656,7 +768,7 @@ namespace IDE var sourceViewPanel = gApp.GetActiveSourceViewPanel(); if (sourceViewPanel == null) { - gApp.mScriptManager.Fail("No active source view panel"); + ScriptManager.sActiveManager.Fail("No active source view panel"); return null; } sourceViewPanel.EnsureReady(); @@ -667,13 +779,13 @@ namespace IDE { var textPanel = gApp.GetActivePanel() as TextPanel; if (textPanel == null) - gApp.mScriptManager.Fail("No active text panel"); + ScriptManager.sActiveManager.Fail("No active text panel"); return textPanel; } public bool Evaluate(String evalStr, String outVal, DebugManager.EvalExpressionFlags expressionFlags = .AllowCalls | .AllowSideEffects) { - var curCmd = gApp.mScriptManager.mCurCmd; + var curCmd = ScriptManager.sActiveManager.mCurCmd; if (curCmd.mIntParam == 1) // Pending { @@ -741,7 +853,7 @@ namespace IDE { int wantTicks = length * gApp.RefreshRate / 1000; - var curCmd = gApp.mScriptManager.mCurCmd; + var curCmd = ScriptManager.sActiveManager.mCurCmd; if ((++curCmd.mIntParam <= wantTicks) || (length < 0)) // Negative is forever curCmd.mHandled = false; } @@ -750,7 +862,7 @@ namespace IDE public void SleepTicks(int length) { int wantTicks = length; - var curCmd = gApp.mScriptManager.mCurCmd; + var curCmd = ScriptManager.sActiveManager.mCurCmd; if ((++curCmd.mIntParam <= wantTicks) || (length < 0)) // Negative is forever curCmd.mHandled = false; } @@ -780,12 +892,25 @@ namespace IDE return false; if (gApp.[Friend]mDeferredOpen != .None) return false; - if (gApp.mWantsRehupCallstack) - return false; + + if ((gApp.mExecutionPaused) && (gApp.mDebugger.IsPaused())) + { + if (gApp.mWantsRehupCallstack) + return false; + } if (gApp.mWantsClean || gApp.mWantsBeefClean) return false; - if ((!gApp.IsCompiling) && (!gApp.AreTestsRunning()) && (!gApp.mDebugger.HasPendingDebugLoads()) && + if (gApp.IsCompiling) + { + if (!ScriptManager.sActiveManager.mAllowCompiling) + return false; + } + + if (!gApp.[Friend]mExecutionInstances.IsEmpty) + return false; + + if ((!gApp.AreTestsRunning()) && (!gApp.mDebugger.HasPendingDebugLoads()) && ((gApp.mExecutionPaused) || (!gApp.mDebugger.mIsRunning))) { var runState = gApp.mDebugger.GetRunState(); @@ -830,14 +955,14 @@ namespace IDE [IDECommand] public void WaitForPaused() { - var curCmd = gApp.mScriptManager.mCurCmd; + var curCmd = ScriptManager.sActiveManager.mCurCmd; curCmd.mHandled = IsPaused(); } [IDECommand] public void WaitForResolve() { - var curCmd = gApp.mScriptManager.mCurCmd; + var curCmd = ScriptManager.sActiveManager.mCurCmd; curCmd.mHandled = IsPaused() && (!gApp.mBfResolveCompiler.IsPerformingBackgroundOperation()); } @@ -857,7 +982,7 @@ namespace IDE case .Ok(let flags): gApp.mDebugger.SetSymSrvOptions(symCacheDir, symSrvStr, flags); case .Err: - gApp.mScriptManager.Fail("Failed to parse flags"); + ScriptManager.sActiveManager.Fail("Failed to parse flags"); } } @@ -875,7 +1000,7 @@ namespace IDE { if (Utils.DelTree(dirPath) case .Err) { - gApp.mScriptManager.Fail(scope String()..AppendF("Failed to deltree '{}'", dirPath)); + ScriptManager.sActiveManager.Fail(scope String()..AppendF("Failed to deltree '{}'", dirPath)); } } @@ -885,7 +1010,7 @@ namespace IDE let fileStream = scope FileStream(); if (fileStream.Create(path) case .Err) { - gApp.mScriptManager.Fail("Failed to create file '{}'", path); + ScriptManager.sActiveManager.Fail("Failed to create file '{}'", path); return; } fileStream.Write(text); @@ -896,7 +1021,7 @@ namespace IDE { if (File.Move(origPath, newPath) case .Err) { - gApp.mScriptManager.Fail("Failed to move file '{}' to '{}'", origPath, newPath); + ScriptManager.sActiveManager.Fail("Failed to move file '{}' to '{}'", origPath, newPath); } } @@ -905,10 +1030,147 @@ namespace IDE { if (File.Delete(path) case .Err) { - gApp.mScriptManager.Fail("Failed to delete file '{}'", path); + mScriptManager.Fail("Failed to delete file '{}'", path); } } + /*[IDECommand] + public void Copy(String srcPath, String destPath) + { + + }*/ + + [IDECommand] + public void CopyFilesIfNewer(String srcPath, String destPath) + { + int copyCount = 0; + int foundCount = 0; + + void Do(String srcPath, String destPath) + { + bool checkedDestDir = false; + + for (var entry in Directory.Enumerate(srcPath, .Directories | .Files)) + { + foundCount++; + + if (mScriptManager.mFailed) + return; + + String srcFilePath = scope .(); + entry.GetFilePath(srcFilePath); + + String srcFileName = scope .(); + entry.GetFileName(srcFileName); + + String destFilePath = scope .(); + Path.GetAbsolutePath(srcFileName, destPath, destFilePath); + + if (entry.IsDirectory) + { + Do(srcFilePath, destFilePath); + continue; + } + + DateTime srcDate; + if (!(File.GetLastWriteTime(srcFilePath) case .Ok(out srcDate))) + continue; + + bool wantCopy = true; + if (File.GetLastWriteTime(destFilePath) case .Ok(let destDate)) + { + wantCopy = srcDate > destDate; + } + + if (!wantCopy) + continue; + + if (!checkedDestDir) + { + if (Directory.CreateDirectory(destPath) case .Err) + { + mScriptManager.Fail("Failed to create directory '{}'", destPath); + return; + } + } + + if (File.Copy(srcFilePath, destFilePath) case .Err) + { + mScriptManager.Fail("Failed to copy '{}' to '{}'", srcFilePath, destFilePath); + return; + } + + copyCount++; + } + } + + Do(srcPath, destPath); + + if (foundCount == 0) + { + String srcDirPath = scope .(); + Path.GetDirectoryPath(srcPath, srcDirPath); + if (!Directory.Exists(srcDirPath)) + { + mScriptManager.Fail("Source directory does not exist: {}", srcDirPath); + } + else if ((!srcDirPath.Contains('*')) && (!srcDirPath.Contains('?')) && (!File.Exists(srcDirPath))) + { + mScriptManager.Fail("Source file does not exist: {}", srcPath); + } + } + + if ((!mScriptManager.mFailed) && (copyCount > 0) && (mScriptManager.mVerbosity >= .Normal)) + { + if (mScriptManager.mCurCmd.mStopWatch != null) + { + mScriptManager.mCurCmd.mStopWatch.Stop(); + gApp.OutputLine("{} files copied from '{}' to '{}' in {:0.00}s", foundCount, srcPath, destPath, mScriptManager.mCurCmd.mStopWatch.ElapsedMilliseconds / 1000.0f); + DeleteAndNullify!(mScriptManager.mCurCmd.mStopWatch); + } + else + gApp.OutputLine("{} files copied from '{}' to '{}'", foundCount, srcPath, destPath); + } + } + + [IDECommand] + public void ExecuteRaw(String cmd) + { + var exePath = scope String(); + int spacePos; + if (cmd.StartsWith("\"")) + { + spacePos = cmd.IndexOf('"', 1) + 1; + if (spacePos != -1) + exePath.Append(cmd, 1, spacePos - 2); + } + else + { + spacePos = cmd.IndexOf(' '); + if (spacePos != -1) + exePath.Append(cmd, 0, spacePos); + } + + if ((spacePos == -1) && (!cmd.IsEmpty)) + { + mScriptManager.Fail("Invalid command '{0}' in '{1}'", cmd, mScriptManager.mCurCmd.mSrcFile); + return; + } + + if (spacePos > 0) + { + var exeArgs = scope String(); + exeArgs.Append(cmd, spacePos + 1); + gApp.DoRun(exePath, exeArgs, gApp.mInstallDir, .None); + } + } + + [IDECommand] + public void Execute(String path) + { + ExecuteRaw(path); + } + [IDECommand] public void SetFileWatcherDelay(int32 delay) { @@ -921,7 +1183,7 @@ namespace IDE String content = scope .(); if (File.ReadAllText(origPath, content, true) case .Err) { - gApp.mScriptManager.Fail("Failed to open file '{}'", origPath); + ScriptManager.sActiveManager.Fail("Failed to open file '{}'", origPath); return; } @@ -942,7 +1204,7 @@ namespace IDE FileStream tempStream = scope .(); if (tempStream.Create(tempPath) case .Err) { - gApp.mScriptManager.Fail("Failed to create temp file '{}'", tempPath); + ScriptManager.sActiveManager.Fail("Failed to create temp file '{}'", tempPath); return; } tempStream.Write(content); @@ -950,13 +1212,13 @@ namespace IDE if (File.Move(tempPath, newPath) case .Err) { - gApp.mScriptManager.Fail("Failed to move file '{}' to '{}'", origPath, newPath); + ScriptManager.sActiveManager.Fail("Failed to move file '{}' to '{}'", origPath, newPath); return; } if (File.Delete(origPath) case .Err) { - gApp.mScriptManager.Fail("Failed to delete file '{}'", origPath); + ScriptManager.sActiveManager.Fail("Failed to delete file '{}'", origPath); return; } } @@ -982,7 +1244,7 @@ namespace IDE var panelHeader = sourceViewPanel.[Friend]mPanelHeader; if (panelHeader == null) { - gApp.mScriptManager.Fail("No panel present"); + ScriptManager.sActiveManager.Fail("No panel present"); return; } @@ -998,7 +1260,7 @@ namespace IDE } } - gApp.mScriptManager.Fail("Button '{0}' not found", buttonName); + ScriptManager.sActiveManager.Fail("Button '{0}' not found", buttonName); } [IDECommand] @@ -1020,7 +1282,7 @@ namespace IDE if (outVal != evalResult) { - gApp.mScriptManager.Fail("Assert failed: {0} == {1}", outVal, evalResult); + ScriptManager.sActiveManager.Fail("Assert failed: {0} == {1}", outVal, evalResult); } } @@ -1033,7 +1295,7 @@ namespace IDE if (!outVal.Contains(evalResult)) { - gApp.mScriptManager.Fail("Assert failed: {0} contains {1}", outVal, evalResult); + ScriptManager.sActiveManager.Fail("Assert failed: {0} contains {1}", outVal, evalResult); } } @@ -1056,7 +1318,7 @@ namespace IDE gApp.mDebugger.UpdateCallStack(); if (stackCount == gApp.mDebugger.GetCallStackCount()) { - gApp.mScriptManager.Fail("Stack idx '{0}' is out of range", selectIdx); + ScriptManager.sActiveManager.Fail("Stack idx '{0}' is out of range", selectIdx); } } @@ -1088,7 +1350,7 @@ namespace IDE stackIdx++; } - gApp.mScriptManager.Fail("Failed to find stack frame containing string '{}'", str); + ScriptManager.sActiveManager.Fail("Failed to find stack frame containing string '{}'", str); } [IDECommand] @@ -1124,7 +1386,7 @@ namespace IDE if (methodName != stackframeInfo) { - gApp.mScriptManager.Fail("Expect method name '{0}', got '{1}'", methodName, stackframeInfo); + ScriptManager.sActiveManager.Fail("Expect method name '{0}', got '{1}'", methodName, stackframeInfo); } } @@ -1162,7 +1424,7 @@ namespace IDE var lastBreakpoint = gApp.mDebugger.mBreakpointList.Back; if (lastBreakpoint == null) { - gApp.mScriptManager.Fail("No last breakpoint"); + ScriptManager.sActiveManager.Fail("No last breakpoint"); return; } lastBreakpoint.SetCondition(condition); @@ -1174,13 +1436,13 @@ namespace IDE var lastBreakpoint = gApp.mDebugger.mBreakpointList.Back; if (lastBreakpoint == null) { - gApp.mScriptManager.Fail("No last breakpoint"); + ScriptManager.sActiveManager.Fail("No last breakpoint"); return; } switch (Enum.Parse(hitCountBreakKindStr)) { case .Err: - gApp.mScriptManager.Fail("Invalid break kind: '{0}'", hitCountBreakKindStr); + ScriptManager.sActiveManager.Fail("Invalid break kind: '{0}'", hitCountBreakKindStr); case .Ok(let hitCountBreakKind): lastBreakpoint.SetHitCountTarget(hitCountTarget, hitCountBreakKind); } @@ -1202,20 +1464,20 @@ namespace IDE var textPanel = GetActiveTextPanel(); if (textPanel == null) { - gApp.mScriptManager.Fail("No text panel active"); + ScriptManager.sActiveManager.Fail("No text panel active"); return null; } var ewc = textPanel.EditWidget.mEditWidgetContent as SourceEditWidgetContent; if (ewc == null) { - gApp.mScriptManager.Fail("Not an autocomplete text view"); + ScriptManager.sActiveManager.Fail("Not an autocomplete text view"); return null; } if (ewc.mAutoComplete == null) { - gApp.mScriptManager.Fail("No autocomplete content"); + ScriptManager.sActiveManager.Fail("No autocomplete content"); return null; } @@ -1252,9 +1514,9 @@ namespace IDE if (found != wantsFind) { if (wantsFind) - gApp.mScriptManager.Fail("Autocomplete entry '{0}' not found", wantEntry); + ScriptManager.sActiveManager.Fail("Autocomplete entry '{0}' not found", wantEntry); else - gApp.mScriptManager.Fail("Autocomplete entry '{0}' found, but it shouldn't have been", wantEntry); + ScriptManager.sActiveManager.Fail("Autocomplete entry '{0}' found, but it shouldn't have been", wantEntry); return false; } return true; @@ -1304,7 +1566,7 @@ namespace IDE if (contents != wantsContents) { - gApp.mScriptManager.Fail("Autocomplete not showing expected values. Expected '{}', got '{}'.", wantsContents, contents); + ScriptManager.sActiveManager.Fail("Autocomplete not showing expected values. Expected '{}', got '{}'.", wantsContents, contents); return false; } return true; @@ -1337,14 +1599,14 @@ namespace IDE if (!Path.Equals(filePath, sourceViewPanel.mFilePath)) { - gApp.mScriptManager.Fail("Expected source file '{0}', got '{1}'", filePath, sourceViewPanel.mFilePath); + ScriptManager.sActiveManager.Fail("Expected source file '{0}', got '{1}'", filePath, sourceViewPanel.mFilePath); return; } let atLine = sourceViewPanel.mEditWidget.mEditWidgetContent.CursorLineAndColumn.mLine + 1; if (atLine != lineNum) { - gApp.mScriptManager.Fail("Expected line '{0}', got '{1}'", lineNum, atLine); + ScriptManager.sActiveManager.Fail("Expected line '{0}', got '{1}'", lineNum, atLine); return; } } @@ -1357,7 +1619,7 @@ namespace IDE var textPanel = GetActiveTextPanel(); if (textPanel == null) { - gApp.mScriptManager.Fail("No active text panel"); + ScriptManager.sActiveManager.Fail("No active text panel"); return; } var ewc = textPanel.EditWidget.mEditWidgetContent; @@ -1387,7 +1649,7 @@ namespace IDE } } - gApp.mScriptManager.Fail("Unable to find text '{0}'", findText); + ScriptManager.sActiveManager.Fail("Unable to find text '{0}'", findText); } [IDECommand] @@ -1411,7 +1673,7 @@ namespace IDE if (!lineText.Contains(findText)) { - gApp.mScriptManager.Fail("Lines does not contain text '{0}'", findText); + ScriptManager.sActiveManager.Fail("Lines does not contain text '{0}'", findText); } } @@ -1514,12 +1776,12 @@ namespace IDE { if (gApp.IsCompiling) { - gApp.mScriptManager.mCurCmd.mHandled = false; + ScriptManager.sActiveManager.mCurCmd.mHandled = false; return; } if (gApp.mLastCompileFailed) - gApp.mScriptManager.Fail("Compile failed"); + ScriptManager.sActiveManager.Fail("Compile failed"); } [IDECommand] @@ -1532,7 +1794,7 @@ namespace IDE var ewc = sourceViewPanel.mEditWidget.mEditWidgetContent; GotoText(textFrom); - if (gApp.mScriptManager.Failed) + if (ScriptManager.sActiveManager.Failed) return; @@ -1630,18 +1892,18 @@ namespace IDE [IDECommand] public void SetExpectError(String error) { - DeleteAndNullify!(gApp.mScriptManager.mExpectingError); - gApp.mScriptManager.mExpectingError = new String(error); - gApp.mScriptManager.mHadExpectingError = true; + DeleteAndNullify!(ScriptManager.sActiveManager.mExpectingError); + ScriptManager.sActiveManager.mExpectingError = new String(error); + ScriptManager.sActiveManager.mHadExpectingError = true; } [IDECommand] public void ExpectError() { - if (gApp.mScriptManager.mExpectingError != null) + if (ScriptManager.sActiveManager.mExpectingError != null) { - DeleteAndNullify!(gApp.mScriptManager.mExpectingError); - gApp.mScriptManager.Fail("Expected error did not occur"); + DeleteAndNullify!(ScriptManager.sActiveManager.mExpectingError); + ScriptManager.sActiveManager.Fail("Expected error did not occur"); } } @@ -1651,7 +1913,7 @@ namespace IDE var textPanel = GetActiveSourceViewPanel(); if (textPanel == null) { - gApp.mScriptManager.Fail("No active text panel"); + ScriptManager.sActiveManager.Fail("No active text panel"); return; } var ewc = textPanel.EditWidget.mEditWidgetContent; @@ -1675,9 +1937,9 @@ namespace IDE if (hasError != expectedError) { if (hasError) - gApp.mScriptManager.Fail("Unexpected error at line {0} in {1}\n\t", lineIdx + 1, textPanel.mFilePath); + ScriptManager.sActiveManager.Fail("Unexpected error at line {0} in {1}\n\t", lineIdx + 1, textPanel.mFilePath); else - gApp.mScriptManager.Fail("Expected error at line {0} in {1} but didn't encounter one\n\t", lineIdx + 1, textPanel.mFilePath); + ScriptManager.sActiveManager.Fail("Expected error at line {0} in {1} but didn't encounter one\n\t", lineIdx + 1, textPanel.mFilePath); return; } } @@ -1686,7 +1948,7 @@ namespace IDE [IDECommand] public void Stop() { - gApp.mScriptManager.Clear(); + ScriptManager.sActiveManager.Clear(); } [IDECommand] diff --git a/IDE/src/SpellChecker.bf b/IDE/src/SpellChecker.bf index 8cf08ead..6cc7df75 100644 --- a/IDE/src/SpellChecker.bf +++ b/IDE/src/SpellChecker.bf @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; using System.Threading; diff --git a/IDE/src/Targets.bf b/IDE/src/Targets.bf index 95f21d7c..1357dce7 100644 --- a/IDE/src/Targets.bf +++ b/IDE/src/Targets.bf @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; diff --git a/IDE/src/WakaTime.bf b/IDE/src/WakaTime.bf index 105a0883..b2280f2f 100644 --- a/IDE/src/WakaTime.bf +++ b/IDE/src/WakaTime.bf @@ -2,7 +2,6 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; -using System.Runtime.InteropServices; using System.Text; using System.Threading; using System.Threading.Tasks; diff --git a/IDE/src/Workspace.bf b/IDE/src/Workspace.bf index a059931e..a61059be 100644 --- a/IDE/src/Workspace.bf +++ b/IDE/src/Workspace.bf @@ -632,7 +632,7 @@ namespace IDE mProjectNameMap.Clear(); } - public Project FindProject(String projectName) + public Project FindProject(StringView projectName) { if (mProjectNameMap.IsEmpty) { @@ -654,7 +654,12 @@ namespace IDE Add(alias, project); } } - return mProjectNameMap.GetValueOrDefault(projectName); + + if (mProjectNameMap.TryGetWith(projectName, var matchKey, var value)) + { + return value; + } + return null; } public void SetupDefault(Options options, String configName, String platformName) diff --git a/IDE/src/ui/ImmediateWidget.bf b/IDE/src/ui/ImmediateWidget.bf index dea7bc59..4dfc61de 100644 --- a/IDE/src/ui/ImmediateWidget.bf +++ b/IDE/src/ui/ImmediateWidget.bf @@ -337,10 +337,8 @@ namespace IDE.ui mUsedHistory = false; if (cmdText.StartsWith("%")) { - StringStream strStream = scope .(StringView(cmdText, 1), .Reference); - StreamReader reader = scope .(strStream); gApp.mScriptManager.Clear(); - gApp.mScriptManager.QueueCommands(reader, "Immediate"); + gApp.mScriptManager.QueueCommands(StringView(cmdText, 1), "Immediate", .NoLines); } else result = mResultHoverWatch.Eval(cmdText, false); diff --git a/IDE/src/ui/NewProjectDialog.bf b/IDE/src/ui/NewProjectDialog.bf index 63cf5465..11271414 100644 --- a/IDE/src/ui/NewProjectDialog.bf +++ b/IDE/src/ui/NewProjectDialog.bf @@ -15,10 +15,11 @@ namespace IDE.ui public PathEditWidget mDirectoryEdit; public EditWidget mNameEdit; public DarkComboBox mTargetComboBox; - static String[4] sApplicationTypeNames = + static String[5] sApplicationTypeNames = .("Console Application", "Windows Application", "Library", + "Dynamic Library", "Custom Build"); public bool mDirChanged; public String mDirBase ~ delete _; diff --git a/IDE/src/ui/ProjectProperties.bf b/IDE/src/ui/ProjectProperties.bf index 18cab3af..256ff4ce 100644 --- a/IDE/src/ui/ProjectProperties.bf +++ b/IDE/src/ui/ProjectProperties.bf @@ -593,6 +593,7 @@ namespace IDE.ui "Console Application", "Windows Application", "Library", + "Dynamic Library", "Custom Build" }); AddPropertiesItem(root, "Project Name Aliases", "mAliases"); diff --git a/IDE/src/ui/SourceEditWidgetContent.bf b/IDE/src/ui/SourceEditWidgetContent.bf index 40290af2..3624ba06 100644 --- a/IDE/src/ui/SourceEditWidgetContent.bf +++ b/IDE/src/ui/SourceEditWidgetContent.bf @@ -4,7 +4,6 @@ using System.Text; using System.Threading.Tasks; using System.Threading; using System.Diagnostics; -using System.Runtime.InteropServices; using Beefy; using Beefy.widgets; using Beefy.theme; diff --git a/IDE/src/ui/SourceViewPanel.bf b/IDE/src/ui/SourceViewPanel.bf index c2d8145f..31c30da1 100644 --- a/IDE/src/ui/SourceViewPanel.bf +++ b/IDE/src/ui/SourceViewPanel.bf @@ -5,7 +5,6 @@ using System.Threading.Tasks; using System.Threading; using System.Diagnostics; using System.IO; -using System.Runtime.InteropServices; using Beefy; using Beefy.widgets; using Beefy.theme; diff --git a/IDE/src/ui/StatusBar.bf b/IDE/src/ui/StatusBar.bf index 4e952929..1741dc64 100644 --- a/IDE/src/ui/StatusBar.bf +++ b/IDE/src/ui/StatusBar.bf @@ -351,6 +351,10 @@ namespace IDE.ui { DrawStatusBox("Running Script"); } + else if ((gApp.mBuildContext != null) && (!completionPct.HasValue)) + { + DrawStatusBox("Custom Build Commands..."); + } else mStatusBoxUpdateCnt = -1; diff --git a/IDE/src/util/Zip.bf b/IDE/src/util/Zip.bf index dce1d067..568c2699 100644 --- a/IDE/src/util/Zip.bf +++ b/IDE/src/util/Zip.bf @@ -974,7 +974,7 @@ namespace IDE.Util bit_buf |= (((tinfl_bit_buf_t)pIn_buf_cur[0]) << num_bits) | (((tinfl_bit_buf_t)pIn_buf_cur[1]) << (num_bits + 8)); pIn_buf_cur += 2; num_bits += 16; } } - if ((temp = (uint16)pHuff.m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]) >= 0) + if ((temp = pHuff.m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]) >= 0) { code_len = temp >> 9; temp &= 511; @@ -984,7 +984,7 @@ namespace IDE.Util code_len = TINFL_FAST_LOOKUP_BITS; repeat { - temp = (uint16)pHuff.m_tree[~temp + (int32)((bit_buf >> code_len++) & 1)]; + temp = pHuff.m_tree[~temp + (int32)((bit_buf >> code_len++) & 1)]; } while (temp < 0); } diff --git a/IDEHelper/Backend/BeCOFFObject.cpp b/IDEHelper/Backend/BeCOFFObject.cpp index d6a53c91..0668aadd 100644 --- a/IDEHelper/Backend/BeCOFFObject.cpp +++ b/IDEHelper/Backend/BeCOFFObject.cpp @@ -1950,7 +1950,7 @@ void BeCOFFObject::Generate(BeModule* module) InitSect(mDebugTSect, ".debug$T", IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_ALIGN_4BYTES | IMAGE_SCN_MEM_DISCARDABLE | IMAGE_SCN_MEM_READ, true, false); } InitSect(mPDataSect, ".pdata", IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_ALIGN_4BYTES | IMAGE_SCN_MEM_READ, true, false); - + mTextSect.mData.mData.Reserve(4096); BfSizedVector globalVarSyms; @@ -2060,8 +2060,21 @@ void BeCOFFObject::Generate(BeModule* module) BeMCContext context(this); context.Generate(func); + + if (func->mIsDLLExport) + { + mDirectives += " "; + mDirectives.Append("/EXPORT:"); + mDirectives.Append(func->mName); + } } } + + if (!mDirectives.IsEmpty()) + { + InitSect(mDirectiveSect, ".drectve", IMAGE_SCN_LNK_INFO | IMAGE_SCN_LNK_REMOVE | IMAGE_SCN_ALIGN_1BYTES, true, false); + mDirectiveSect.mData.Write((void*)mDirectives.c_str(), (int)mDirectives.length()); + } if (hasDebugInfo) { diff --git a/IDEHelper/Backend/BeCOFFObject.h b/IDEHelper/Backend/BeCOFFObject.h index a113bdad..1736992c 100644 --- a/IDEHelper/Backend/BeCOFFObject.h +++ b/IDEHelper/Backend/BeCOFFObject.h @@ -229,6 +229,7 @@ public: BeCOFFSection mXDataSect; BeCOFFSection mDebugSSect; BeCOFFSection mDebugTSect; + BeCOFFSection mDirectiveSect; DynMemStream mStrTable; int mBSSPos; Array mUsedSections; @@ -244,6 +245,7 @@ public: int mCurStringId; int mCurJumpTableIdx; bool mTypesLocked; + String mDirectives; public: void ToString(BeMDNode* mdNode, String& str); diff --git a/IDEHelper/Backend/BeIRCodeGen.cpp b/IDEHelper/Backend/BeIRCodeGen.cpp index d8807ddb..da064722 100644 --- a/IDEHelper/Backend/BeIRCodeGen.cpp +++ b/IDEHelper/Backend/BeIRCodeGen.cpp @@ -2112,6 +2112,10 @@ void BeIRCodeGen::HandleNextCmd() func->mNoReturn = true; else if (attribute == BFIRAttribute_NoFramePointerElim) func->mNoFramePointerElim = true; + else if (attribute == BFIRAttribute_DllExport) + func->mIsDLLExport = true; + else if (attribute == BFIRAttribute_DllImport) + func->mIsDLLImport = true; else BF_FATAL("Unhandled"); } diff --git a/IDEHelper/Backend/BeMCContext.cpp b/IDEHelper/Backend/BeMCContext.cpp index 1d867f6d..ea0bc719 100644 --- a/IDEHelper/Backend/BeMCContext.cpp +++ b/IDEHelper/Backend/BeMCContext.cpp @@ -11502,6 +11502,10 @@ void BeMCContext::EmitAggMov(const BeMCOperand& dest, const BeMCOperand& src) int curOfs = 0; bool allowRep = dataVec.size() >= BF_REP_MOV_LIMIT; + if (mDebugging) + { + NOP; + } union IntUnion { @@ -11570,7 +11574,7 @@ void BeMCContext::EmitAggMov(const BeMCOperand& dest, const BeMCOperand& src) } }; - for (; curOfs <= memSize - 8; curOfs += 8) + for (; curOfs <= memSize - 8; ) { if (allowRep) { @@ -11588,14 +11592,26 @@ void BeMCContext::EmitAggMov(const BeMCOperand& dest, const BeMCOperand& src) if (repSize >= 16) { - // mov al, - Emit(0xB0); Emit(val); - + bool regSaved = false; + if ((regA == X64Reg_RAX) || + (regA == X64Reg_RCX) || + (regA == X64Reg_RDI)) + { + BF_ASSERT(regB == X64Reg_None); + // mov R11, regA + Emit(0x49); Emit(0x89); + EmitModRM(BeMCOperand::FromReg(regA), BeMCOperand::FromReg(X64Reg_R11)); + regSaved = true; + } + // lea rdi, EmitREX(BeMCOperand::FromReg(X64Reg_RDI), dest, true); Emit(0x8D); EmitModRMRel(EncodeRegNum(X64Reg_RDI), regA, regB, 1, disp + curOfs); + // mov al, + Emit(0xB0); Emit(val); + // mov edx, Emit(0xB9); mOut.Write((int32)repSize); @@ -11603,6 +11619,13 @@ void BeMCContext::EmitAggMov(const BeMCOperand& dest, const BeMCOperand& src) // rep stosb Emit(0xF3); Emit(0xAA); + if (regSaved) + { + // mov regA, R11 + Emit(0x4C); Emit(0x89); + EmitModRM(BeMCOperand::FromReg(X64Reg_R11), BeMCOperand::FromReg(regA)); + } + curOfs += repSize; continue; } @@ -11615,6 +11638,7 @@ void BeMCContext::EmitAggMov(const BeMCOperand& dest, const BeMCOperand& src) EmitREX(BeMCOperand::FromReg(X64Reg_R11), dest, true); Emit(0x89); EmitModRMRel(EncodeRegNum(X64Reg_R11), regA, regB, 1, disp + curOfs); + curOfs += 8; } for (; curOfs <= memSize - 4; curOfs += 4) @@ -14738,7 +14762,7 @@ void BeMCContext::Generate(BeFunction* function) mDbgPreferredRegs[32] = X64Reg_R8;*/ //mDbgPreferredRegs[8] = X64Reg_RAX; - mDebugging = function->mName == "??$Add@MW4RMWAtomicOrdering@Interlocked@Threading@System@bf@@$$04@Interlocked@Threading@System@bf@@SAMAEAMMW4RMWAtomicOrdering@Interlocked@Threading@System@bf@@$$04@Z"; + //mDebugging = function->mName == "?__BfStaticCtor@Blurg@bf@@SAXXZ"; //"?Main@Program@bf@@CAHPEAV?$Array1@PEAVString@System@bf@@@System@2@@Z"; //"?Hey@Blurg@bf@@SAXXZ"; diff --git a/IDEHelper/Backend/BeModule.cpp b/IDEHelper/Backend/BeModule.cpp index 32195507..efba57b3 100644 --- a/IDEHelper/Backend/BeModule.cpp +++ b/IDEHelper/Backend/BeModule.cpp @@ -1963,6 +1963,8 @@ String BeModule::ToString(BeFunction* wantFunc) str += " noreturn"; if (func->mNoFramePointerElim) str += " noframepointerelim"; + if (func->mIsDLLExport) + str += " dllexport"; if (func->mBlocks.size() == 0) { @@ -2970,6 +2972,9 @@ BeFunction* BeModule::CreateFunction(BeFunctionType* funcType, BfIRLinkageType l func->mLinkageType = linkageType; func->mParams.Resize(funcType->mParams.size()); mFunctions.push_back(func); +#ifdef _DEBUG + BF_ASSERT(mFunctionMap.TryAdd(name, func)); +#endif return func; } diff --git a/IDEHelper/Backend/BeModule.h b/IDEHelper/Backend/BeModule.h index 9aa67ce6..eeaba408 100644 --- a/IDEHelper/Backend/BeModule.h +++ b/IDEHelper/Backend/BeModule.h @@ -447,6 +447,8 @@ public: bool mNoReturn; bool mDidInlinePass; bool mNoFramePointerElim; + bool mIsDLLExport; + bool mIsDLLImport; BfIRCallingConv mCallingConv; Array mBlocks; Array mParams; @@ -467,6 +469,8 @@ public: mUWTable = false; mNoReturn = false; mNoFramePointerElim = false; + mIsDLLExport = false; + mIsDLLImport = false; mRemapBindVar = NULL; mCurElementId = 0; } @@ -2056,6 +2060,7 @@ public: BeDbgLoc* mLastDbgLoc; Array mArgs; Array mFunctions; + Dictionary mFunctionMap; int mCurDbgLocIdx; int mCurLexBlockId; diff --git a/IDEHelper/Compiler/BfCompiler.cpp b/IDEHelper/Compiler/BfCompiler.cpp index 6da47507..2d5b1a94 100644 --- a/IDEHelper/Compiler/BfCompiler.cpp +++ b/IDEHelper/Compiler/BfCompiler.cpp @@ -477,7 +477,13 @@ bool BfCompiler::IsTypeUsed(BfType* checkType, BfProject* curProject) BfTypeInstance* typeInst = checkType->ToTypeInstance(); if (typeInst != NULL) - { + { + if ((typeInst->mTypeDef->mProject != NULL) && (typeInst->mTypeDef->mProject != curProject)) + { + if (typeInst->mTypeDef->mProject->mTargetType == BfTargetType_BeefDynLib) + return false; + } + if (checkType->IsInterface()) return typeInst->mIsReified; @@ -757,6 +763,211 @@ BfIRFunction BfCompiler::CreateLoadSharedLibraries(BfVDataModule* bfModule, Arra return loadSharedLibFunc; } +void BfCompiler::GetTestMethods(BfVDataModule* bfModule, Array& testMethods, HashContext& vdataHashCtx) +{ + vdataHashCtx.Mixin(0xBEEF0001); // Marker + + auto _CheckMethod = [&](BfTypeInstance* typeInstance, BfMethodInstance* methodInstance) + { + auto project = typeInstance->mTypeDef->mProject; + if (project->mTargetType != BfTargetType_BeefTest) + return; + if (project != bfModule->mProject) + return; + + bool isTest = false; + if ((methodInstance->GetCustomAttributes() != NULL) && + (methodInstance->GetCustomAttributes()->Contains(mTestAttributeTypeDef))) + isTest = true; + if (!isTest) + return; + + if (!methodInstance->mMethodDef->mIsStatic) + { + bfModule->Fail(StrFormat("Method '%s' cannot be used for testing because it is not static", bfModule->MethodToString(methodInstance).c_str()), + methodInstance->mMethodDef->GetRefNode()); + bfModule->mHadBuildError = true; + return; + } + + if (methodInstance->GetParamCount() > 0) + { + if ((methodInstance->GetParamInitializer(0) == NULL) && + (methodInstance->GetParamKind(0) != BfParamKind_Params)) + { + bfModule->Fail(StrFormat("Method '%s' cannot be used for testing because it contains parameters without defaults", bfModule->MethodToString(methodInstance).c_str()), + methodInstance->mMethodDef->GetRefNode()); + bfModule->mHadBuildError = true; + return; + } + } + + BF_ASSERT(typeInstance->IsReified()); + + TestMethod testMethod; + testMethod.mMethodInstance = methodInstance; + testMethods.Add(testMethod); + + if (!bfModule->mProject->mUsedModules.Contains(typeInstance->mModule)) + bfModule->mProject->mUsedModules.Add(typeInstance->mModule); + + vdataHashCtx.Mixin(methodInstance->GetOwner()->mTypeId); + vdataHashCtx.Mixin(methodInstance->mMethodDef->mIdx); + }; + + + for (auto type : mContext->mResolvedTypes) + { + auto typeInstance = type->ToTypeInstance(); + if (typeInstance == NULL) + continue; + + for (auto& methodInstanceGroup : typeInstance->mMethodInstanceGroups) + { + if (methodInstanceGroup.mDefault != NULL) + { + _CheckMethod(typeInstance, methodInstanceGroup.mDefault); + } + } + } +} + +void BfCompiler::EmitTestMethod(BfVDataModule* bfModule, Array& testMethods, BfIRValue& retValue) +{ + for (auto& testMethod : testMethods) + { + auto methodInstance = testMethod.mMethodInstance; + auto typeInstance = methodInstance->GetOwner(); + testMethod.mName += bfModule->TypeToString(typeInstance); + testMethod.mName += "."; + testMethod.mName += methodInstance->mMethodDef->mName; + + testMethod.mName += "\t"; + auto testAttribute = methodInstance->GetCustomAttributes()->Get(mTestAttributeTypeDef); + for (auto& field : testAttribute->mSetField) + { + auto constant = typeInstance->mConstHolder->GetConstant(field.mParam.mValue); + if ((constant != NULL) && (constant->mTypeCode == BfTypeCode_Boolean) && (constant->mBool)) + { + BfFieldDef* fieldDef = field.mFieldRef; + if (fieldDef->mName == "ShouldFail") + { + testMethod.mName += "Sf"; + } + else if (fieldDef->mName == "Profile") + { + testMethod.mName += "Pr"; + } + else if (fieldDef->mName == "Ignore") + { + testMethod.mName += "Ig"; + } + } + } + + bfModule->UpdateSrcPos(methodInstance->mMethodDef->GetRefNode(), (BfSrcPosFlags)(BfSrcPosFlag_NoSetDebugLoc | BfSrcPosFlag_Force)); + testMethod.mName += StrFormat("\t%s\t%d\t%d", bfModule->mCurFilePosition.mFileInstance->mParser->mFileName.c_str(), bfModule->mCurFilePosition.mCurLine, bfModule->mCurFilePosition.mCurColumn); + } + + std::stable_sort(testMethods.begin(), testMethods.end(), + [](const TestMethod& lhs, const TestMethod& rhs) + { + return lhs.mName < rhs.mName; + }); + + String methodData; + for (int methodIdx = 0; methodIdx < (int)testMethods.size(); methodIdx++) + { + String& methodName = testMethods[methodIdx].mName; + if (!methodData.IsEmpty()) + methodData += "\n"; + methodData += methodName; + } + + ////////////////////////////////////////////////////////////////////////// + + auto testInitMethod = bfModule->GetInternalMethod("Test_Init"); + auto testQueryMethod = bfModule->GetInternalMethod("Test_Query"); + auto testFinishMethod = bfModule->GetInternalMethod("Test_Finish"); + + auto char8PtrType = bfModule->CreatePointerType(bfModule->GetPrimitiveType(BfTypeCode_Char8)); + + BfIRType strCharType = bfModule->mBfIRBuilder->GetSizedArrayType(bfModule->mBfIRBuilder->GetPrimitiveType(BfTypeCode_Char8), (int)methodData.length() + 1); + BfIRValue strConstant = bfModule->mBfIRBuilder->CreateConstString(methodData); + BfIRValue gv = bfModule->mBfIRBuilder->CreateGlobalVariable(strCharType, + true, BfIRLinkageType_External, + strConstant, "__bfTestData"); + BfIRValue strPtrVal = bfModule->mBfIRBuilder->CreateBitCast(gv, bfModule->mBfIRBuilder->MapType(char8PtrType)); + + SizedArray irArgs; + irArgs.Add(strPtrVal); + bfModule->mBfIRBuilder->CreateCall(testInitMethod.mFunc, irArgs); + + BfIRBlock testHeadBlock = bfModule->mBfIRBuilder->CreateBlock("testHead"); + BfIRBlock testEndBlock = bfModule->mBfIRBuilder->CreateBlock("testEnd"); + + bfModule->mBfIRBuilder->CreateBr(testHeadBlock); + bfModule->mBfIRBuilder->AddBlock(testHeadBlock); + bfModule->mBfIRBuilder->SetInsertPoint(testHeadBlock); + + irArgs.clear(); + auto testVal = bfModule->mBfIRBuilder->CreateCall(testQueryMethod.mFunc, irArgs); + + auto switchVal = bfModule->mBfIRBuilder->CreateSwitch(testVal, testEndBlock, (int)testMethods.size()); + + for (int methodIdx = 0; methodIdx < (int)testMethods.size(); methodIdx++) + { + auto methodInstance = testMethods[methodIdx].mMethodInstance; + String& methodName = testMethods[methodIdx].mName; + + auto testBlock = bfModule->mBfIRBuilder->CreateBlock(StrFormat("test%d", methodIdx)); + bfModule->mBfIRBuilder->AddSwitchCase(switchVal, bfModule->mBfIRBuilder->CreateConst(BfTypeCode_Int32, methodIdx), testBlock); + + bfModule->mBfIRBuilder->AddBlock(testBlock); + bfModule->mBfIRBuilder->SetInsertPoint(testBlock); + + auto moduleMethodInstance = bfModule->ReferenceExternalMethodInstance(methodInstance); + irArgs.clear(); + if (methodInstance->GetParamCount() > 0) + { + if (methodInstance->GetParamKind(0) == BfParamKind_Params) + { + auto paramType = methodInstance->GetParamType(0); + auto paramTypeInst = paramType->ToTypeInstance(); + BfTypedValue paramVal = BfTypedValue(bfModule->mBfIRBuilder->CreateAlloca(bfModule->mBfIRBuilder->MapTypeInst(paramTypeInst)), paramType); + bfModule->InitTypeInst(paramVal, NULL, false, BfIRValue()); + + //TODO: Assert 'length' var is at slot 1 + auto arrayBits = bfModule->mBfIRBuilder->CreateBitCast(paramVal.mValue, bfModule->mBfIRBuilder->MapType(paramTypeInst->mBaseType)); + auto addr = bfModule->mBfIRBuilder->CreateInBoundsGEP(arrayBits, 0, 1); + auto storeInst = bfModule->mBfIRBuilder->CreateAlignedStore(bfModule->GetConstValue(0), addr, 4); + + irArgs.Add(paramVal.mValue); + } + else + { + for (int defaultIdx = 0; defaultIdx < (int)methodInstance->mDefaultValues.size(); defaultIdx++) + { + irArgs.Add(methodInstance->mDefaultValues[defaultIdx]); + } + } + } + + BfExprEvaluator exprEvaluator(bfModule); + exprEvaluator.CreateCall(moduleMethodInstance.mMethodInstance, moduleMethodInstance.mFunc, false, irArgs); + + bfModule->mBfIRBuilder->CreateBr(testHeadBlock); + } + + bfModule->mBfIRBuilder->AddBlock(testEndBlock); + bfModule->mBfIRBuilder->SetInsertPoint(testEndBlock); + + irArgs.clear(); + bfModule->mBfIRBuilder->CreateCall(testFinishMethod.mFunc, irArgs); + + retValue = bfModule->mBfIRBuilder->CreateConst(BfTypeCode_Int32, 0); +} + void BfCompiler::CreateVData(BfVDataModule* bfModule) { bool isHotCompile = IsHotCompile(); @@ -842,81 +1053,9 @@ void BfCompiler::CreateVData(BfVDataModule* bfModule) vdataHashCtx.Mixin(bfModule->mProject->mVDataConfigHash); - struct _TestMethod - { - String mName; - BfMethodInstance* mMethodInstance; - }; - Array<_TestMethod> testMethods; - + Array testMethods; if (project->mTargetType == BfTargetType_BeefTest) - { - vdataHashCtx.Mixin(0xBEEF0001); // Marker - - auto _CheckMethod = [&](BfTypeInstance* typeInstance, BfMethodInstance* methodInstance) - { - auto project = typeInstance->mTypeDef->mProject; - if (project->mTargetType != BfTargetType_BeefTest) - return; - if (project != bfModule->mProject) - return; - - bool isTest = false; - if ((methodInstance->GetCustomAttributes() != NULL) && - (methodInstance->GetCustomAttributes()->Contains(mTestAttributeTypeDef))) - isTest = true; - if (!isTest) - return; - - if (!methodInstance->mMethodDef->mIsStatic) - { - bfModule->Fail(StrFormat("Method '%s' cannot be used for testing because it is not static", bfModule->MethodToString(methodInstance).c_str()), - methodInstance->mMethodDef->GetRefNode()); - bfModule->mHadBuildError = true; - return; - } - - if (methodInstance->GetParamCount() > 0) - { - if ((methodInstance->GetParamInitializer(0) == NULL) && - (methodInstance->GetParamKind(0) != BfParamKind_Params)) - { - bfModule->Fail(StrFormat("Method '%s' cannot be used for testing because it contains parameters without defaults", bfModule->MethodToString(methodInstance).c_str()), - methodInstance->mMethodDef->GetRefNode()); - bfModule->mHadBuildError = true; - return; - } - } - - BF_ASSERT(typeInstance->IsReified()); - - _TestMethod testMethod; - testMethod.mMethodInstance = methodInstance; - testMethods.Add(testMethod); - - if (!bfModule->mProject->mUsedModules.Contains(typeInstance->mModule)) - bfModule->mProject->mUsedModules.Add(typeInstance->mModule); - - vdataHashCtx.Mixin(methodInstance->GetOwner()->mTypeId); - vdataHashCtx.Mixin(methodInstance->mMethodDef->mIdx); - }; - - - for (auto type : mContext->mResolvedTypes) - { - auto typeInstance = type->ToTypeInstance(); - if (typeInstance == NULL) - continue; - - for (auto& methodInstanceGroup : typeInstance->mMethodInstanceGroups) - { - if (methodInstanceGroup.mDefault != NULL) - { - _CheckMethod(typeInstance, methodInstanceGroup.mDefault); - } - } - } - } + GetTestMethods(bfModule, testMethods, vdataHashCtx); Array vdataTypeList; std::multimap sortedStaticInitMap; @@ -956,7 +1095,7 @@ void BfCompiler::CreateVData(BfVDataModule* bfModule) auto module = typeInst->mModule; if (module == NULL) continue; - + if (type->IsInterface()) vdataHashCtx.Mixin(typeInst->mSlotNum); @@ -997,7 +1136,14 @@ void BfCompiler::CreateVData(BfVDataModule* bfModule) { vdataHashCtx.Mixin(baseType->mTypeDef->mSignatureHash); baseType = baseType->mBaseType; - } + } + + if (module->mProject != bfModule->mProject) + { + if ((module->mProject != NULL) && (module->mProject->mTargetType == BfTargetType_BeefDynLib)) + continue; + } + if (typeInst->mHasStaticInitMethod) sortedStaticInitMap.insert(std::make_pair(bfModule->TypeToString(type), typeInst)); else if (typeInst->mHasStaticDtorMethod) // Only store types not already in the static init map @@ -1437,6 +1583,17 @@ void BfCompiler::CreateVData(BfVDataModule* bfModule) mainFuncType = bfModule->mBfIRBuilder->CreateFunctionType(int32Type, paramTypes, false); mainFunc = bfModule->mBfIRBuilder->CreateFunction(mainFuncType, BfIRLinkageType_External, "main"); } + else if (project->mTargetType == BfTargetType_BeefDynLib) + { + SmallVector paramTypes; + paramTypes.push_back(nullPtrType); // hinstDLL + paramTypes.push_back(int32Type); // fdwReason + paramTypes.push_back(nullPtrType); // lpvReserved + mainFuncType = bfModule->mBfIRBuilder->CreateFunctionType(int32Type, paramTypes, false); + mainFunc = bfModule->mBfIRBuilder->CreateFunction(mainFuncType, BfIRLinkageType_External, "DllMain"); + if (mSystem->mPtrSize == 4) + bfModule->mBfIRBuilder->SetFuncCallingConv(mainFunc, BfIRCallingConv_StdCall); + } else if (project->mTargetType == BfTargetType_BeefWindowsApplication) { SmallVector paramTypes; @@ -1478,6 +1635,17 @@ void BfCompiler::CreateVData(BfVDataModule* bfModule) } #endif + BfIRBlock initSkipBlock; + if (project->mTargetType == BfTargetType_BeefDynLib) + { + auto initBlock = bfModule->mBfIRBuilder->CreateBlock("doInit", false); + initSkipBlock = bfModule->mBfIRBuilder->CreateBlock("skipInit", false); + auto cmpResult = bfModule->mBfIRBuilder->CreateCmpEQ(bfModule->mBfIRBuilder->GetArgument(1), bfModule->mBfIRBuilder->CreateConst(BfTypeCode_Int32, 1)); + bfModule->mBfIRBuilder->CreateCondBr(cmpResult, initBlock, initSkipBlock); + bfModule->mBfIRBuilder->AddBlock(initBlock); + bfModule->mBfIRBuilder->SetInsertPoint(initBlock); + } + // Do the LoadLibrary calls below priority 100 bool didSharedLibLoad = false; auto _CheckSharedLibLoad = [&]() @@ -1516,6 +1684,13 @@ void BfCompiler::CreateVData(BfVDataModule* bfModule) _CheckSharedLibLoad(); + if (initSkipBlock) + { + bfModule->mBfIRBuilder->CreateBr(initSkipBlock); + bfModule->mBfIRBuilder->AddBlock(initSkipBlock); + bfModule->mBfIRBuilder->SetInsertPoint(initSkipBlock); + } + BfIRValue retValue; if ((project->mTargetType == BfTargetType_BeefConsoleApplication) || (project->mTargetType == BfTargetType_BeefWindowsApplication)) { @@ -1655,142 +1830,24 @@ void BfCompiler::CreateVData(BfVDataModule* bfModule) if (!hadRet) retValue = bfModule->GetConstValue32(0); - } + } + else if (project->mTargetType == BfTargetType_BeefDynLib) + { + retValue = bfModule->GetConstValue32(1); + } if (project->mTargetType == BfTargetType_BeefTest) + EmitTestMethod(bfModule, testMethods, retValue); + + BfIRBlock deinitSkipBlock; + if (project->mTargetType == BfTargetType_BeefDynLib) { - for (auto& testMethod : testMethods) - { - auto methodInstance = testMethod.mMethodInstance; - auto typeInstance = methodInstance->GetOwner(); - testMethod.mName += bfModule->TypeToString(typeInstance); - testMethod.mName += "."; - testMethod.mName += methodInstance->mMethodDef->mName; - - testMethod.mName += "\t"; - auto testAttribute = methodInstance->GetCustomAttributes()->Get(mTestAttributeTypeDef); - for (auto& field : testAttribute->mSetField) - { - auto constant = typeInstance->mConstHolder->GetConstant(field.mParam.mValue); - if ((constant != NULL) && (constant->mTypeCode == BfTypeCode_Boolean) && (constant->mBool)) - { - BfFieldDef* fieldDef = field.mFieldRef; - if (fieldDef->mName == "ShouldFail") - { - testMethod.mName += "Sf"; - } - else if (fieldDef->mName == "Profile") - { - testMethod.mName += "Pr"; - } - else if (fieldDef->mName == "Ignore") - { - testMethod.mName += "Ig"; - } - } - } - - bfModule->UpdateSrcPos(methodInstance->mMethodDef->GetRefNode(), (BfSrcPosFlags)(BfSrcPosFlag_NoSetDebugLoc | BfSrcPosFlag_Force)); - testMethod.mName += StrFormat("\t%s\t%d\t%d", bfModule->mCurFilePosition.mFileInstance->mParser->mFileName.c_str(), bfModule->mCurFilePosition.mCurLine, bfModule->mCurFilePosition.mCurColumn); - } - - std::stable_sort(testMethods.begin(), testMethods.end(), - [](const _TestMethod& lhs, const _TestMethod& rhs) - { - return lhs.mName < rhs.mName; - }); - - String methodData; - for (int methodIdx = 0; methodIdx < (int)testMethods.size(); methodIdx++) - { - String& methodName = testMethods[methodIdx].mName; - if (!methodData.IsEmpty()) - methodData += "\n"; - methodData += methodName; - } - - ////////////////////////////////////////////////////////////////////////// - - auto testInitMethod = bfModule->GetInternalMethod("Test_Init"); - auto testQueryMethod = bfModule->GetInternalMethod("Test_Query"); - auto testFinishMethod = bfModule->GetInternalMethod("Test_Finish"); - - auto char8PtrType = bfModule->CreatePointerType(bfModule->GetPrimitiveType(BfTypeCode_Char8)); - - BfIRType strCharType = bfModule->mBfIRBuilder->GetSizedArrayType(bfModule->mBfIRBuilder->GetPrimitiveType(BfTypeCode_Char8), (int)methodData.length() + 1); - BfIRValue strConstant = bfModule->mBfIRBuilder->CreateConstString(methodData); - BfIRValue gv = bfModule->mBfIRBuilder->CreateGlobalVariable(strCharType, - true, BfIRLinkageType_External, - strConstant, "__bfTestData"); - BfIRValue strPtrVal = bfModule->mBfIRBuilder->CreateBitCast(gv, bfModule->mBfIRBuilder->MapType(char8PtrType)); - - SizedArray irArgs; - irArgs.Add(strPtrVal); - bfModule->mBfIRBuilder->CreateCall(testInitMethod.mFunc, irArgs); - - BfIRBlock testHeadBlock = bfModule->mBfIRBuilder->CreateBlock("testHead"); - BfIRBlock testEndBlock = bfModule->mBfIRBuilder->CreateBlock("testEnd"); - - bfModule->mBfIRBuilder->CreateBr(testHeadBlock); - bfModule->mBfIRBuilder->AddBlock(testHeadBlock); - bfModule->mBfIRBuilder->SetInsertPoint(testHeadBlock); - - irArgs.clear(); - auto testVal = bfModule->mBfIRBuilder->CreateCall(testQueryMethod.mFunc, irArgs); - - auto switchVal = bfModule->mBfIRBuilder->CreateSwitch(testVal, testEndBlock, (int)testMethods.size()); - - for (int methodIdx = 0; methodIdx < (int)testMethods.size(); methodIdx++) - { - auto methodInstance = testMethods[methodIdx].mMethodInstance; - String& methodName = testMethods[methodIdx].mName; - - auto testBlock = bfModule->mBfIRBuilder->CreateBlock(StrFormat("test%d", methodIdx)); - bfModule->mBfIRBuilder->AddSwitchCase(switchVal, bfModule->mBfIRBuilder->CreateConst(BfTypeCode_Int32, methodIdx), testBlock); - - bfModule->mBfIRBuilder->AddBlock(testBlock); - bfModule->mBfIRBuilder->SetInsertPoint(testBlock); - - auto moduleMethodInstance = bfModule->ReferenceExternalMethodInstance(methodInstance); - irArgs.clear(); - if (methodInstance->GetParamCount() > 0) - { - if (methodInstance->GetParamKind(0) == BfParamKind_Params) - { - auto paramType = methodInstance->GetParamType(0); - auto paramTypeInst = paramType->ToTypeInstance(); - BfTypedValue paramVal = BfTypedValue(bfModule->mBfIRBuilder->CreateAlloca(bfModule->mBfIRBuilder->MapTypeInst(paramTypeInst)), paramType); - bfModule->InitTypeInst(paramVal, NULL, false, BfIRValue()); - - //TODO: Assert 'length' var is at slot 1 - auto arrayBits = bfModule->mBfIRBuilder->CreateBitCast(paramVal.mValue, bfModule->mBfIRBuilder->MapType(paramTypeInst->mBaseType)); - auto addr = bfModule->mBfIRBuilder->CreateInBoundsGEP(arrayBits, 0, 1); - auto storeInst = bfModule->mBfIRBuilder->CreateAlignedStore(bfModule->GetConstValue(0), addr, 4); - - irArgs.Add(paramVal.mValue); - } - else - { - for (int defaultIdx = 0; defaultIdx < (int)methodInstance->mDefaultValues.size(); defaultIdx++) - { - irArgs.Add(methodInstance->mDefaultValues[defaultIdx]); - } - } - } - - BfExprEvaluator exprEvaluator(bfModule); - exprEvaluator.CreateCall(moduleMethodInstance.mMethodInstance, moduleMethodInstance.mFunc, false, irArgs); - - bfModule->mBfIRBuilder->CreateBr(testHeadBlock); - } - - bfModule->mBfIRBuilder->AddBlock(testEndBlock); - bfModule->mBfIRBuilder->SetInsertPoint(testEndBlock); - - irArgs.clear(); - bfModule->mBfIRBuilder->CreateCall(testFinishMethod.mFunc, irArgs); - - retValue = bfModule->mBfIRBuilder->CreateConst(BfTypeCode_Int32, 0); + auto deinitBlock = bfModule->mBfIRBuilder->CreateBlock("doDeinit", false); + deinitSkipBlock = bfModule->mBfIRBuilder->CreateBlock("skipDeinit", false); + auto cmpResult = bfModule->mBfIRBuilder->CreateCmpEQ(bfModule->mBfIRBuilder->GetArgument(1), bfModule->mBfIRBuilder->CreateConst(BfTypeCode_Int32, 0)); + bfModule->mBfIRBuilder->CreateCondBr(cmpResult, deinitBlock, deinitSkipBlock); + bfModule->mBfIRBuilder->AddBlock(deinitBlock); + bfModule->mBfIRBuilder->SetInsertPoint(deinitBlock); } bfModule->mBfIRBuilder->CreateCall(dtorFunc, SizedArray()); @@ -1801,6 +1858,13 @@ void BfCompiler::CreateVData(BfVDataModule* bfModule) bfModule->mBfIRBuilder->CreateCall(shutdownMethod.mFunc, SizedArray()); } + if (deinitSkipBlock) + { + bfModule->mBfIRBuilder->CreateBr(deinitSkipBlock); + bfModule->mBfIRBuilder->AddBlock(deinitSkipBlock); + bfModule->mBfIRBuilder->SetInsertPoint(deinitSkipBlock); + } + if (retValue) bfModule->mBfIRBuilder->CreateRet(retValue); else @@ -5784,6 +5848,7 @@ bool BfCompiler::DoCompile(const StringImpl& outputDirectory) } if ((bfProject->mTargetType != BfTargetType_BeefConsoleApplication) && (bfProject->mTargetType != BfTargetType_BeefWindowsApplication) && + (bfProject->mTargetType != BfTargetType_BeefDynLib) && (bfProject->mTargetType != BfTargetType_C_ConsoleApplication) && (bfProject->mTargetType != BfTargetType_C_WindowsApplication) && (bfProject->mTargetType != BfTargetType_BeefTest)) continue; @@ -7866,6 +7931,11 @@ BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetUsedOutputFileNames(BfCompiler* { if (!bfProject->ContainsReference(project)) canReference = false; + if (bfProject != project) + { + if (project->mTargetType == BfTargetType_BeefDynLib) + canReference = false; + } } if (!canReference) continue; diff --git a/IDEHelper/Compiler/BfCompiler.h b/IDEHelper/Compiler/BfCompiler.h index cf04d10b..cb3af9ea 100644 --- a/IDEHelper/Compiler/BfCompiler.h +++ b/IDEHelper/Compiler/BfCompiler.h @@ -291,6 +291,12 @@ public: BfIRValue mStringVal; }; + struct TestMethod + { + String mName; + BfMethodInstance* mMethodInstance; + }; + public: BfPassInstance* mPassInstance; FILE* mCompileLogFP; @@ -386,6 +392,8 @@ public: void CheckModuleStringRefs(BfModule* module, BfVDataModule* vdataModule, int lastModuleRevision, HashSet& foundStringIds, HashSet& dllNameSet, Array& dllMethods, Array& stringValueEntries); void HashModuleVData(BfModule* module, HashContext& hash); BfIRFunction CreateLoadSharedLibraries(BfVDataModule* bfModule, Array& dllMethods); + void GetTestMethods(BfVDataModule* bfModule, Array& testMethods, HashContext& vdataHashCtx); + void EmitTestMethod(BfVDataModule* bfModule, Array& testMethods, BfIRValue& retValue); void CreateVData(BfVDataModule* bfModule); void UpdateDependencyMap(bool deleteUnusued, bool& didWork); void ProcessPurgatory(bool reifiedOnly); diff --git a/IDEHelper/Compiler/BfDefBuilder.cpp b/IDEHelper/Compiler/BfDefBuilder.cpp index f3b1f9bb..77eee6dc 100644 --- a/IDEHelper/Compiler/BfDefBuilder.cpp +++ b/IDEHelper/Compiler/BfDefBuilder.cpp @@ -652,6 +652,11 @@ void BfDefBuilder::ParseAttributes(BfAttributeDirective* attributes, BfMethodDef methodDef->mCheckedKind = BfCheckedKind_Checked; else if (typeRefName == "Unchecked") methodDef->mCheckedKind = BfCheckedKind_Unchecked; + else if (typeRefName == "Export") + { + mCurTypeDef->mIsAlwaysInclude = true; + methodDef->mImportKind = BfImportKind_Export; + } else if (typeRefName == "Import") { methodDef->mImportKind = BfImportKind_Static; diff --git a/IDEHelper/Compiler/BfIRBuilder.cpp b/IDEHelper/Compiler/BfIRBuilder.cpp index 7f9cd3c6..19eeba0d 100644 --- a/IDEHelper/Compiler/BfIRBuilder.cpp +++ b/IDEHelper/Compiler/BfIRBuilder.cpp @@ -4305,6 +4305,11 @@ BfIRFunction BfIRBuilder::CreateFunction(BfIRFunctionType funcType, BfIRLinkageT NEW_CMD_INSERTED_IRVALUE; mFunctionMap[name] = retVal; + if (name == "??B?$Result@PEAX@System@bf@@SAPEAXU012@@Z") + { + NOP; + } + //BfLogSys(mModule->mSystem, "BfIRBuilder::CreateFunction: %d %s Module:%p\n", retVal.mId, name.c_str(), mModule); return retVal; @@ -4842,15 +4847,15 @@ BfIRMDNode BfIRBuilder::DbgCreateMethod(BfIRMDNode context, const StringImpl& na BfIRMDNode retVal = WriteCmd(BfIRCmd_DbgCreateMethod, context, name, linkageName, file, lineNum, type, isLocalToUnit, isDefinition, vk, vIndex, vTableHolder, flags, isOptimized, fn, genericArgs, genericConstValueArgs); NEW_CMD_INSERTED_IRMD; - if (vIndex == 8) + if (linkageName == "?Unwrap@?$Result@PEAX@System@bf@@AEAAPEAXXZ") { NOP; } - if (mDbgVerifyCodeGen && gDebugDbgLoc) - { - OutputDebugStrF("DbgCreateFunction Context:%d name:%s = %d\n", context.mId, name.c_str(), retVal.mId); - } +// if (mDbgVerifyCodeGen && gDebugDbgLoc) +// { +// OutputDebugStrF("DbgCreateFunction Context:%d name:%s = %d\n", context.mId, name.c_str(), retVal.mId); +// } return retVal; } @@ -4860,10 +4865,10 @@ BfIRMDNode BfIRBuilder::DbgCreateFunction(BfIRMDNode context, const StringImpl& BfIRMDNode retVal = WriteCmd(BfIRCmd_DbgCreateFunction, context, name, linkageName, file, lineNum, type, isLocalToUnit, isDefinition, scopeLine, flags, isOptimized, fn); NEW_CMD_INSERTED_IRMD; - if (mDbgVerifyCodeGen && gDebugDbgLoc) - { - OutputDebugStrF("DbgCreateFunction Context:%d name:%s = %d\n", context.mId, name.c_str(), retVal.mId); - } +// if (mDbgVerifyCodeGen && gDebugDbgLoc) +// { +// OutputDebugStrF("DbgCreateFunction Context:%d name:%s = %d\n", context.mId, name.c_str(), retVal.mId); +// } return retVal; } diff --git a/IDEHelper/Compiler/BfModule.cpp b/IDEHelper/Compiler/BfModule.cpp index f29998b9..834d50a8 100644 --- a/IDEHelper/Compiler/BfModule.cpp +++ b/IDEHelper/Compiler/BfModule.cpp @@ -1118,8 +1118,8 @@ void BfModule::EnsureIRBuilder(bool dbgVerifyCodeGen) // code as we walk the AST //mBfIRBuilder->mDbgVerifyCodeGen = true; if ( - (mModuleName == "Color") - || (mModuleName == "Tests_FuncRefs") + (mModuleName == "vdata") + || (mModuleName == "System_Result_PTR_void") //|| (mModuleName == "vdata") || (mModuleName == "Hey_Dude_Bro_TestClass") ) @@ -4474,7 +4474,7 @@ BfIRValue BfModule::CreateTypeData(BfType* type, Dictionary& usedStrin BF_ASSERT(!methodInstance->GetOwner()->IsUnspecializedType()); // We need to create an empty thunk for this chained method - BfIRFunction func = CreateFunctionFrom(methodInstance); + BfIRFunction func = CreateFunctionFrom(methodInstance, false, methodInstance->mAlwaysInline); mBfIRBuilder->SetActiveFunction(func); auto block = mBfIRBuilder->CreateBlock("entry", true); mBfIRBuilder->SetInsertPoint(block); @@ -8494,6 +8494,15 @@ BfIRValue BfModule::CreateFunctionFrom(BfMethodInstance* methodInstance, bool tr if (callingConv != BfIRCallingConv_CDecl) mBfIRBuilder->SetFuncCallingConv(func, callingConv); SetupLLVMMethod(methodInstance, func, isInlined); + +// auto srcModule = methodInstance->GetOwner()->GetModule(); +// if ((srcModule != NULL) && (srcModule->mProject != mProject)) +// { +// if (srcModule->mProject->mTargetType == BfTargetType_BeefDynLib) +// { +// mBfIRBuilder->Func_AddAttribute(func, -1, BFIRAttribute_DllImport); +// } +// } return func; } @@ -10485,12 +10494,7 @@ void BfModule::AddMethodReference(const BfMethodRef& methodRef, BfGetMethodInsta } BfModuleMethodInstance BfModule::ReferenceExternalMethodInstance(BfMethodInstance* methodInstance, BfGetMethodInstanceFlags flags) -{ - if (methodInstance->mMethodDef->mName == "OpenAudio") - { - NOP; - } - +{ if ((flags & BfGetMethodInstanceFlag_ResultNotUsed) != 0) return BfModuleMethodInstance(methodInstance, BfIRValue()); @@ -11067,7 +11071,7 @@ BfModuleMethodInstance BfModule::GetMethodInstance(BfTypeInstance* typeInst, BfM if (!mIsModuleMutable) StartExtension(); - if (!mBfIRBuilder->mIgnoreWrites) + if ((!mBfIRBuilder->mIgnoreWrites) && (methodInstance->mDeclModule != NULL)) { StringT<128> mangledName; BfMangler::Mangle(mangledName, mCompiler->GetMangleKind(), methodInstance); @@ -11127,41 +11131,9 @@ BfModuleMethodInstance BfModule::GetMethodInstance(BfTypeInstance* typeInst, BfM } if ((methodInstance != NULL) && (!doingRedeclare)) - { - if (mExtensionCount > 0) - { - if ((mIsModuleMutable) && (!methodInstance->mIRFunction) && - ((projectList.IsEmpty() || ((flags & BfGetMethodInstanceFlag_ExplicitSpecializedModule) != 0)))) - { - SetAndRestoreValue prevIgnoreWrites(mBfIRBuilder->mIgnoreWrites, false); - - if (mAwaitingInitFinish) - FinishInit(); - - // We need to refer to a function that was defined in a prior module - methodInstance->mIRFunction = CreateFunctionFrom(methodInstance); - BF_ASSERT((methodInstance->mDeclModule == this) || (methodInstance->mDeclModule == mContext->mUnreifiedModule) || (methodInstance->mDeclModule == NULL)); - methodInstance->mDeclModule = this; - - // Add this inlined def to ourselves - if ((methodInstance->mAlwaysInline) && (HasCompiledOutput()) && (!methodInstance->mIsUnspecialized)) - { - mIncompleteMethodCount++; - BfInlineMethodRequest* inlineMethodRequest = mContext->mInlineMethodWorkList.Alloc(); - inlineMethodRequest->mType = typeInst; - inlineMethodRequest->mFromModule = this; - inlineMethodRequest->mFunc = methodInstance->mIRFunction; - inlineMethodRequest->mFromModuleRevision = mRevision; - inlineMethodRequest->mMethodInstance = methodInstance; - - BfLogSysM("mInlineMethodWorkList %p for method %p in module %p in GetMethodInstance\n", inlineMethodRequest, methodInstance, this); - BF_ASSERT(mIsModuleMutable); - } - } - } - + { if (methodInstance->mMethodInstanceGroup->mOnDemandKind == BfMethodOnDemandKind_Decl_AwaitingReference) - { + { /*if ((!mCompiler->mIsResolveOnly) && (!isReified)) BF_ASSERT(!methodInstance->mIsReified);*/ @@ -11191,6 +11163,44 @@ BfModuleMethodInstance BfModule::GetMethodInstance(BfTypeInstance* typeInst, BfM } } + if (mExtensionCount > 0) + { + if ((mIsModuleMutable) && (!methodInstance->mIRFunction) && + ((projectList.IsEmpty() || ((flags & BfGetMethodInstanceFlag_ExplicitSpecializedModule) != 0)))) + { + SetAndRestoreValue prevIgnoreWrites(mBfIRBuilder->mIgnoreWrites, false); + + if ((methodInstance->mMethodDef->mName == "Unwrap") && (mModuleName == "System_Result_PTR_void")) + { + NOP; + } + + if (mAwaitingInitFinish) + FinishInit(); + + // We need to refer to a function that was defined in a prior module + bool isInlined = (methodInstance->mAlwaysInline) || ((flags & BfGetMethodInstanceFlag_ForceInline) != 0); + methodInstance->mIRFunction = CreateFunctionFrom(methodInstance, false, isInlined); + BF_ASSERT((methodInstance->mDeclModule == this) || (methodInstance->mDeclModule == mContext->mUnreifiedModule) || (methodInstance->mDeclModule == NULL)); + methodInstance->mDeclModule = this; + + // Add this inlined def to ourselves + if ((methodInstance->mAlwaysInline) && (HasCompiledOutput()) && (!methodInstance->mIsUnspecialized)) + { + mIncompleteMethodCount++; + BfInlineMethodRequest* inlineMethodRequest = mContext->mInlineMethodWorkList.Alloc(); + inlineMethodRequest->mType = typeInst; + inlineMethodRequest->mFromModule = this; + inlineMethodRequest->mFunc = methodInstance->mIRFunction; + inlineMethodRequest->mFromModuleRevision = mRevision; + inlineMethodRequest->mMethodInstance = methodInstance; + + BfLogSysM("mInlineMethodWorkList %p for method %p in module %p in GetMethodInstance\n", inlineMethodRequest, methodInstance, this); + BF_ASSERT(mIsModuleMutable); + } + } + } + if (mCompiler->IsSkippingExtraResolveChecks()) return BfModuleMethodInstance(methodInstance, BfIRFunction()); else @@ -13545,6 +13555,8 @@ void BfModule::SetupLLVMMethod(BfMethodInstance* methodInstance, BfIRFunction fu if (mCompiler->mOptions.mNoFramePointerElim) mBfIRBuilder->Func_AddAttribute(func, -1, BFIRAttribute_NoFramePointerElim); + if (methodDef->mImportKind == BfImportKind_Export) + mBfIRBuilder->Func_AddAttribute(func, -1, BFIRAttribute_DllExport); mBfIRBuilder->Func_AddAttribute(func, -1, BFIRAttribute_NoUnwind); if (mSystem->mPtrSize == 8) // We need unwind info for debugging diff --git a/IDEHelper/Compiler/BfModule.h b/IDEHelper/Compiler/BfModule.h index 421a5f5c..cc26f618 100644 --- a/IDEHelper/Compiler/BfModule.h +++ b/IDEHelper/Compiler/BfModule.h @@ -1686,7 +1686,7 @@ public: void CreateValueTypeEqualsMethod(); BfIRFunction GetIntrinsic(BfMethodInstance* methodInstance, bool reportFailure = false); BfIRFunction GetBuiltInFunc(BfBuiltInFuncType funcType); - BfIRValue CreateFunctionFrom(BfMethodInstance* methodInstance, bool tryExisting = false, bool isInlined = false); + BfIRValue CreateFunctionFrom(BfMethodInstance* methodInstance, bool tryExisting, bool isInlined); void EvaluateWithNewScope(BfExprEvaluator& exprEvaluator, BfExpression* expr, BfEvalExprFlags flags); BfTypedValue CreateValueFromExpression(BfExprEvaluator& exprEvaluator, BfExpression* expr, BfType* wantTypeRef = NULL, BfEvalExprFlags flags = BfEvalExprFlags_None, BfType** outOrigType = NULL); BfTypedValue CreateValueFromExpression(BfExpression* expr, BfType* wantTypeRef = NULL, BfEvalExprFlags flags = BfEvalExprFlags_None, BfType** outOrigType = NULL); diff --git a/IDEHelper/Compiler/BfModuleTypeUtils.cpp b/IDEHelper/Compiler/BfModuleTypeUtils.cpp index c3bf747e..0865463a 100644 --- a/IDEHelper/Compiler/BfModuleTypeUtils.cpp +++ b/IDEHelper/Compiler/BfModuleTypeUtils.cpp @@ -3434,6 +3434,8 @@ void BfModule::DoTypeInstanceMethodProcessing(BfTypeInstance* typeInstance) if (typeRefName == "AlwaysInclude") implRequired = true; + else if (typeRefName == "Export") + implRequired = true; else if (typeRefName == "Test") implRequired = true; else @@ -4086,7 +4088,7 @@ void BfModule::AddMethodToWorkList(BfMethodInstance* methodInstance) auto module = GetOrCreateMethodModule(methodInstance); methodInstance->mDeclModule = module; - BfIRValue func = CreateFunctionFrom(methodInstance); + BfIRValue func = CreateFunctionFrom(methodInstance, false, methodInstance->mAlwaysInline); methodInstance->mIRFunction = func; module->mFuncReferences[methodInstance] = func; @@ -4892,8 +4894,10 @@ BfType* BfModule::ResolveInnerType(BfType* outerType, BfTypeReference* typeRef, while (checkOuterType != NULL) { for (auto checkType : checkOuterType->mTypeDef->mNestedTypes) - { - if ((!isFailurePass) && (!CheckProtection(checkType->mProtection, allowProtected, allowPrivate))) + { + auto latestCheckType = checkType->GetLatest(); + + if ((!isFailurePass) && (!CheckProtection(latestCheckType->mProtection, allowProtected, allowPrivate))) continue; if (checkType->mName->mString == findName) diff --git a/IDEHelper/Compiler/BfSystem.h b/IDEHelper/Compiler/BfSystem.h index 8f793117..8895f9d5 100644 --- a/IDEHelper/Compiler/BfSystem.h +++ b/IDEHelper/Compiler/BfSystem.h @@ -577,6 +577,7 @@ enum BfImportKind : int8 BfImportKind_None, BfImportKind_Static, BfImportKind_Dynamic, + BfImportKind_Export }; enum BfCheckedKind : int8 @@ -911,8 +912,9 @@ struct BfTypeDefMapFuncs : public MultiHashSetFuncs enum BfTargetType { BfTargetType_BeefConsoleApplication, - BfTargetType_BeefWindowsApplication, + BfTargetType_BeefWindowsApplication, BfTargetType_BeefLib, + BfTargetType_BeefDynLib, BfTargetType_CustomBuild, BfTargetType_C_ConsoleApplication, BfTargetType_C_WindowsApplication, diff --git a/IDEHelper/WinDebugger.cpp b/IDEHelper/WinDebugger.cpp index 9f54dc66..b75a91a7 100644 --- a/IDEHelper/WinDebugger.cpp +++ b/IDEHelper/WinDebugger.cpp @@ -8734,7 +8734,9 @@ DbgModule* WinDebugger::GetCallStackDbgModule(int callStackIdx) return mEmptyDebugTarget->GetMainDbgModule(); if (callStackIdx == -1) return mDebugTarget->GetMainDbgModule(); - FixCallStackIdx(callStackIdx); + FixCallStackIdx(callStackIdx); + if (callStackIdx >= mCallStack.size()) + return mDebugTarget->GetMainDbgModule(); UpdateCallStackMethod(callStackIdx); auto subProgram = mCallStack[callStackIdx]->mSubProgram; if (subProgram != NULL) diff --git a/bin/build.bat b/bin/build.bat index 7f5801ec..b2a80a1d 100644 --- a/bin/build.bat +++ b/bin/build.bat @@ -22,7 +22,7 @@ CALL bin/msbuild.bat IDEHelper\IDEHelper.vcxproj /p:Configuration=Debug /p:Platf CALL bin/msbuild.bat IDEHelper\IDEHelper.vcxproj /p:Configuration=Release /p:Platform=x64 /p:SolutionDir=%cd%\ /v:m %MSBUILD_FLAGS% @IF %ERRORLEVEL% NEQ 0 GOTO HADERROR -CALL bin/build_rt.bat +CALL bin/build_rt.bat %1 @IF %ERRORLEVEL% NEQ 0 GOTO HADERROR CALL bin/msbuild.bat BeefBoot\BeefBoot.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:SolutionDir=%cd%\ /v:m %MSBUILD_FLAGS% diff --git a/bin/build_rt.bat b/bin/build_rt.bat index edfb2a94..46c32a4c 100644 --- a/bin/build_rt.bat +++ b/bin/build_rt.bat @@ -1,85 +1,115 @@ PUSHD %~dp0..\ +@SET MSBUILD_FLAGS= +@IF "%1" NEQ "clean" goto BUILD +@SET MSBUILD_FLAGS=/t:Clean,Build +@ECHO Performing clean build +:BUILD + @ECHO @@@@@@@@@@@@@@ Win64 @@@@@@@@@@@@@@ @ECHO ---- Building BeefRT64 (Debug) ---- -CALL bin\msbuild.bat BeefRT\BeefRT.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:SolutionDir=%cd%\ /v:m +CALL bin\msbuild.bat BeefRT\BeefRT.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:SolutionDir=%cd%\ /v:m %MSBUILD_FLAGS% IF %ERRORLEVEL% NEQ 0 GOTO FAILED @ECHO ---- Building BeefRT64 (Debug Static) ---- -CALL bin\msbuild.bat BeefRT\BeefRT.vcxproj /p:Configuration="Debug Static" /p:Platform=x64 /p:SolutionDir=%cd%\ /v:m +CALL bin\msbuild.bat BeefRT\BeefRT.vcxproj /p:Configuration="Debug Static" /p:Platform=x64 /p:SolutionDir=%cd%\ /v:m %MSBUILD_FLAGS% IF %ERRORLEVEL% NEQ 0 GOTO FAILED @ECHO ---- Building BeefRT64 (Debug Static CStatic) ---- -CALL bin\msbuild.bat BeefRT\BeefRT.vcxproj /p:Configuration="Debug Static CStatic" /p:Platform=x64 /p:SolutionDir=%cd%\ /v:m +CALL bin\msbuild.bat BeefRT\BeefRT.vcxproj /p:Configuration="Debug Static CStatic" /p:Platform=x64 /p:SolutionDir=%cd%\ /v:m %MSBUILD_FLAGS% IF %ERRORLEVEL% NEQ 0 GOTO FAILED @ECHO ---- Building BeefRT64 (Release) ---- -CALL bin\msbuild.bat BeefRT\BeefRT.vcxproj /p:Configuration=Release /p:Platform=x64 /p:SolutionDir=%cd%\ /v:m +CALL bin\msbuild.bat BeefRT\BeefRT.vcxproj /p:Configuration=Release /p:Platform=x64 /p:SolutionDir=%cd%\ /v:m %MSBUILD_FLAGS% IF %ERRORLEVEL% NEQ 0 GOTO FAILED @ECHO ---- Building BeefRT64 (Release Static) ---- -CALL bin\msbuild.bat BeefRT\BeefRT.vcxproj /p:Configuration="Release Static" /p:Platform=x64 /p:SolutionDir=%cd%\ /v:m +CALL bin\msbuild.bat BeefRT\BeefRT.vcxproj /p:Configuration="Release Static" /p:Platform=x64 /p:SolutionDir=%cd%\ /v:m %MSBUILD_FLAGS% IF %ERRORLEVEL% NEQ 0 GOTO FAILED @ECHO ---- Building BeefRT6 (Release Static CStatic) ---- -CALL bin\msbuild.bat BeefRT\BeefRT.vcxproj /p:Configuration="Release Static CStatic" /p:Platform=x64 /p:SolutionDir=%cd%\ /v:m +CALL bin\msbuild.bat BeefRT\BeefRT.vcxproj /p:Configuration="Release Static CStatic" /p:Platform=x64 /p:SolutionDir=%cd%\ /v:m %MSBUILD_FLAGS% IF %ERRORLEVEL% NEQ 0 GOTO FAILED @ECHO ---- Building BeefDbg64 (Debug) ---- -CALL bin\msbuild.bat BeefRT\BeefDbg\BeefDbg.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:SolutionDir=%cd%\ /v:m +CALL bin\msbuild.bat BeefRT\BeefDbg\BeefDbg.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:SolutionDir=%cd%\ /v:m %MSBUILD_FLAGS% +IF %ERRORLEVEL% NEQ 0 GOTO FAILED +@ECHO ---- Building BeefDbg64 (Debug Static) ---- +CALL bin\msbuild.bat BeefRT\BeefDbg\BeefDbg.vcxproj /p:Configuration="Debug Static" /p:Platform=x64 /p:SolutionDir=%cd%\ /v:m %MSBUILD_FLAGS% +IF %ERRORLEVEL% NEQ 0 GOTO FAILED +@ECHO ---- Building BeefDbg64 (Debug Static CStatic) ---- +CALL bin\msbuild.bat BeefRT\BeefDbg\BeefDbg.vcxproj /p:Configuration="Debug Static CStatic" /p:Platform=x64 /p:SolutionDir=%cd%\ /v:m %MSBUILD_FLAGS% IF %ERRORLEVEL% NEQ 0 GOTO FAILED @ECHO ---- Building BeefDbg64 (Release) ---- -CALL bin\msbuild.bat BeefRT\BeefDbg\BeefDbg.vcxproj /p:Configuration=Release /p:Platform=x64 /p:SolutionDir=%cd%\ /v:m +CALL bin\msbuild.bat BeefRT\BeefDbg\BeefDbg.vcxproj /p:Configuration=Release /p:Platform=x64 /p:SolutionDir=%cd%\ /v:m %MSBUILD_FLAGS% +IF %ERRORLEVEL% NEQ 0 GOTO FAILED +@ECHO ---- Building BeefDbg64 (Release Static) ---- +CALL bin\msbuild.bat BeefRT\BeefDbg\BeefDbg.vcxproj /p:Configuration="Release Static" /p:Platform=x64 /p:SolutionDir=%cd%\ /v:m %MSBUILD_FLAGS% +IF %ERRORLEVEL% NEQ 0 GOTO FAILED +@ECHO ---- Building BeefDbg64 (Release Static CStatic) ---- +CALL bin\msbuild.bat BeefRT\BeefDbg\BeefDbg.vcxproj /p:Configuration="Release Static CStatic" /p:Platform=x64 /p:SolutionDir=%cd%\ /v:m %MSBUILD_FLAGS% IF %ERRORLEVEL% NEQ 0 GOTO FAILED @ECHO ---- Building MinRT (Debug) ---- -CALL bin\msbuild.bat BeefRT\MinRT\MinRT.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:SolutionDir=%cd%\ /v:m +CALL bin\msbuild.bat BeefRT\MinRT\MinRT.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:SolutionDir=%cd%\ /v:m %MSBUILD_FLAGS% IF %ERRORLEVEL% NEQ 0 GOTO FAILED @ECHO ---- Building MinRT (Debug GUI) ---- -CALL bin\msbuild.bat BeefRT\MinRT\MinRT.vcxproj /p:Configuration="Debug GUI" /p:Platform=x64 /p:SolutionDir=%cd%\ /v:m +CALL bin\msbuild.bat BeefRT\MinRT\MinRT.vcxproj /p:Configuration="Debug GUI" /p:Platform=x64 /p:SolutionDir=%cd%\ /v:m %MSBUILD_FLAGS% IF %ERRORLEVEL% NEQ 0 GOTO FAILED @ECHO ---- Building MinRT (Release) ---- -CALL bin\msbuild.bat BeefRT\MinRT\MinRT.vcxproj /p:Configuration=Release /p:Platform=x64 /p:SolutionDir=%cd%\ /v:m +CALL bin\msbuild.bat BeefRT\MinRT\MinRT.vcxproj /p:Configuration=Release /p:Platform=x64 /p:SolutionDir=%cd%\ /v:m %MSBUILD_FLAGS% IF %ERRORLEVEL% NEQ 0 GOTO FAILED @ECHO ---- Building MinRT (Release GUI) ---- -CALL bin\msbuild.bat BeefRT\MinRT\MinRT.vcxproj /p:Configuration="Release GUI" /p:Platform=x64 /p:SolutionDir=%cd%\ /v:m +CALL bin\msbuild.bat BeefRT\MinRT\MinRT.vcxproj /p:Configuration="Release GUI" /p:Platform=x64 /p:SolutionDir=%cd%\ /v:m %MSBUILD_FLAGS% IF %ERRORLEVEL% NEQ 0 GOTO FAILED @ECHO @@@@@@@@@@@@@ Win32 @@@@@@@@@@@@@@ @ECHO ---- Building BeefRT32 (Debug) ---- -CALL bin\msbuild.bat BeefRT\BeefRT.vcxproj /p:Configuration=Debug /p:Platform=Win32 /p:SolutionDir=%cd%\ /v:m +CALL bin\msbuild.bat BeefRT\BeefRT.vcxproj /p:Configuration=Debug /p:Platform=Win32 /p:SolutionDir=%cd%\ /v:m %MSBUILD_FLAGS% IF %ERRORLEVEL% NEQ 0 GOTO FAILED @ECHO ---- Building BeefRT32 (Debug Static) ---- -CALL bin\msbuild.bat BeefRT\BeefRT.vcxproj /p:Configuration="Debug Static" /p:Platform=Win32 /p:SolutionDir=%cd%\ /v:m +CALL bin\msbuild.bat BeefRT\BeefRT.vcxproj /p:Configuration="Debug Static" /p:Platform=Win32 /p:SolutionDir=%cd%\ /v:m %MSBUILD_FLAGS% IF %ERRORLEVEL% NEQ 0 GOTO FAILED @ECHO ---- Building BeefRT32 (Debug Static CStatic) ---- -CALL bin\msbuild.bat BeefRT\BeefRT.vcxproj /p:Configuration="Debug Static CStatic" /p:Platform=Win32 /p:SolutionDir=%cd%\ /v:m +CALL bin\msbuild.bat BeefRT\BeefRT.vcxproj /p:Configuration="Debug Static CStatic" /p:Platform=Win32 /p:SolutionDir=%cd%\ /v:m %MSBUILD_FLAGS% IF %ERRORLEVEL% NEQ 0 GOTO FAILED @ECHO ---- Building BeefRT32 (Release) ---- -CALL bin\msbuild.bat BeefRT\BeefRT.vcxproj /p:Configuration=Release /p:Platform=Win32 /p:SolutionDir=%cd%\ /v:m +CALL bin\msbuild.bat BeefRT\BeefRT.vcxproj /p:Configuration=Release /p:Platform=Win32 /p:SolutionDir=%cd%\ /v:m %MSBUILD_FLAGS% IF %ERRORLEVEL% NEQ 0 GOTO FAILED @ECHO ---- Building BeefRT32 (Release Static) ---- -CALL bin\msbuild.bat BeefRT\BeefRT.vcxproj /p:Configuration="Release Static" /p:Platform=Win32 /p:SolutionDir=%cd%\ /v:m +CALL bin\msbuild.bat BeefRT\BeefRT.vcxproj /p:Configuration="Release Static" /p:Platform=Win32 /p:SolutionDir=%cd%\ /v:m %MSBUILD_FLAGS% IF %ERRORLEVEL% NEQ 0 GOTO FAILED @ECHO ---- Building BeefRT32 (Release Static CStatic) ---- -CALL bin\msbuild.bat BeefRT\BeefRT.vcxproj /p:Configuration="Release Static CStatic" /p:Platform=Win32 /p:SolutionDir=%cd%\ /v:m +CALL bin\msbuild.bat BeefRT\BeefRT.vcxproj /p:Configuration="Release Static CStatic" /p:Platform=Win32 /p:SolutionDir=%cd%\ /v:m %MSBUILD_FLAGS% IF %ERRORLEVEL% NEQ 0 GOTO FAILED @ECHO ---- Building BeefDbg32 (Debug) ---- -CALL bin\msbuild.bat BeefRT\BeefDbg\BeefDbg.vcxproj /p:Configuration=Debug /p:Platform=Win32 /p:SolutionDir=%cd%\ /v:m +CALL bin\msbuild.bat BeefRT\BeefDbg\BeefDbg.vcxproj /p:Configuration=Debug /p:Platform=Win32 /p:SolutionDir=%cd%\ /v:m %MSBUILD_FLAGS% +IF %ERRORLEVEL% NEQ 0 GOTO FAILED +@ECHO ---- Building BeefDbg32 (Debug Static) ---- +CALL bin\msbuild.bat BeefRT\BeefDbg\BeefDbg.vcxproj /p:Configuration="Debug Static" /p:Platform=Win32 /p:SolutionDir=%cd%\ /v:m %MSBUILD_FLAGS% +IF %ERRORLEVEL% NEQ 0 GOTO FAILED +@ECHO ---- Building BeefDbg32 (Debug Static CStatic) ---- +CALL bin\msbuild.bat BeefRT\BeefDbg\BeefDbg.vcxproj /p:Configuration="Debug Static CStatic" /p:Platform=Win32 /p:SolutionDir=%cd%\ /v:m %MSBUILD_FLAGS% IF %ERRORLEVEL% NEQ 0 GOTO FAILED @ECHO ---- Building BeefDbg32 (Release) ---- -CALL bin\msbuild.bat BeefRT\BeefDbg\BeefDbg.vcxproj /p:Configuration=Release /p:Platform=Win32 /p:SolutionDir=%cd%\ /v:m +CALL bin\msbuild.bat BeefRT\BeefDbg\BeefDbg.vcxproj /p:Configuration=Release /p:Platform=Win32 /p:SolutionDir=%cd%\ /v:m %MSBUILD_FLAGS% +IF %ERRORLEVEL% NEQ 0 GOTO FAILED +@ECHO ---- Building BeefDbg32 (Release Static) ---- +CALL bin\msbuild.bat BeefRT\BeefDbg\BeefDbg.vcxproj /p:Configuration="Release Static" /p:Platform=Win32 /p:SolutionDir=%cd%\ /v:m %MSBUILD_FLAGS% +IF %ERRORLEVEL% NEQ 0 GOTO FAILED +@ECHO ---- Building BeefDbg32 (Release Static CStatic) ---- +CALL bin\msbuild.bat BeefRT\BeefDbg\BeefDbg.vcxproj /p:Configuration="Release Static CStatic" /p:Platform=Win32 /p:SolutionDir=%cd%\ /v:m %MSBUILD_FLAGS% IF %ERRORLEVEL% NEQ 0 GOTO FAILED @ECHO ---- Building MinRT (Debug) ---- -CALL bin\msbuild.bat BeefRT\MinRT\MinRT.vcxproj /p:Configuration=Debug /p:Platform=Win32 /p:SolutionDir=%cd%\ /v:m +CALL bin\msbuild.bat BeefRT\MinRT\MinRT.vcxproj /p:Configuration=Debug /p:Platform=Win32 /p:SolutionDir=%cd%\ /v:m %MSBUILD_FLAGS% IF %ERRORLEVEL% NEQ 0 GOTO FAILED @ECHO ---- Building MinRT (Debug GUI) ---- -CALL bin\msbuild.bat BeefRT\MinRT\MinRT.vcxproj /p:Configuration="Debug GUI" /p:Platform=Win32 /p:SolutionDir=%cd%\ /v:m +CALL bin\msbuild.bat BeefRT\MinRT\MinRT.vcxproj /p:Configuration="Debug GUI" /p:Platform=Win32 /p:SolutionDir=%cd%\ /v:m %MSBUILD_FLAGS% IF %ERRORLEVEL% NEQ 0 GOTO FAILED @ECHO ---- Building MinRT (Release) ---- -CALL bin\msbuild.bat BeefRT\MinRT\MinRT.vcxproj /p:Configuration=Release /p:Platform=Win32 /p:SolutionDir=%cd%\ /v:m +CALL bin\msbuild.bat BeefRT\MinRT\MinRT.vcxproj /p:Configuration=Release /p:Platform=Win32 /p:SolutionDir=%cd%\ /v:m %MSBUILD_FLAGS% IF %ERRORLEVEL% NEQ 0 GOTO FAILED @ECHO ---- Building MinRT (Release GUI) ---- -CALL bin\msbuild.bat BeefRT\MinRT\MinRT.vcxproj /p:Configuration="Release GUI" /p:Platform=Win32 /p:SolutionDir=%cd%\ /v:m +CALL bin\msbuild.bat BeefRT\MinRT\MinRT.vcxproj /p:Configuration="Release GUI" /p:Platform=Win32 /p:SolutionDir=%cd%\ /v:m %MSBUILD_FLAGS% IF %ERRORLEVEL% NEQ 0 GOTO FAILED GOTO DONE diff --git a/bin/test_ide.bat b/bin/test_ide.bat index e77d81f8..c7a46ec8 100644 --- a/bin/test_ide.bat +++ b/bin/test_ide.bat @@ -8,21 +8,31 @@ PUSHD %~dp0..\ @SET TESTPATH=IDE\Tests\CompileFail001 @CALL :TEST @IF !ERRORLEVEL! NEQ 0 GOTO HADERROR + @SET TESTPATH=IDE\Tests\Test1 @CALL :TEST @IF !ERRORLEVEL! NEQ 0 GOTO HADERROR + @SET TESTPATH=IDE\Tests\SlotTest @CALL :TEST @IF !ERRORLEVEL! NEQ 0 GOTO HADERROR +@SET TESTPATH=IDE\Tests\BugW001 +@CALL :TEST +@IF !ERRORLEVEL! NEQ 0 GOTO HADERROR + @GOTO :EMPTYTEST :TEST @FOR %%i IN (%TESTPATH%\scripts\*.txt) DO ( - @ECHO Testing %%i - Win64 + @ECHO Testing %%i in BeefIDE_d - Win64 %~dp0\RunAndWait %~dp0..\IDE\dist\BeefIDE_d.exe -proddir=%~dp0..\%TESTPATH% -test=%cd%\%%i @IF !ERRORLEVEL! NEQ 0 GOTO:EOF + @ECHO Testing %%i in BeefIDE - Win64 + %~dp0\RunAndWait %~dp0..\IDE\dist\BeefIDE.exe -proddir=%~dp0..\%TESTPATH% -test=%cd%\%%i + @IF !ERRORLEVEL! NEQ 0 GOTO:EOF + @REM @ECHO Testing %%i - Win32 @REM %~dp0\RunAndWait %~dp0..\IDE\dist\BeefIDE_d.exe -proddir=%~dp0..\%TESTPATH% -test=%cd%\%%i -platform=Win32 @REM @IF !ERRORLEVEL! NEQ 0 GOTO:EOF @@ -32,7 +42,7 @@ GOTO:EOF :EMPTYTEST @PUSHD %cd%\IDE\Tests\EmptyTest @FOR %%i IN (scripts\*.txt) DO ( - @ECHO Testing IDE\Tests\EmptyTest\%%i + @ECHO Testing IDE\Tests\EmptyTest\%%i in BeefIDE_d - Win64 %~dp0\RunAndWait %~dp0\..\IDE\dist\BeefIDE_d.exe -test=%cd%\%%i @IF !ERRORLEVEL! NEQ 0 GOTO HADERROR_EMPTY )