2019-08-23 11:56:54 -07:00
|
|
|
using System;
|
2020-04-29 06:40:03 -07:00
|
|
|
using System.Collections;
|
2019-08-23 11:56:54 -07:00
|
|
|
using System.Text;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using System.Threading;
|
|
|
|
using System.Diagnostics;
|
|
|
|
using Beefy.widgets;
|
|
|
|
using Beefy;
|
|
|
|
using Beefy.utils;
|
2019-10-23 07:12:36 -07:00
|
|
|
using IDE.Util;
|
2020-01-06 13:49:35 -08:00
|
|
|
using IDE.ui;
|
2020-03-23 12:07:05 -07:00
|
|
|
using IDE.util;
|
2020-11-04 06:51:30 -08:00
|
|
|
using System.IO;
|
2019-08-23 11:56:54 -07:00
|
|
|
|
|
|
|
namespace IDE.Compiler
|
|
|
|
{
|
|
|
|
//public class Bf
|
|
|
|
|
|
|
|
public class BfCompiler : CompilerBase
|
|
|
|
{
|
|
|
|
enum OptionFlags : int32
|
|
|
|
{
|
|
|
|
EmitDebugInfo = 1,
|
|
|
|
EmitLineInfo = 2,
|
|
|
|
WriteIR = 4,
|
|
|
|
GenerateOBJ = 8,
|
2019-10-29 04:56:42 -07:00
|
|
|
GenerateBitcode = 0x10,
|
2019-08-23 11:56:54 -07:00
|
|
|
ClearLocalVars = 0x20,
|
|
|
|
RuntimeChecks = 0x40,
|
|
|
|
EmitDynamicCastCheck = 0x80,
|
|
|
|
EnableObjectDebugFlags = 0x100,
|
|
|
|
EmitObjectAccessCheck = 0x200,
|
|
|
|
EnableCustodian = 0x400,
|
|
|
|
EnableRealtimeLeakCheck = 0x800,
|
|
|
|
EnableSideStack = 0x1000,
|
|
|
|
EnableHotSwapping = 0x2000,
|
|
|
|
IncrementalBuild = 0x4000,
|
2019-10-29 04:56:42 -07:00
|
|
|
DebugAlloc = 0x8000,
|
|
|
|
OmitDebugHelpers = 0x10000,
|
|
|
|
NoFramePointerElim = 0x20000,
|
2022-01-11 08:17:09 -05:00
|
|
|
ArithmeticChecks = 0x40000
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
|
2022-01-28 08:19:11 -05:00
|
|
|
public enum UsedOutputFlags : int32
|
|
|
|
{
|
|
|
|
None = 0,
|
|
|
|
FlushQueuedHotFiles = 1,
|
|
|
|
SkipImports = 2,
|
|
|
|
}
|
|
|
|
|
2020-05-25 20:46:28 +08:00
|
|
|
[CallingConvention(.Stdcall), CLink]
|
2019-08-23 11:56:54 -07:00
|
|
|
static extern bool BfCompiler_Compile(void* bfCompiler, void* bfPassInstance, char8* outputDirectory);
|
|
|
|
|
2020-05-25 20:46:28 +08:00
|
|
|
[CallingConvention(.Stdcall), CLink]
|
2019-08-23 11:56:54 -07:00
|
|
|
static extern bool BfCompiler_ClearResults(void* bfCompiler);
|
|
|
|
|
2020-05-25 20:46:28 +08:00
|
|
|
[CallingConvention(.Stdcall), CLink]
|
2019-08-23 11:56:54 -07:00
|
|
|
static extern bool BfCompiler_VerifyTypeName(void* bfCompiler, char8* typeName, int32 cursorPos);
|
|
|
|
|
2020-05-25 20:46:28 +08:00
|
|
|
[CallingConvention(.Stdcall), CLink]
|
2022-04-16 06:27:54 -07:00
|
|
|
static extern bool BfCompiler_ClassifySource(void* bfCompiler, void* bfPassInstance, void* bfResolvePassData);
|
2019-08-23 11:56:54 -07:00
|
|
|
|
2022-02-28 11:27:12 -08:00
|
|
|
[CallingConvention(.Stdcall), CLink]
|
2022-04-16 06:27:54 -07:00
|
|
|
static extern char8* BfCompiler_GetCollapseRegions(void* bfCompiler, void* bfParser, void* bfResolvePassData, char8* explicitEmitTypeNames);
|
2022-02-28 11:27:12 -08:00
|
|
|
|
2020-05-25 20:46:28 +08:00
|
|
|
[CallingConvention(.Stdcall), CLink]
|
2019-08-23 11:56:54 -07:00
|
|
|
static extern char8* BfCompiler_GetAutocompleteInfo(void* bfCompiler);
|
|
|
|
|
2021-12-29 10:07:36 -05:00
|
|
|
[CallingConvention(.Stdcall), CLink]
|
|
|
|
static extern char8* BfCompiler_GetRebuildFileSet(void* bfCompiler);
|
|
|
|
|
|
|
|
[CallingConvention(.Stdcall), CLink]
|
|
|
|
static extern void BfCompiler_FileChanged(void* bfCompiler, char8* str);
|
|
|
|
|
2020-05-25 20:46:28 +08:00
|
|
|
[CallingConvention(.Stdcall), CLink]
|
2019-08-23 11:56:54 -07:00
|
|
|
static extern char8* BfCompiler_GetSymbolReferences(void* bfCompiler, void* bfPassInstance, void* bfResolvePassData);
|
|
|
|
|
2020-05-25 20:46:28 +08:00
|
|
|
[CallingConvention(.Stdcall), CLink]
|
2019-08-23 11:56:54 -07:00
|
|
|
static extern void BfCompiler_Cancel(void* bfCompiler);
|
|
|
|
|
2021-01-08 16:21:03 -08:00
|
|
|
[CallingConvention(.Stdcall), CLink]
|
|
|
|
static extern void BfCompiler_RequestFastFinish(void* bfCompiler);
|
|
|
|
|
2020-05-25 20:46:28 +08:00
|
|
|
[CallingConvention(.Stdcall), CLink]
|
2019-08-23 11:56:54 -07:00
|
|
|
static extern void BfCompiler_ClearCompletionPercentage(void* bfCompiler);
|
|
|
|
|
2020-05-25 20:46:28 +08:00
|
|
|
[CallingConvention(.Stdcall), CLink]
|
2019-08-23 11:56:54 -07:00
|
|
|
static extern float BfCompiler_GetCompletionPercentage(void* bfCompiler);
|
|
|
|
|
2020-05-25 20:46:28 +08:00
|
|
|
[CallingConvention(.Stdcall), CLink]
|
2019-08-23 11:56:54 -07:00
|
|
|
static extern int32 BfCompiler_GetCompileRevision(void* bfCompiler);
|
|
|
|
|
2020-12-24 07:45:58 -08:00
|
|
|
[CallingConvention(.Stdcall), CLink]
|
|
|
|
static extern int32 BfCompiler_GetCurConstEvalExecuteId(void* bfCompiler);
|
|
|
|
|
2021-12-20 09:52:29 -05:00
|
|
|
[CallingConvention(.Stdcall), CLink]
|
|
|
|
static extern bool BfCompiler_GetLastHadComptimeRebuilds(void* bfCompiler);
|
|
|
|
|
2020-05-25 20:46:28 +08:00
|
|
|
[CallingConvention(.Stdcall), CLink]
|
2019-08-23 11:56:54 -07:00
|
|
|
static extern void BfCompiler_Delete(void* bfCompiler);
|
|
|
|
|
2020-05-25 20:46:28 +08:00
|
|
|
[CallingConvention(.Stdcall), CLink]
|
2019-08-23 11:56:54 -07:00
|
|
|
static extern void BfCompiler_ClearBuildCache(void* bfCompiler);
|
|
|
|
|
2020-05-25 20:46:28 +08:00
|
|
|
[CallingConvention(.Stdcall), CLink]
|
2019-09-28 09:48:37 -07:00
|
|
|
static extern void BfCompiler_SetBuildValue(void* bfCompiler, char8* cacheDir, char8* key, char8* value);
|
|
|
|
|
2020-05-25 20:46:28 +08:00
|
|
|
[CallingConvention(.Stdcall), CLink]
|
2019-09-28 09:48:37 -07:00
|
|
|
static extern char8* BfCompiler_GetBuildValue(void* bfCompiler, char8* cacheDir, char8* key);
|
|
|
|
|
2020-05-25 20:46:28 +08:00
|
|
|
[CallingConvention(.Stdcall), CLink]
|
2019-09-28 09:48:37 -07:00
|
|
|
static extern void BfCompiler_WriteBuildCache(void* bfCompiler, char8* cacheDir);
|
|
|
|
|
2020-05-25 20:46:28 +08:00
|
|
|
[CallingConvention(.Stdcall), CLink]
|
2022-01-28 08:19:11 -05:00
|
|
|
static extern char8* BfCompiler_GetUsedOutputFileNames(void* bfCompiler, void* bfProject, UsedOutputFlags flags, out bool hadOutputChanges);
|
2019-08-23 11:56:54 -07:00
|
|
|
|
2021-12-11 09:08:42 -08:00
|
|
|
[CallingConvention(.Stdcall), CLink]
|
|
|
|
static extern char8* BfCompiler_GetGeneratorTypeDefList(void* bfCompiler);
|
|
|
|
|
|
|
|
[CallingConvention(.Stdcall), CLink]
|
|
|
|
static extern char8* BfCompiler_GetGeneratorInitData(void* bfCompiler, char8* typeDefName, char8* args);
|
|
|
|
|
|
|
|
[CallingConvention(.Stdcall), CLink]
|
|
|
|
static extern char8* BfCompiler_GetGeneratorGenData(void* bfCompiler, char8* typeDefName, char8* args);
|
|
|
|
|
2020-05-25 20:46:28 +08:00
|
|
|
[CallingConvention(.Stdcall), CLink]
|
2022-08-23 19:13:15 +02:00
|
|
|
static extern char8* BfCompiler_GetTypeDefList(void* bfCompiler, bool includeLocation);
|
2019-08-23 11:56:54 -07:00
|
|
|
|
2020-05-25 20:46:28 +08:00
|
|
|
[CallingConvention(.Stdcall), CLink]
|
2022-08-23 19:13:15 +02:00
|
|
|
static extern char8* BfCompiler_GetTypeDefMatches(void* bfCompiler, char8* searchStr, bool includeLocation);
|
2019-08-23 11:56:54 -07:00
|
|
|
|
2020-05-25 20:46:28 +08:00
|
|
|
[CallingConvention(.Stdcall), CLink]
|
2019-08-23 11:56:54 -07:00
|
|
|
static extern char8* BfCompiler_GetTypeDefInfo(void* bfCompiler, char8* typeDefName);
|
|
|
|
|
2020-06-04 11:47:55 -07:00
|
|
|
[CallingConvention(.Stdcall), CLink]
|
|
|
|
static extern char8* BfCompiler_GetTypeInfo(void* bfCompiler, char8* typeName);
|
|
|
|
|
2022-04-16 06:27:54 -07:00
|
|
|
[CallingConvention(.Stdcall), CLink]
|
|
|
|
static extern char8* BfCompiler_GetGenericTypeInstances(void* bfCompiler, char8* typeName);
|
|
|
|
|
|
|
|
[CallingConvention(.Stdcall), CLink]
|
|
|
|
static extern int32 BfCompiler_GetTypeId(void* bfCompiler, char8* typeName);
|
|
|
|
|
2020-05-25 20:46:28 +08:00
|
|
|
[CallingConvention(.Stdcall), CLink]
|
2019-08-23 11:56:54 -07:00
|
|
|
static extern void BfCompiler_SetOptions(void* bfCompiler,
|
2022-01-25 07:04:54 -05:00
|
|
|
void* hotProject, int32 hotIdx, char8* targetTriple, char8* targetCPU, int32 toolsetType, int32 simdSetting, int32 allocStackCount, int32 maxWorkerThreads,
|
2019-08-23 11:56:54 -07:00
|
|
|
OptionFlags optionsFlags, char8* mallocName, char8* freeName);
|
|
|
|
|
2020-05-25 20:46:28 +08:00
|
|
|
[CallingConvention(.Stdcall), CLink]
|
2019-08-23 11:56:54 -07:00
|
|
|
static extern void BfCompiler_ForceRebuild(void* bfCompiler);
|
|
|
|
|
2021-01-08 16:21:03 -08:00
|
|
|
[CallingConvention(.Stdcall), CLink]
|
|
|
|
static extern char8* BfCompiler_GetEmitSource(void* bfCompiler, char8* fileName);
|
|
|
|
|
|
|
|
[CallingConvention(.Stdcall), CLink]
|
|
|
|
static extern int32 BfCompiler_GetEmitSourceVersion(void* bfCompiler, char8* fileName);
|
|
|
|
|
2022-04-16 06:27:54 -07:00
|
|
|
[CallingConvention(.Stdcall), CLink]
|
2022-06-13 08:52:17 -07:00
|
|
|
static extern char8* BfCompiler_GetEmitLocation(void* bfCompiler, char8* typeName, int32 line, out int32 embedLine, out int32 embedLineChar, out uint64 hash);
|
2022-04-16 06:27:54 -07:00
|
|
|
|
|
|
|
[CallingConvention(.Stdcall), CLink]
|
|
|
|
static extern void BfCompiler_WriteEmitData(void* bfCompiler, char8* filePath, void* bfProject);
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
public enum HotTypeFlags
|
|
|
|
{
|
|
|
|
None = 0,
|
|
|
|
UserNotUsed = 1,
|
|
|
|
UserUsed = 2,
|
|
|
|
Heap = 4,
|
|
|
|
};
|
|
|
|
|
2020-05-25 20:46:28 +08:00
|
|
|
[CallingConvention(.Stdcall), CLink]
|
2019-08-23 11:56:54 -07:00
|
|
|
static extern bool BfCompiler_GetHasHotPendingDataChanges(void* bfCompiler);
|
|
|
|
|
2020-05-25 20:46:28 +08:00
|
|
|
[CallingConvention(.Stdcall), CLink]
|
2019-08-23 11:56:54 -07:00
|
|
|
static extern void BfCompiler_HotCommit(void* bfCompiler);
|
|
|
|
|
|
|
|
public enum HotResolveFlags
|
|
|
|
{
|
|
|
|
None = 0,
|
|
|
|
HadDataChanges = 1
|
|
|
|
}
|
|
|
|
|
2020-05-25 20:46:28 +08:00
|
|
|
[CallingConvention(.Stdcall), CLink]
|
2019-08-23 11:56:54 -07:00
|
|
|
static extern void BfCompiler_HotResolve_Start(void* bfCompiler, int32 flags);
|
|
|
|
|
2020-05-25 20:46:28 +08:00
|
|
|
[CallingConvention(.Stdcall), CLink]
|
2019-08-23 11:56:54 -07:00
|
|
|
static extern void BfCompiler_HotResolve_AddActiveMethod(void* bfCompiler, char8* methodName);
|
|
|
|
|
2020-05-25 20:46:28 +08:00
|
|
|
[CallingConvention(.Stdcall), CLink]
|
2019-08-23 11:56:54 -07:00
|
|
|
static extern void BfCompiler_HotResolve_AddDelegateMethod(void* bfCompiler, char8* methodName);
|
|
|
|
|
2020-05-25 20:46:28 +08:00
|
|
|
[CallingConvention(.Stdcall), CLink]
|
2019-08-23 11:56:54 -07:00
|
|
|
static extern void BfCompiler_HotResolve_ReportType(void* bfCompiler, int typeId, int usageKind);
|
|
|
|
|
2020-05-25 20:46:28 +08:00
|
|
|
[CallingConvention(.Stdcall), CLink]
|
2019-08-23 11:56:54 -07:00
|
|
|
static extern void BfCompiler_HotResolve_ReportTypeRange(void* bfCompiler, char8* typeName, int usageKind);
|
|
|
|
|
2020-05-25 20:46:28 +08:00
|
|
|
[CallingConvention(.Stdcall), CLink]
|
2019-08-23 11:56:54 -07:00
|
|
|
static extern char8* BfCompiler_HotResolve_Finish(void* bfCompiler);
|
|
|
|
|
|
|
|
class SetPassInstanceCommand : Command
|
|
|
|
{
|
|
|
|
public BfPassInstance mPassInstance;
|
|
|
|
}
|
|
|
|
|
2020-05-15 06:28:01 -07:00
|
|
|
class DeletePassInstanceCommand : Command
|
|
|
|
{
|
|
|
|
public BfPassInstance mPassInstance;
|
|
|
|
}
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
class SetupProjectSettingsCommand : Command
|
|
|
|
{
|
|
|
|
public Project mProject;
|
|
|
|
}
|
|
|
|
|
|
|
|
class DeleteBfProjectCommand : Command
|
|
|
|
{
|
|
|
|
public BfProject mBfProject;
|
|
|
|
}
|
|
|
|
|
|
|
|
class RefreshViewCommand : Command
|
|
|
|
{
|
2022-05-02 07:48:29 -07:00
|
|
|
public ViewRefreshKind mRefreshKind;
|
|
|
|
|
|
|
|
public this(ViewRefreshKind refreshKind)
|
|
|
|
{
|
|
|
|
mRefreshKind = refreshKind;
|
|
|
|
}
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
class SetWorkspaceOptionsCommand : Command
|
|
|
|
{
|
|
|
|
public BfProject mHotBfProject;
|
|
|
|
public int32 mHotIdx;
|
|
|
|
}
|
|
|
|
|
2021-12-29 10:07:36 -05:00
|
|
|
class RebuildFileChangedCommand : Command
|
|
|
|
{
|
|
|
|
public String mDir = new .() ~ delete _;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
public void* mNativeBfCompiler;
|
|
|
|
public bool mIsResolveOnly;
|
2022-05-02 07:48:29 -07:00
|
|
|
public bool mWantsResolveAllCollapseRefresh;
|
2019-08-23 11:56:54 -07:00
|
|
|
public BfSystem mBfSystem;
|
|
|
|
bool mWantsRemoveOldData;
|
2021-12-29 10:07:36 -05:00
|
|
|
public Dictionary<String, String> mRebuildWatchingFiles = new .() ~ delete _;
|
2019-08-23 11:56:54 -07:00
|
|
|
|
|
|
|
public this(void* nativeBfCompiler)
|
|
|
|
{
|
|
|
|
mNativeBfCompiler = nativeBfCompiler;
|
|
|
|
}
|
|
|
|
|
|
|
|
public ~this()
|
|
|
|
{
|
|
|
|
BfCompiler_Delete(mNativeBfCompiler);
|
|
|
|
mNativeBfCompiler = null;
|
2021-12-29 10:07:36 -05:00
|
|
|
|
|
|
|
for (var kv in mRebuildWatchingFiles)
|
|
|
|
{
|
|
|
|
gApp.mFileWatcher.RemoveWatch(kv.key, kv.value);
|
|
|
|
delete kv.key;
|
|
|
|
delete kv.value;
|
|
|
|
}
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
public bool Compile(BfPassInstance passInstance, String outputDirectory)
|
|
|
|
{
|
|
|
|
bool success = BfCompiler_Compile(mNativeBfCompiler, passInstance.mNativeBfPassInstance, outputDirectory);
|
|
|
|
passInstance.mCompileSucceeded = success;
|
|
|
|
passInstance.mDidCompile = true;
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void ClearResults()
|
|
|
|
{
|
|
|
|
BfCompiler_ClearResults(mNativeBfCompiler);
|
|
|
|
}
|
|
|
|
|
2022-04-16 06:27:54 -07:00
|
|
|
public bool ClassifySource(BfPassInstance bfPassInstance, BfResolvePassData resolvePassData)
|
2019-08-23 11:56:54 -07:00
|
|
|
{
|
|
|
|
void* nativeResolvePassData = null;
|
|
|
|
if (resolvePassData != null)
|
|
|
|
nativeResolvePassData = resolvePassData.mNativeResolvePassData;
|
2022-04-16 06:27:54 -07:00
|
|
|
return BfCompiler_ClassifySource(mNativeBfCompiler, bfPassInstance.mNativeBfPassInstance, nativeResolvePassData);
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
|
2022-04-16 06:27:54 -07:00
|
|
|
public void GetCollapseRegions(BfParser parser, BfResolvePassData resolvePassData, String explicitEmitTypeNames, String outData)
|
2022-02-28 11:27:12 -08:00
|
|
|
{
|
2022-04-16 06:27:54 -07:00
|
|
|
outData.Append(BfCompiler_GetCollapseRegions(mNativeBfCompiler, (parser != null) ? parser.mNativeBfParser : null, resolvePassData.mNativeResolvePassData, explicitEmitTypeNames));
|
2022-02-28 11:27:12 -08:00
|
|
|
}
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
public bool VerifyTypeName(String typeName, int cursorPos)
|
|
|
|
{
|
|
|
|
return BfCompiler_VerifyTypeName(mNativeBfCompiler, typeName, (.)cursorPos);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void GetAutocompleteInfo(String outAutocompleteInfo)
|
|
|
|
{
|
|
|
|
char8* result = BfCompiler_GetAutocompleteInfo(mNativeBfCompiler);
|
2021-12-16 08:00:20 -05:00
|
|
|
outAutocompleteInfo.Append(StringView(result));
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
|
2021-12-29 10:07:36 -05:00
|
|
|
public void GetRebuildFileSet(String outDirInfo)
|
|
|
|
{
|
|
|
|
char8* result = BfCompiler_GetRebuildFileSet(mNativeBfCompiler);
|
|
|
|
outDirInfo.Append(StringView(result));
|
|
|
|
}
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
public void GetSymbolReferences(BfPassInstance passInstance, BfResolvePassData resolvePassData, String outSymbolReferences)
|
|
|
|
{
|
|
|
|
char8* result = BfCompiler_GetSymbolReferences(mNativeBfCompiler, passInstance.mNativeBfPassInstance, resolvePassData.mNativeResolvePassData);
|
2021-12-16 08:00:20 -05:00
|
|
|
outSymbolReferences.Append(StringView(result));
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*public void UpdateRenameSymbols(BfPassInstance passInstance, BfResolvePassData resolvePassData)
|
|
|
|
{
|
|
|
|
BfCompiler_UpdateRenameSymbols(mNativeBfCompiler, passInstance.mNativeBfPassInstance, resolvePassData.mNativeResolvePassData);
|
|
|
|
}*/
|
|
|
|
|
2022-01-28 08:19:11 -05:00
|
|
|
public void GetOutputFileNames(BfProject project, UsedOutputFlags flags, out bool hadOutputChanges, List<String> outFileNames)
|
2019-08-23 11:56:54 -07:00
|
|
|
{
|
2022-01-28 08:19:11 -05:00
|
|
|
char8* result = BfCompiler_GetUsedOutputFileNames(mNativeBfCompiler, project.mNativeBfProject, flags, out hadOutputChanges);
|
2019-08-23 11:56:54 -07:00
|
|
|
if (result == null)
|
|
|
|
return;
|
|
|
|
String fileNamesStr = scope String();
|
|
|
|
fileNamesStr.Append(result);
|
|
|
|
if (fileNamesStr.Length == 0)
|
|
|
|
return;
|
|
|
|
List<StringView> stringViews = scope List<StringView>(fileNamesStr.Split('\n'));
|
|
|
|
for (var strView in stringViews)
|
|
|
|
outFileNames.Add(new String(strView));
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SetOptions(BfProject hotProject, int32 hotIdx,
|
2022-01-25 07:04:54 -05:00
|
|
|
String targetTriple, String targetCPU, int32 toolsetType, int32 simdSetting, int32 allocStackCount, int32 maxWorkerThreads,
|
2019-08-23 11:56:54 -07:00
|
|
|
OptionFlags optionFlags, String mallocFuncName, String freeFuncName)
|
|
|
|
{
|
|
|
|
BfCompiler_SetOptions(mNativeBfCompiler,
|
|
|
|
(hotProject != null) ? hotProject.mNativeBfProject : null, hotIdx,
|
2022-01-25 07:04:54 -05:00
|
|
|
targetTriple, targetCPU, toolsetType, simdSetting, allocStackCount, maxWorkerThreads, optionFlags, mallocFuncName, freeFuncName);
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
public void ForceRebuild()
|
|
|
|
{
|
|
|
|
BfCompiler_ForceRebuild(mNativeBfCompiler);
|
|
|
|
}
|
|
|
|
|
2021-01-08 16:21:03 -08:00
|
|
|
public bool GetEmitSource(StringView fileName, String outText)
|
|
|
|
{
|
|
|
|
char8* str = BfCompiler_GetEmitSource(mNativeBfCompiler, fileName.ToScopeCStr!());
|
|
|
|
if (str == null)
|
|
|
|
return false;
|
|
|
|
outText.Append(str);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int32 GetEmitVersion(StringView fileName)
|
|
|
|
{
|
|
|
|
return BfCompiler_GetEmitSourceVersion(mNativeBfCompiler, fileName.ToScopeCStr!());
|
|
|
|
}
|
|
|
|
|
2022-06-13 08:52:17 -07:00
|
|
|
public void GetEmitLocation(StringView typeName, int line, String outFilePath, out int embedLine, out int embedLineChar, out uint64 hash)
|
2022-04-16 06:27:54 -07:00
|
|
|
{
|
|
|
|
int32 embedLine32;
|
|
|
|
int32 embedLineChar32;
|
2022-06-13 08:52:17 -07:00
|
|
|
outFilePath.Append(BfCompiler_GetEmitLocation(mNativeBfCompiler, typeName.ToScopeCStr!(), (.)line, out embedLine32, out embedLineChar32, out hash));
|
2022-04-16 06:27:54 -07:00
|
|
|
embedLine = embedLine32;
|
|
|
|
embedLineChar = embedLineChar32;
|
|
|
|
}
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
public void QueueSetPassInstance(BfPassInstance passInstance)
|
|
|
|
{
|
|
|
|
SetPassInstanceCommand command = new SetPassInstanceCommand();
|
|
|
|
command.mPassInstance = passInstance;
|
|
|
|
QueueCommand(command);
|
|
|
|
}
|
|
|
|
|
2020-05-15 06:28:01 -07:00
|
|
|
public void QueueDeletePassInstance(BfPassInstance passInstance)
|
|
|
|
{
|
|
|
|
DeletePassInstanceCommand command = new DeletePassInstanceCommand();
|
|
|
|
command.mPassInstance = passInstance;
|
|
|
|
QueueCommand(command);
|
|
|
|
}
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
public void QueueSetupProjectSettings(Project project)
|
|
|
|
{
|
|
|
|
SetupProjectSettingsCommand command = new SetupProjectSettingsCommand();
|
|
|
|
command.mProject = project;
|
|
|
|
QueueCommand(command);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void QueueDeleteBfProject(BfProject bfProject)
|
|
|
|
{
|
|
|
|
DeleteBfProjectCommand command = new DeleteBfProjectCommand();
|
|
|
|
command.mBfProject = bfProject;
|
|
|
|
QueueCommand(command);
|
|
|
|
}
|
|
|
|
|
2022-05-02 07:48:29 -07:00
|
|
|
public void QueueRefreshViewCommand(ViewRefreshKind viewRefreshKind = .FullRefresh)
|
2019-08-23 11:56:54 -07:00
|
|
|
{
|
2022-05-02 07:48:29 -07:00
|
|
|
QueueCommand(new RefreshViewCommand(viewRefreshKind));
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
public void QueueSetWorkspaceOptions(Project hotProject, int32 hotIdx)
|
|
|
|
{
|
|
|
|
BfProject hotBfProject = null;
|
|
|
|
if (hotProject != null)
|
|
|
|
hotBfProject = mBfSystem.GetBfProject(hotProject);
|
|
|
|
var command = new SetWorkspaceOptionsCommand();
|
|
|
|
command.mHotBfProject = hotBfProject;
|
|
|
|
command.mHotIdx = hotIdx;
|
|
|
|
QueueCommand(command);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void DoProcessQueue()
|
|
|
|
{
|
2020-01-06 13:49:35 -08:00
|
|
|
BfPassInstance.PassKind passKind = .None;
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
BfPassInstance passInstance = null;
|
|
|
|
bool didPassInstanceAlloc = false;
|
2020-05-08 07:10:35 -07:00
|
|
|
bool wantsRemoveOldData = false;
|
2019-08-23 11:56:54 -07:00
|
|
|
|
|
|
|
mBfSystem.Lock(0);
|
|
|
|
|
|
|
|
//Debug.WriteLine("Starting Beef Thread {0}", Thread.CurrentThread.Id);
|
|
|
|
|
|
|
|
while (true)
|
|
|
|
{
|
|
|
|
Command command = null;
|
|
|
|
using (mMonitor.Enter())
|
|
|
|
{
|
|
|
|
if (mCommandQueue.Count == 0)
|
|
|
|
break;
|
|
|
|
command = mCommandQueue[0];
|
|
|
|
}
|
|
|
|
|
2020-01-06 13:49:35 -08:00
|
|
|
bool commandProcessed = true;
|
|
|
|
defer
|
|
|
|
{
|
|
|
|
if (commandProcessed)
|
|
|
|
{
|
|
|
|
using (mMonitor.Enter())
|
|
|
|
{
|
|
|
|
delete command;
|
|
|
|
if (!mShuttingDown)
|
|
|
|
{
|
|
|
|
var poppedCmd = mCommandQueue.PopFront();
|
|
|
|
Debug.Assert(poppedCmd == command);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
if (command is SetPassInstanceCommand)
|
|
|
|
{
|
|
|
|
var setPassInstanceCommand = (SetPassInstanceCommand)command;
|
|
|
|
passInstance = setPassInstanceCommand.mPassInstance;
|
2020-05-15 06:28:01 -07:00
|
|
|
}
|
|
|
|
else if (command is DeletePassInstanceCommand)
|
|
|
|
{
|
|
|
|
var deletePassInstanceCommand = (DeletePassInstanceCommand)command;
|
|
|
|
if (passInstance == deletePassInstanceCommand.mPassInstance)
|
|
|
|
passInstance = null;
|
|
|
|
delete deletePassInstanceCommand.mPassInstance;
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
else if (passInstance == null)
|
|
|
|
{
|
|
|
|
passInstance = mBfSystem.CreatePassInstance("ProcessQueue");
|
|
|
|
didPassInstanceAlloc = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (command is SetupProjectSettingsCommand)
|
|
|
|
{
|
2020-09-06 06:14:39 -07:00
|
|
|
var setupProjectSettingsCommand = (SetupProjectSettingsCommand)command;
|
|
|
|
if (setupProjectSettingsCommand.mProject.mDeleted)
|
|
|
|
continue;
|
2019-08-23 11:56:54 -07:00
|
|
|
gApp.SetupBeefProjectSettings(mBfSystem, this, setupProjectSettingsCommand.mProject);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (command is DeleteBfProjectCommand)
|
|
|
|
{
|
|
|
|
var deleteBfProjectCommand = (DeleteBfProjectCommand)command;
|
|
|
|
deleteBfProjectCommand.mBfProject.Dispose();
|
|
|
|
delete deleteBfProjectCommand.mBfProject;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (command is ProjectSourceCommand)
|
|
|
|
ProjectSourceCommandBlock:
|
|
|
|
{
|
|
|
|
var projectSourceCommand = (ProjectSourceCommand)command;
|
2020-09-06 06:14:39 -07:00
|
|
|
if (projectSourceCommand.mProjectSource.mProject.mDeleted)
|
|
|
|
continue;
|
2019-08-23 11:56:54 -07:00
|
|
|
bool worked = true;
|
|
|
|
String sourceFilePath = scope String();
|
|
|
|
var projectSource = projectSourceCommand.mProjectSource;
|
|
|
|
if (projectSource.mIncludeKind != .Ignore)
|
|
|
|
{
|
2020-01-06 13:49:35 -08:00
|
|
|
BfProject bfProject = null;
|
2019-08-23 11:56:54 -07:00
|
|
|
using (projectSource.mProject.mMonitor.Enter())
|
|
|
|
{
|
|
|
|
projectSourceCommand.mProjectSource.GetFullImportPath(sourceFilePath);
|
2020-01-06 13:49:35 -08:00
|
|
|
bfProject = mBfSystem.GetBfProject(projectSource.mProject);
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
|
2020-03-23 12:07:05 -07:00
|
|
|
bool wantsHash = !mIsResolveOnly;
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
bool canMoveSourceString = true;
|
|
|
|
IdSpan char8IdData = projectSourceCommand.mSourceCharIdData;
|
|
|
|
String data = projectSourceCommand.mSourceString;
|
2020-03-23 12:07:05 -07:00
|
|
|
SourceHash hash = .None;
|
|
|
|
if (wantsHash)
|
|
|
|
hash = projectSourceCommand.mSourceHash;
|
2019-08-23 11:56:54 -07:00
|
|
|
if (char8IdData.IsEmpty)
|
|
|
|
{
|
|
|
|
data = scope:ProjectSourceCommandBlock String();
|
2020-03-23 12:07:05 -07:00
|
|
|
|
|
|
|
if (gApp.LoadTextFile(sourceFilePath, data, true, scope [&] () => { if (wantsHash) hash = SourceHash.Create(.MD5, data); } ) case .Err)
|
2019-08-23 11:56:54 -07:00
|
|
|
data = null;
|
|
|
|
if (data != null)
|
|
|
|
{
|
|
|
|
data.EnsureNullTerminator();
|
|
|
|
char8IdData = IdSpan.GetDefault((int32)data.Length);
|
|
|
|
defer:ProjectSourceCommandBlock char8IdData.Dispose();
|
|
|
|
var editData = gApp.GetEditData(projectSource, false);
|
|
|
|
using (gApp.mMonitor.Enter())
|
|
|
|
{
|
2020-11-04 09:50:41 -08:00
|
|
|
editData.GetFileTime();
|
2019-08-23 11:56:54 -07:00
|
|
|
editData.SetSavedData(data, char8IdData);
|
2020-03-23 12:07:05 -07:00
|
|
|
if (hash case .MD5(let md5Hash))
|
|
|
|
editData.mMD5Hash = md5Hash;
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
canMoveSourceString = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (data == null)
|
|
|
|
{
|
|
|
|
String msg = new String();
|
2020-01-15 08:33:16 -08:00
|
|
|
msg.AppendF("ERROR: FAILED TO LOAD FILE '{0}' in project '{1}'", sourceFilePath, projectSource.mProject.mProjectName);
|
2019-08-23 11:56:54 -07:00
|
|
|
mQueuedOutput.Add(msg);
|
|
|
|
passInstance.mFailed = true;
|
2020-01-15 08:33:16 -08:00
|
|
|
projectSourceCommand.mProjectSource.mLoadFailed = true;
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
2020-01-15 08:33:16 -08:00
|
|
|
else
|
|
|
|
projectSourceCommand.mProjectSource.mLoadFailed = false;
|
|
|
|
|
|
|
|
if (mIsResolveOnly)
|
|
|
|
projectSourceCommand.mProjectSource.mLoadFailed = data == null;
|
2019-08-23 11:56:54 -07:00
|
|
|
|
|
|
|
if ((!mIsResolveOnly) && (data != null))
|
2020-04-14 11:37:27 -07:00
|
|
|
IDEApp.sApp.mWorkspace.ProjectSourceCompiled(projectSource, data, hash, char8IdData, canMoveSourceString);
|
2019-08-23 11:56:54 -07:00
|
|
|
|
|
|
|
var bfParser = mBfSystem.CreateParser(projectSourceCommand.mProjectSource);
|
|
|
|
if (data != null)
|
2022-05-26 15:39:32 -07:00
|
|
|
bfParser.SetSource(data, sourceFilePath, -1);
|
2019-08-23 11:56:54 -07:00
|
|
|
else
|
2022-05-26 15:39:32 -07:00
|
|
|
bfParser.SetSource("", sourceFilePath, -1);
|
2019-08-23 11:56:54 -07:00
|
|
|
bfParser.SetCharIdData(ref char8IdData);
|
2020-01-06 13:49:35 -08:00
|
|
|
|
2020-03-23 12:07:05 -07:00
|
|
|
if (hash case .MD5(let md5Hash))
|
|
|
|
bfParser.SetHashMD5(md5Hash);
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
worked &= bfParser.Parse(passInstance, false);
|
|
|
|
worked &= bfParser.Reduce(passInstance);
|
|
|
|
worked &= bfParser.BuildDefs(passInstance, null, false);
|
|
|
|
|
2020-01-06 13:49:35 -08:00
|
|
|
passKind = .Parse;
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
// Do this to make sure we re-trigger errors in parse/reduce/builddefs
|
|
|
|
if (!worked)
|
|
|
|
projectSource.HasChangedSinceLastCompile = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (command is ProjectSourceRemovedCommand)
|
|
|
|
{
|
|
|
|
var fileRemovedCommand = (ProjectSourceRemovedCommand)command;
|
2020-01-06 13:49:35 -08:00
|
|
|
let projectSource = fileRemovedCommand.mProjectSource;
|
|
|
|
|
|
|
|
using (projectSource.mProject.mMonitor.Enter())
|
|
|
|
{
|
|
|
|
String sourceFilePath = scope String();
|
|
|
|
projectSource.GetFullImportPath(sourceFilePath);
|
|
|
|
gApp.mErrorsPanel.ClearParserErrors(sourceFilePath);
|
|
|
|
}
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
var bfParser = mBfSystem.FileRemoved(fileRemovedCommand.mProjectSource);
|
|
|
|
if (bfParser != null)
|
|
|
|
{
|
|
|
|
bfParser.RemoveDefs();
|
|
|
|
delete bfParser;
|
|
|
|
mWantsRemoveOldData = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (command is CompileCommand)
|
|
|
|
{
|
|
|
|
var compileCommand = (CompileCommand)command;
|
|
|
|
Compile(passInstance, compileCommand.mOutputDirectory);
|
2021-12-29 10:07:36 -05:00
|
|
|
UpdateRebuildFileWatches();
|
2019-08-23 11:56:54 -07:00
|
|
|
mBfSystem.RemoveOldParsers();
|
|
|
|
mBfSystem.RemoveOldData();
|
2022-06-13 08:52:17 -07:00
|
|
|
if (gApp.mSettings.mEditorSettings.mEmitCompiler == .Build)
|
|
|
|
QueueRefreshViewCommand(.Collapse);
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (command is ResolveAllCommand)
|
|
|
|
{
|
2020-01-06 13:49:35 -08:00
|
|
|
if (passKind != .None)
|
|
|
|
{
|
|
|
|
commandProcessed = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
var resolvePassData = BfResolvePassData.Create(ResolveType.Classify);
|
|
|
|
// If we get canceled then try again after waiting a couple updates
|
2022-05-02 07:48:29 -07:00
|
|
|
|
|
|
|
bool wantsCollapseRefresh = false;
|
|
|
|
|
|
|
|
if (ClassifySource(passInstance, resolvePassData))
|
|
|
|
{
|
|
|
|
if (mWantsResolveAllCollapseRefresh)
|
|
|
|
{
|
|
|
|
mWantsResolveAllCollapseRefresh = false;
|
|
|
|
wantsCollapseRefresh = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-08-23 11:56:54 -07:00
|
|
|
QueueDeferredResolveAll();
|
2022-05-02 07:48:29 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (resolvePassData.HadEmits)
|
|
|
|
wantsCollapseRefresh = true;
|
|
|
|
|
|
|
|
if (wantsCollapseRefresh)
|
|
|
|
QueueRefreshViewCommand(.Collapse);
|
|
|
|
|
2021-12-29 10:07:36 -05:00
|
|
|
UpdateRebuildFileWatches();
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
delete resolvePassData;
|
2020-05-08 07:10:35 -07:00
|
|
|
wantsRemoveOldData = true;
|
2020-01-06 13:49:35 -08:00
|
|
|
passKind = .Classify;
|
|
|
|
|
|
|
|
// End after resolveAll
|
|
|
|
break;
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (command is SetWorkspaceOptionsCommand)
|
|
|
|
{
|
|
|
|
var setWorkspaceOptionsCommand = (SetWorkspaceOptionsCommand)command;
|
|
|
|
var workspace = IDEApp.sApp.mWorkspace;
|
|
|
|
using (workspace.mMonitor.Enter())
|
|
|
|
{
|
|
|
|
HandleOptions(setWorkspaceOptionsCommand.mHotBfProject, setWorkspaceOptionsCommand.mHotIdx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (command is RefreshViewCommand)
|
|
|
|
{
|
2022-05-02 07:48:29 -07:00
|
|
|
var refreshViewCommand = (RefreshViewCommand)command;
|
|
|
|
mWantsActiveViewRefresh = Math.Max(mWantsActiveViewRefresh, refreshViewCommand.mRefreshKind);
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
2021-12-29 10:07:36 -05:00
|
|
|
|
|
|
|
if (var dirChangedCommand = command as RebuildFileChangedCommand)
|
|
|
|
{
|
|
|
|
BfCompiler_FileChanged(mNativeBfCompiler, dirChangedCommand.mDir);
|
|
|
|
}
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
mBfSystem.Unlock();
|
|
|
|
|
|
|
|
if (didPassInstanceAlloc)
|
2020-01-06 13:49:35 -08:00
|
|
|
{
|
|
|
|
if ((passKind != .None) && (mIsResolveOnly))
|
|
|
|
gApp.mErrorsPanel.ProcessPassInstance(passInstance, passKind);
|
|
|
|
delete passInstance;
|
|
|
|
}
|
2020-05-08 07:10:35 -07:00
|
|
|
|
|
|
|
if (wantsRemoveOldData)
|
|
|
|
{
|
|
|
|
mBfSystem.RemoveOldParsers();
|
|
|
|
mBfSystem.RemoveOldData();
|
|
|
|
}
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void HandleOptions(BfProject hotBfProject, int32 hotIdx)
|
|
|
|
{
|
|
|
|
//Debug.WriteLine("HandleOptions");
|
|
|
|
|
|
|
|
var options = IDEApp.sApp.GetCurWorkspaceOptions();
|
2019-10-14 17:49:10 -07:00
|
|
|
String targetTriple = scope .();
|
2019-10-23 07:12:36 -07:00
|
|
|
if (TargetTriple.IsTargetTriple(gApp.mPlatformName))
|
|
|
|
targetTriple.Set(gApp.mPlatformName);
|
|
|
|
else
|
|
|
|
Workspace.PlatformType.GetTargetTripleByName(gApp.mPlatformName, options.mToolsetType, targetTriple);
|
2019-08-23 11:56:54 -07:00
|
|
|
|
|
|
|
bool enableObjectDebugFlags = options.mEnableObjectDebugFlags;
|
|
|
|
bool emitObjectAccessCheck = options.mEmitObjectAccessCheck && enableObjectDebugFlags;
|
|
|
|
|
|
|
|
OptionFlags optionFlags = default;
|
|
|
|
void SetOpt(bool val, OptionFlags optionFlag)
|
|
|
|
{
|
|
|
|
if (val)
|
|
|
|
optionFlags |= optionFlag;
|
|
|
|
//Debug.WriteLine(" SetOpt {0:X} {1:X}", (int)optionFlags, (int)optionFlag);
|
|
|
|
}
|
|
|
|
|
|
|
|
SetOpt(options.mIncrementalBuild, .IncrementalBuild);
|
|
|
|
SetOpt(options.mEmitDebugInfo == .Yes, .EmitDebugInfo);
|
|
|
|
SetOpt((options.mEmitDebugInfo == .Yes) || (options.mEmitDebugInfo == .LinesOnly), .EmitLineInfo);
|
|
|
|
if (gApp.mConfig_NoIR)
|
|
|
|
{
|
|
|
|
SetOpt(true, .GenerateOBJ);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-10-29 04:56:42 -07:00
|
|
|
SetOpt((options.mIntermediateType == .IRCode) || (options.mIntermediateType == .ObjectAndIRCode) || (options.mIntermediateType == .BitcodeAndIRCode), .WriteIR);
|
|
|
|
SetOpt((options.mIntermediateType == .Object) || (options.mIntermediateType == .ObjectAndIRCode) ||
|
|
|
|
(options.mIntermediateType == .Bitcode) || (options.mIntermediateType == .BitcodeAndIRCode), .GenerateOBJ);
|
|
|
|
SetOpt((options.mIntermediateType == .Bitcode) || (options.mIntermediateType == .BitcodeAndIRCode), .GenerateBitcode);
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
SetOpt(options.mNoOmitFramePointers, .NoFramePointerElim);
|
|
|
|
SetOpt(options.mInitLocalVariables, .ClearLocalVars);
|
|
|
|
SetOpt(options.mRuntimeChecks, .RuntimeChecks);
|
|
|
|
SetOpt(options.mEmitDynamicCastCheck, .EmitDynamicCastCheck);
|
|
|
|
SetOpt(enableObjectDebugFlags, .EnableObjectDebugFlags);
|
|
|
|
SetOpt(emitObjectAccessCheck, .EmitObjectAccessCheck);
|
2022-01-11 08:17:09 -05:00
|
|
|
SetOpt(options.mArithmeticCheck, .ArithmeticChecks);
|
2020-05-15 10:33:56 -07:00
|
|
|
|
|
|
|
if (options.LeakCheckingEnabled)
|
|
|
|
SetOpt(options.mEnableRealtimeLeakCheck, .EnableRealtimeLeakCheck);
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
SetOpt(options.mEnableSideStack, .EnableSideStack);
|
|
|
|
#if !CLI
|
|
|
|
SetOpt(options.mAllowHotSwapping, .EnableHotSwapping);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
String mallocLinkName;
|
|
|
|
String freeLinkName;
|
|
|
|
switch (options.mAllocType)
|
|
|
|
{
|
2022-06-03 06:33:12 -07:00
|
|
|
case .CRT:
|
|
|
|
mallocLinkName = "malloc";
|
|
|
|
freeLinkName = "free";
|
2019-08-23 11:56:54 -07:00
|
|
|
case .Debug:
|
|
|
|
optionFlags |= .DebugAlloc;
|
|
|
|
mallocLinkName = "";
|
|
|
|
freeLinkName = "";
|
2022-06-02 07:03:42 -07:00
|
|
|
case .Stomp:
|
|
|
|
mallocLinkName = "StompAlloc";
|
|
|
|
freeLinkName = "StompFree";
|
2022-06-02 17:57:09 -07:00
|
|
|
case .JEMalloc, .JEMalloc_Debug:
|
2019-08-23 11:56:54 -07:00
|
|
|
mallocLinkName = "je_malloc";
|
|
|
|
freeLinkName = "je_free";
|
2022-06-02 17:57:09 -07:00
|
|
|
case .TCMalloc, .TCMalloc_Debug:
|
|
|
|
mallocLinkName = "tc_malloc";
|
|
|
|
freeLinkName = "tc_free";
|
2019-08-23 11:56:54 -07:00
|
|
|
case .Custom:
|
|
|
|
mallocLinkName = options.mAllocMalloc;
|
|
|
|
freeLinkName = options.mAllocFree;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Debug.WriteLine("HandleOptions SetOptions:{0:X}", (int)optionFlags);
|
2022-01-25 14:39:52 -05:00
|
|
|
if (!options.mTargetTriple.IsWhiteSpace)
|
|
|
|
targetTriple.Set(options.mTargetTriple);
|
2019-08-23 11:56:54 -07:00
|
|
|
|
|
|
|
SetOptions(hotBfProject, hotIdx,
|
2022-01-25 07:04:54 -05:00
|
|
|
targetTriple, options.mTargetCPU, (int32)options.mToolsetType, (int32)options.mBfSIMDSetting, (int32)options.mAllocStackTraceDepth,
|
|
|
|
(int32)gApp.mSettings.mCompilerSettings.mWorkerThreads, optionFlags, mallocLinkName, freeLinkName);
|
2019-08-23 11:56:54 -07:00
|
|
|
|
|
|
|
if (!mIsResolveOnly)
|
|
|
|
{
|
|
|
|
for (let typeOption in gApp.mWorkspace.mBeefGlobalOptions.mDistinctBuildOptions)
|
|
|
|
mBfSystem.AddTypeOptions(typeOption);
|
|
|
|
for (let typeOption in options.mDistinctBuildOptions)
|
|
|
|
mBfSystem.AddTypeOptions(typeOption);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void StartQueueProcessThread()
|
|
|
|
{
|
|
|
|
// This causes the current view to do a full refresh every keystroke.
|
|
|
|
// I think it's not needed...
|
|
|
|
//mWantsActiveViewRefresh = true;
|
|
|
|
base.StartQueueProcessThread();
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void RequestCancelBackground()
|
|
|
|
{
|
2021-12-11 09:08:42 -08:00
|
|
|
if (mThreadWorker.mThreadRunning)
|
2019-08-23 11:56:54 -07:00
|
|
|
{
|
2021-01-30 14:43:10 -08:00
|
|
|
if ((mNativeBfCompiler != null) && (!gApp.mDeterministic))
|
2019-08-23 11:56:54 -07:00
|
|
|
BfCompiler_Cancel(mNativeBfCompiler);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-11 09:08:42 -08:00
|
|
|
public override void RequestFastFinish(bool force = false)
|
2021-01-08 16:21:03 -08:00
|
|
|
{
|
2021-12-11 09:08:42 -08:00
|
|
|
if (mThreadWorker.mThreadRunning || mThreadWorkerHi.mThreadRunning)
|
2021-01-08 16:21:03 -08:00
|
|
|
{
|
2021-12-11 09:08:42 -08:00
|
|
|
if ((!force) &&
|
|
|
|
((!mThreadWorker.mAllowFastFinish) || (!mThreadWorkerHi.mAllowFastFinish)))
|
|
|
|
return;
|
|
|
|
|
2021-01-30 14:43:10 -08:00
|
|
|
if ((mNativeBfCompiler != null) && (!gApp.mDeterministic))
|
2021-01-08 16:21:03 -08:00
|
|
|
BfCompiler_RequestFastFinish(mNativeBfCompiler);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
public void ClearCompletionPercentage()
|
|
|
|
{
|
|
|
|
BfCompiler_ClearCompletionPercentage(mNativeBfCompiler);
|
|
|
|
}
|
|
|
|
|
|
|
|
public float GetCompletionPercentage()
|
|
|
|
{
|
|
|
|
return BfCompiler_GetCompletionPercentage(mNativeBfCompiler);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int32 GetCompileRevision()
|
|
|
|
{
|
|
|
|
return BfCompiler_GetCompileRevision(mNativeBfCompiler);
|
|
|
|
}
|
|
|
|
|
2020-12-24 07:45:58 -08:00
|
|
|
public int32 GetCurConstEvalExecuteId()
|
|
|
|
{
|
|
|
|
return BfCompiler_GetCurConstEvalExecuteId(mNativeBfCompiler);
|
|
|
|
}
|
|
|
|
|
2021-12-11 09:08:42 -08:00
|
|
|
public void GetGeneratorTypeDefList(String outStr)
|
|
|
|
{
|
|
|
|
outStr.Append(BfCompiler_GetGeneratorTypeDefList(mNativeBfCompiler));
|
|
|
|
}
|
|
|
|
|
|
|
|
public void GetGeneratorInitData(String typeDefName, String args, String outStr)
|
|
|
|
{
|
|
|
|
outStr.Append(BfCompiler_GetGeneratorInitData(mNativeBfCompiler, typeDefName, args));
|
|
|
|
}
|
|
|
|
|
|
|
|
public void GetGeneratorGenData(String typeDefName, String args, String outStr)
|
|
|
|
{
|
|
|
|
outStr.Append(BfCompiler_GetGeneratorGenData(mNativeBfCompiler, typeDefName, args));
|
|
|
|
}
|
|
|
|
|
2022-08-23 19:13:15 +02:00
|
|
|
public void GetTypeDefList(String outStr, bool includeLocation = false)
|
2019-08-23 11:56:54 -07:00
|
|
|
{
|
2022-08-23 19:13:15 +02:00
|
|
|
outStr.Append(BfCompiler_GetTypeDefList(mNativeBfCompiler, includeLocation));
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
|
2022-08-23 19:13:15 +02:00
|
|
|
public void GetTypeDefMatches(String searchStr, String outStr, bool includeLocation = false)
|
2019-08-23 11:56:54 -07:00
|
|
|
{
|
2022-08-23 19:13:15 +02:00
|
|
|
outStr.Append(BfCompiler_GetTypeDefMatches(mNativeBfCompiler, searchStr, includeLocation));
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
public void GetTypeDefInfo(String typeDefName, String outStr)
|
|
|
|
{
|
|
|
|
outStr.Append(BfCompiler_GetTypeDefInfo(mNativeBfCompiler, typeDefName));
|
|
|
|
}
|
|
|
|
|
2022-04-16 06:27:54 -07:00
|
|
|
public void GetGenericTypeInstances(String typeName, String outStr)
|
|
|
|
{
|
|
|
|
outStr.Append(BfCompiler_GetGenericTypeInstances(mNativeBfCompiler, typeName));
|
|
|
|
}
|
|
|
|
|
2020-06-04 11:47:55 -07:00
|
|
|
public void GetTypeInfo(String typeDefName, String outStr)
|
|
|
|
{
|
|
|
|
outStr.Append(BfCompiler_GetTypeInfo(mNativeBfCompiler, typeDefName));
|
|
|
|
}
|
|
|
|
|
2022-04-16 06:27:54 -07:00
|
|
|
public int GetTypeId(String typeName)
|
|
|
|
{
|
|
|
|
return BfCompiler_GetTypeId(mNativeBfCompiler, typeName);
|
|
|
|
}
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
public void ClearBuildCache()
|
|
|
|
{
|
|
|
|
BfCompiler_ClearBuildCache(mNativeBfCompiler);
|
|
|
|
}
|
|
|
|
|
2019-09-28 09:48:37 -07:00
|
|
|
public void SetBuildValue(String cacheDir, String key, String value)
|
|
|
|
{
|
|
|
|
BfCompiler_SetBuildValue(mNativeBfCompiler, cacheDir, key, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void GetBuildValue(String cacheDir, String key, String outValue)
|
|
|
|
{
|
|
|
|
char8* cStr = BfCompiler_GetBuildValue(mNativeBfCompiler, cacheDir, key);
|
|
|
|
outValue.Append(cStr);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void WriteBuildCache(String cacheDir)
|
|
|
|
{
|
|
|
|
BfCompiler_WriteBuildCache(mNativeBfCompiler, cacheDir);
|
|
|
|
}
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
public bool GetHasHotPendingDataChanges()
|
|
|
|
{
|
|
|
|
return BfCompiler_GetHasHotPendingDataChanges(mNativeBfCompiler);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void HotCommit()
|
|
|
|
{
|
|
|
|
BfCompiler_HotCommit(mNativeBfCompiler);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void HotResolve_Start(HotResolveFlags flags)
|
|
|
|
{
|
|
|
|
BfCompiler_HotResolve_Start(mNativeBfCompiler, (.)flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void HotResolve_AddActiveMethod(char8* methodName)
|
|
|
|
{
|
|
|
|
BfCompiler_HotResolve_AddActiveMethod(mNativeBfCompiler, methodName);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void HotResolve_AddDelegateMethod(char8* methodName)
|
|
|
|
{
|
|
|
|
BfCompiler_HotResolve_AddDelegateMethod(mNativeBfCompiler, methodName);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void HotResolve_ReportType(int typeId, HotTypeFlags flags)
|
|
|
|
{
|
|
|
|
BfCompiler_HotResolve_ReportType(mNativeBfCompiler, typeId, (int32)flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void HotResolve_ReportTypeRange(char8* typeName, HotTypeFlags flags)
|
|
|
|
{
|
|
|
|
BfCompiler_HotResolve_ReportTypeRange(mNativeBfCompiler, typeName, (int32)flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void HotResolve_Finish(String result)
|
|
|
|
{
|
|
|
|
char8* resultCStr = BfCompiler_HotResolve_Finish(mNativeBfCompiler);
|
|
|
|
result.Append(resultCStr);
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void Update()
|
|
|
|
{
|
|
|
|
base.Update();
|
|
|
|
|
|
|
|
if (!ThreadRunning)
|
|
|
|
{
|
|
|
|
if (mWantsRemoveOldData)
|
|
|
|
{
|
2020-05-19 09:09:18 -07:00
|
|
|
mBfSystem.RemoveOldParsers();
|
2019-08-23 11:56:54 -07:00
|
|
|
mBfSystem.RemoveOldData();
|
|
|
|
mWantsRemoveOldData = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-12-20 09:52:29 -05:00
|
|
|
|
|
|
|
public bool GetLastHadComptimeRebuilds()
|
|
|
|
{
|
|
|
|
return BfCompiler_GetLastHadComptimeRebuilds(mNativeBfCompiler);
|
|
|
|
}
|
2021-12-29 10:07:36 -05:00
|
|
|
|
|
|
|
void UpdateRebuildFileWatches()
|
|
|
|
{
|
|
|
|
HashSet<StringView> curWatches = scope .();
|
|
|
|
|
|
|
|
var rebuildDirStr = GetRebuildFileSet(.. scope .());
|
|
|
|
for (var dir in rebuildDirStr.Split('\n', .RemoveEmptyEntries))
|
|
|
|
{
|
|
|
|
curWatches.Add(dir);
|
|
|
|
if (mRebuildWatchingFiles.TryAddAlt(dir, var keyPtr, var valuePtr))
|
|
|
|
{
|
|
|
|
*keyPtr = new String(dir);
|
|
|
|
String watchFile = *valuePtr = new .();
|
|
|
|
watchFile.Append(dir);
|
|
|
|
if ((watchFile.EndsWith(Path.DirectorySeparatorChar)) || (watchFile.EndsWith(Path.AltDirectorySeparatorChar)))
|
|
|
|
watchFile.Append("*");
|
|
|
|
gApp.mFileWatcher.WatchFile(watchFile, watchFile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
List<String> oldKeys = scope .();
|
|
|
|
for (var kv in mRebuildWatchingFiles)
|
|
|
|
{
|
|
|
|
if (!curWatches.Contains(kv.key))
|
|
|
|
{
|
|
|
|
gApp.mFileWatcher.RemoveWatch(kv.key, kv.value);
|
|
|
|
oldKeys.Add(kv.key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (var key in oldKeys)
|
|
|
|
{
|
|
|
|
var kv = mRebuildWatchingFiles.GetAndRemove(key).Value;
|
|
|
|
delete kv.key;
|
|
|
|
delete kv.value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool HasRebuildFileWatches()
|
|
|
|
{
|
|
|
|
return !mRebuildWatchingFiles.IsEmpty;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void AddChangedDirectory(StringView str)
|
|
|
|
{
|
|
|
|
var dirChangedCommand = new RebuildFileChangedCommand();
|
|
|
|
dirChangedCommand.mDir.Set(str);
|
|
|
|
QueueCommand(dirChangedCommand);
|
|
|
|
}
|
2022-04-16 06:27:54 -07:00
|
|
|
|
|
|
|
public void WriteEmitData(String filePath, BfProject bfProject)
|
|
|
|
{
|
|
|
|
BfCompiler_WriteEmitData(mNativeBfCompiler, filePath, bfProject.mNativeBfProject);
|
|
|
|
}
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
}
|