mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 12:32:20 +02:00
Removed "Dynamic Library" target type, replaced by Build Kind
This commit is contained in:
parent
1c1cb1ac49
commit
7ae8599916
8 changed files with 163 additions and 98 deletions
|
@ -296,7 +296,7 @@ namespace IDE
|
||||||
|
|
||||||
bool isTest = options.mBuildOptions.mBuildKind == .Test;
|
bool isTest = options.mBuildOptions.mBuildKind == .Test;
|
||||||
bool isExe = ((project.mGeneralOptions.mTargetType != Project.TargetType.BeefLib) && (project.mGeneralOptions.mTargetType != Project.TargetType.BeefTest)) || (isTest);
|
bool isExe = ((project.mGeneralOptions.mTargetType != Project.TargetType.BeefLib) && (project.mGeneralOptions.mTargetType != Project.TargetType.BeefTest)) || (isTest);
|
||||||
bool isDynLib = project.mGeneralOptions.mTargetType == Project.TargetType.BeefDynLib;
|
bool isDynLib = (project.mGeneralOptions.mTargetType == Project.TargetType.BeefLib) && (options.mBuildOptions.mBuildKind == .DynamicLib);
|
||||||
|
|
||||||
if (options.mBuildOptions.mBuildKind == .StaticLib)
|
if (options.mBuildOptions.mBuildKind == .StaticLib)
|
||||||
isExe = false;
|
isExe = false;
|
||||||
|
@ -525,7 +525,7 @@ namespace IDE
|
||||||
|
|
||||||
bool isTest = options.mBuildOptions.mBuildKind == .Test;
|
bool isTest = options.mBuildOptions.mBuildKind == .Test;
|
||||||
bool isExe = ((project.mGeneralOptions.mTargetType != Project.TargetType.BeefLib) && (project.mGeneralOptions.mTargetType != Project.TargetType.BeefTest)) || (isTest);
|
bool isExe = ((project.mGeneralOptions.mTargetType != Project.TargetType.BeefLib) && (project.mGeneralOptions.mTargetType != Project.TargetType.BeefTest)) || (isTest);
|
||||||
bool isDynLib = project.mGeneralOptions.mTargetType == Project.TargetType.BeefDynLib;
|
bool isDynLib = (project.mGeneralOptions.mTargetType == Project.TargetType.BeefLib) && (options.mBuildOptions.mBuildKind == .DynamicLib);
|
||||||
|
|
||||||
if (isExe || isDynLib)
|
if (isExe || isDynLib)
|
||||||
{
|
{
|
||||||
|
@ -761,7 +761,8 @@ namespace IDE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (depProject.mGeneralOptions.mTargetType == .BeefDynLib)
|
bool depIsDynLib = (depProject.mGeneralOptions.mTargetType == Project.TargetType.BeefLib) && (depOptions.mBuildOptions.mBuildKind == .DynamicLib);
|
||||||
|
if (depIsDynLib)
|
||||||
{
|
{
|
||||||
if (mImpLibMap.TryGetValue(depProject, var libPath))
|
if (mImpLibMap.TryGetValue(depProject, var libPath))
|
||||||
{
|
{
|
||||||
|
@ -797,9 +798,9 @@ namespace IDE
|
||||||
|
|
||||||
bool isTest = options.mBuildOptions.mBuildKind == .Test;
|
bool isTest = options.mBuildOptions.mBuildKind == .Test;
|
||||||
bool isExe = ((project.mGeneralOptions.mTargetType != Project.TargetType.BeefLib) && (project.mGeneralOptions.mTargetType != Project.TargetType.BeefTest)) || (isTest);
|
bool isExe = ((project.mGeneralOptions.mTargetType != Project.TargetType.BeefLib) && (project.mGeneralOptions.mTargetType != Project.TargetType.BeefTest)) || (isTest);
|
||||||
if (options.mBuildOptions.mBuildKind == .StaticLib)
|
if (options.mBuildOptions.mBuildKind == .DynamicLib)
|
||||||
isExe = false;
|
isExe = true;
|
||||||
|
|
||||||
if (isExe)
|
if (isExe)
|
||||||
{
|
{
|
||||||
String linkLine = scope String();
|
String linkLine = scope String();
|
||||||
|
@ -814,7 +815,7 @@ namespace IDE
|
||||||
linkLine.Append("-subsystem:windows ");
|
linkLine.Append("-subsystem:windows ");
|
||||||
else if (project.mGeneralOptions.mTargetType == .C_GUIApplication)
|
else if (project.mGeneralOptions.mTargetType == .C_GUIApplication)
|
||||||
linkLine.Append("-subsystem:console ");
|
linkLine.Append("-subsystem:console ");
|
||||||
else if (project.mGeneralOptions.mTargetType == .BeefDynLib)
|
else if (project.mGeneralOptions.mTargetType == .BeefLib)
|
||||||
{
|
{
|
||||||
linkLine.Append("-dll ");
|
linkLine.Append("-dll ");
|
||||||
|
|
||||||
|
@ -885,7 +886,7 @@ namespace IDE
|
||||||
|
|
||||||
linkLine.Append("-nologo ");
|
linkLine.Append("-nologo ");
|
||||||
|
|
||||||
if ((project.mGeneralOptions.mTargetType == .BeefDynLib) && (workspaceOptions.mAllowHotSwapping) && (is64Bit))
|
if ((project.mGeneralOptions.mTargetType == .BeefLib) && (workspaceOptions.mAllowHotSwapping) && (is64Bit))
|
||||||
{
|
{
|
||||||
// This helps to ensure that DLLs have enough hot swapping space after them
|
// This helps to ensure that DLLs have enough hot swapping space after them
|
||||||
int nameHash = targetPath.GetHashCode();
|
int nameHash = targetPath.GetHashCode();
|
||||||
|
@ -1204,7 +1205,7 @@ namespace IDE
|
||||||
Directory.CreateDirectory(targetDir).IgnoreError();
|
Directory.CreateDirectory(targetDir).IgnoreError();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (project.mGeneralOptions.mTargetType == .BeefDynLib)
|
if (project.mGeneralOptions.mTargetType == .BeefLib)
|
||||||
{
|
{
|
||||||
if (targetPath.EndsWith(".dll", .InvariantCultureIgnoreCase))
|
if (targetPath.EndsWith(".dll", .InvariantCultureIgnoreCase))
|
||||||
{
|
{
|
||||||
|
|
|
@ -8884,11 +8884,15 @@ namespace IDE
|
||||||
{
|
{
|
||||||
if (project.mGeneralOptions.mTargetType.IsBeefApplication)
|
if (project.mGeneralOptions.mTargetType.IsBeefApplication)
|
||||||
targetType = .BeefApplication_StaticLib;
|
targetType = .BeefApplication_StaticLib;
|
||||||
|
else if (project.mGeneralOptions.mTargetType == .BeefLib)
|
||||||
|
targetType = .BeefLib_Static;
|
||||||
}
|
}
|
||||||
else if (options.mBuildOptions.mBuildKind == .DynamicLib)
|
else if (options.mBuildOptions.mBuildKind == .DynamicLib)
|
||||||
{
|
{
|
||||||
if (project.mGeneralOptions.mTargetType.IsBeefApplication)
|
if (project.mGeneralOptions.mTargetType.IsBeefApplication)
|
||||||
targetType = .BeefApplication_DynamicLib;
|
targetType = .BeefApplication_DynamicLib;
|
||||||
|
else if (project.mGeneralOptions.mTargetType == .BeefLib)
|
||||||
|
targetType = .BeefLib_Dynamic;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9418,48 +9422,28 @@ namespace IDE
|
||||||
|
|
||||||
let platformType = Workspace.PlatformType.GetFromName(platformName);
|
let platformType = Workspace.PlatformType.GetFromName(platformName);
|
||||||
|
|
||||||
if (options.mBuildOptions.mBuildKind.IsApplicationLib)
|
switch (platformType)
|
||||||
{
|
{
|
||||||
switch (platformType)
|
case .Windows:
|
||||||
{
|
if (options.mBuildOptions.mBuildKind == .DynamicLib)
|
||||||
case .Windows:
|
newString.Append(".dll");
|
||||||
|
else if ((options.mBuildOptions.mBuildKind == .StaticLib) || (project.mGeneralOptions.mTargetType == .BeefLib))
|
||||||
newString.Append(".lib");
|
newString.Append(".lib");
|
||||||
case .iOS:
|
else if (project.mGeneralOptions.mTargetType != .CustomBuild)
|
||||||
if (options.mBuildOptions.mBuildKind == .DynamicLib)
|
newString.Append(".exe");
|
||||||
newString.Append(".dylib");
|
case .macOS:
|
||||||
else
|
if (options.mBuildOptions.mBuildKind == .DynamicLib)
|
||||||
newString.Append(".a");
|
newString.Append(".dylib");
|
||||||
case .Wasm:
|
else if (options.mBuildOptions.mBuildKind == .StaticLib)
|
||||||
if (!newString.Contains('.'))
|
newString.Append(".a");
|
||||||
newString.Append(".html");
|
case .Wasm:
|
||||||
default:
|
if (!newString.Contains('.'))
|
||||||
if (options.mBuildOptions.mBuildKind == .DynamicLib)
|
newString.Append(".html");
|
||||||
newString.Append(".so");
|
default:
|
||||||
else
|
if (options.mBuildOptions.mBuildKind == .DynamicLib)
|
||||||
newString.Append(".a");
|
newString.Append(".so");
|
||||||
}
|
else if (options.mBuildOptions.mBuildKind == .StaticLib)
|
||||||
}
|
newString.Append(".a");
|
||||||
else
|
|
||||||
{
|
|
||||||
switch (platformType)
|
|
||||||
{
|
|
||||||
case .Windows:
|
|
||||||
if (project.mGeneralOptions.mTargetType == .BeefLib)
|
|
||||||
newString.Append(".lib");
|
|
||||||
else if (project.mGeneralOptions.mTargetType == .BeefDynLib)
|
|
||||||
newString.Append(".dll");
|
|
||||||
else if (project.mGeneralOptions.mTargetType != .CustomBuild)
|
|
||||||
newString.Append(".exe");
|
|
||||||
case .macOS:
|
|
||||||
if (project.mGeneralOptions.mTargetType == .BeefDynLib)
|
|
||||||
newString.Append(".dylib");
|
|
||||||
case .Wasm:
|
|
||||||
if (!newString.Contains('.'))
|
|
||||||
newString.Append(".html");
|
|
||||||
default:
|
|
||||||
if (project.mGeneralOptions.mTargetType == .BeefDynLib)
|
|
||||||
newString.Append(".so");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
IDEUtils.FixFilePath(newString);
|
IDEUtils.FixFilePath(newString);
|
||||||
|
@ -9480,9 +9464,11 @@ namespace IDE
|
||||||
case "LinkFlags":
|
case "LinkFlags":
|
||||||
newString = scope:ReplaceBlock String();
|
newString = scope:ReplaceBlock String();
|
||||||
|
|
||||||
|
bool isBeefDynLib = (project.mGeneralOptions.mTargetType == .BeefLib) && (options.mBuildOptions.mBuildKind == .DynamicLib);
|
||||||
|
|
||||||
if ((project.mGeneralOptions.mTargetType == .BeefConsoleApplication) ||
|
if ((project.mGeneralOptions.mTargetType == .BeefConsoleApplication) ||
|
||||||
(project.mGeneralOptions.mTargetType == .BeefGUIApplication) ||
|
(project.mGeneralOptions.mTargetType == .BeefGUIApplication) ||
|
||||||
(project.mGeneralOptions.mTargetType == .BeefDynLib) ||
|
(isBeefDynLib) ||
|
||||||
(options.mBuildOptions.mBuildKind == .Test))
|
(options.mBuildOptions.mBuildKind == .Test))
|
||||||
{
|
{
|
||||||
let platformType = Workspace.PlatformType.GetFromName(platformName);
|
let platformType = Workspace.PlatformType.GetFromName(platformName);
|
||||||
|
|
|
@ -866,14 +866,6 @@ namespace IDE
|
||||||
case StaticLib;
|
case StaticLib;
|
||||||
case DynamicLib;
|
case DynamicLib;
|
||||||
case NotSupported;
|
case NotSupported;
|
||||||
|
|
||||||
public bool IsApplicationLib
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return (this == .StaticLib) || (this == .DynamicLib);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum COptimizationLevel
|
public enum COptimizationLevel
|
||||||
|
@ -916,13 +908,14 @@ namespace IDE
|
||||||
case BeefConsoleApplication,
|
case BeefConsoleApplication,
|
||||||
BeefGUIApplication,
|
BeefGUIApplication,
|
||||||
BeefLib,
|
BeefLib,
|
||||||
BeefDynLib,
|
|
||||||
CustomBuild,
|
CustomBuild,
|
||||||
BeefTest,
|
BeefTest,
|
||||||
C_ConsoleApplication,
|
C_ConsoleApplication,
|
||||||
C_GUIApplication,
|
C_GUIApplication,
|
||||||
BeefApplication_StaticLib,
|
BeefApplication_StaticLib,
|
||||||
BeefApplication_DynamicLib;
|
BeefApplication_DynamicLib,
|
||||||
|
BeefLib_Static,
|
||||||
|
BeefLib_Dynamic;
|
||||||
|
|
||||||
public bool IsBeef
|
public bool IsBeef
|
||||||
{
|
{
|
||||||
|
@ -933,7 +926,6 @@ namespace IDE
|
||||||
case BeefConsoleApplication,
|
case BeefConsoleApplication,
|
||||||
BeefGUIApplication,
|
BeefGUIApplication,
|
||||||
BeefLib,
|
BeefLib,
|
||||||
BeefDynLib,
|
|
||||||
BeefTest:
|
BeefTest:
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
|
@ -956,6 +948,22 @@ namespace IDE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsBeefApplicationOrLib
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
switch (this)
|
||||||
|
{
|
||||||
|
case BeefConsoleApplication,
|
||||||
|
BeefGUIApplication,
|
||||||
|
BeefLib:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class WindowsOptions
|
public class WindowsOptions
|
||||||
|
@ -1863,7 +1871,8 @@ namespace IDE
|
||||||
strs.Add(cmd);
|
strs.Add(cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isBeefDynLib = false;
|
||||||
using (data.Open("Project"))
|
using (data.Open("Project"))
|
||||||
{
|
{
|
||||||
if (!IsSingleFile)
|
if (!IsSingleFile)
|
||||||
|
@ -1889,6 +1898,9 @@ namespace IDE
|
||||||
mGeneralOptions.mTargetType = .BeefGUIApplication;
|
mGeneralOptions.mTargetType = .BeefGUIApplication;
|
||||||
case "C_WindowsApplication":
|
case "C_WindowsApplication":
|
||||||
mGeneralOptions.mTargetType = .C_GUIApplication;
|
mGeneralOptions.mTargetType = .C_GUIApplication;
|
||||||
|
case "BeefDynLib":
|
||||||
|
mGeneralOptions.mTargetType = .BeefLib;
|
||||||
|
isBeefDynLib = true;
|
||||||
default:
|
default:
|
||||||
mGeneralOptions.mTargetType = data.GetEnum<TargetType>("TargetType", GetDefaultTargetType());
|
mGeneralOptions.mTargetType = data.GetEnum<TargetType>("TargetType", GetDefaultTargetType());
|
||||||
}
|
}
|
||||||
|
@ -1962,6 +1974,8 @@ namespace IDE
|
||||||
|
|
||||||
// Build
|
// Build
|
||||||
options.mBuildOptions.mBuildKind = data.GetEnum<BuildKind>("BuildKind", isTest ? .Test : .Normal);
|
options.mBuildOptions.mBuildKind = data.GetEnum<BuildKind>("BuildKind", isTest ? .Test : .Normal);
|
||||||
|
if ((isBeefDynLib) && (options.mBuildOptions.mBuildKind == .Normal))
|
||||||
|
options.mBuildOptions.mBuildKind = .DynamicLib;
|
||||||
data.GetString("TargetDirectory", options.mBuildOptions.mTargetDirectory, "$(BuildDir)");
|
data.GetString("TargetDirectory", options.mBuildOptions.mTargetDirectory, "$(BuildDir)");
|
||||||
data.GetString("TargetName", options.mBuildOptions.mTargetName, "$(ProjectName)");
|
data.GetString("TargetName", options.mBuildOptions.mTargetName, "$(ProjectName)");
|
||||||
data.GetString("OtherLinkFlags", options.mBuildOptions.mOtherLinkFlags, "$(LinkFlags)");
|
data.GetString("OtherLinkFlags", options.mBuildOptions.mOtherLinkFlags, "$(LinkFlags)");
|
||||||
|
|
|
@ -16,11 +16,10 @@ namespace IDE.ui
|
||||||
public PathEditWidget mDirectoryEdit;
|
public PathEditWidget mDirectoryEdit;
|
||||||
public EditWidget mNameEdit;
|
public EditWidget mNameEdit;
|
||||||
public DarkComboBox mTargetComboBox;
|
public DarkComboBox mTargetComboBox;
|
||||||
static String[6] sApplicationTypeNames =
|
static String[5] sApplicationTypeNames =
|
||||||
.("Console Application",
|
.("Console Application",
|
||||||
"GUI Application",
|
"GUI Application",
|
||||||
"Library",
|
"Library",
|
||||||
"Dynamic Library",
|
|
||||||
"Custom Build",
|
"Custom Build",
|
||||||
"Test");
|
"Test");
|
||||||
public bool mNameChanged;
|
public bool mNameChanged;
|
||||||
|
|
|
@ -622,7 +622,6 @@ namespace IDE.ui
|
||||||
"Console Application",
|
"Console Application",
|
||||||
"GUI Application",
|
"GUI Application",
|
||||||
"Library",
|
"Library",
|
||||||
"Dynamic Library",
|
|
||||||
"Custom Build",
|
"Custom Build",
|
||||||
"Test"
|
"Test"
|
||||||
));
|
));
|
||||||
|
|
|
@ -521,11 +521,12 @@ bool BfCompiler::IsTypeUsed(BfType* checkType, BfProject* curProject)
|
||||||
BfTypeInstance* typeInst = checkType->ToTypeInstance();
|
BfTypeInstance* typeInst = checkType->ToTypeInstance();
|
||||||
if (typeInst != NULL)
|
if (typeInst != NULL)
|
||||||
{
|
{
|
||||||
if ((typeInst->mTypeDef->mProject != NULL) && (typeInst->mTypeDef->mProject != curProject))
|
//TODO: Why was this here?
|
||||||
{
|
// if ((typeInst->mTypeDef->mProject != NULL) && (typeInst->mTypeDef->mProject != curProject))
|
||||||
if (typeInst->mTypeDef->mProject->mTargetType == BfTargetType_BeefDynLib)
|
// {
|
||||||
return false;
|
// if (typeInst->mTypeDef->mProject->mTargetType == BfTargetType_BeefDynLib)
|
||||||
}
|
// return false;
|
||||||
|
// }
|
||||||
|
|
||||||
if (checkType->IsInterface())
|
if (checkType->IsInterface())
|
||||||
return typeInst->mIsReified;
|
return typeInst->mIsReified;
|
||||||
|
@ -1217,11 +1218,12 @@ void BfCompiler::CreateVData(BfVDataModule* bfModule)
|
||||||
baseType = baseType->mBaseType;
|
baseType = baseType->mBaseType;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (module->mProject != bfModule->mProject)
|
//TODO: What was this for?
|
||||||
{
|
// if (module->mProject != bfModule->mProject)
|
||||||
if ((module->mProject != NULL) && (module->mProject->mTargetType == BfTargetType_BeefDynLib))
|
// {
|
||||||
continue;
|
// if ((module->mProject != NULL) && (module->mProject->mTargetType == BfTargetType_BeefDynLib))
|
||||||
}
|
// continue;
|
||||||
|
// }
|
||||||
|
|
||||||
if (typeInst->mHasStaticInitMethod)
|
if (typeInst->mHasStaticInitMethod)
|
||||||
sortedStaticInitMap.insert(std::make_pair(bfModule->TypeToString(type), typeInst));
|
sortedStaticInitMap.insert(std::make_pair(bfModule->TypeToString(type), typeInst));
|
||||||
|
@ -1662,8 +1664,18 @@ void BfCompiler::CreateVData(BfVDataModule* bfModule)
|
||||||
if ((targetType == BfTargetType_BeefWindowsApplication) && (mOptions.mPlatformType != BfPlatformType_Windows))
|
if ((targetType == BfTargetType_BeefWindowsApplication) && (mOptions.mPlatformType != BfPlatformType_Windows))
|
||||||
targetType = BfTargetType_BeefConsoleApplication;
|
targetType = BfTargetType_BeefConsoleApplication;
|
||||||
|
|
||||||
bool isPosixDynLib = (targetType == BfTargetType_BeefDynLib) && (mOptions.mPlatformType != BfPlatformType_Windows);
|
bool isConsoleApplication = (targetType == BfTargetType_BeefConsoleApplication) || (targetType == BfTargetType_BeefTest);
|
||||||
|
if ((targetType == BfTargetType_BeefWindowsApplication) && (mOptions.mPlatformType != BfPlatformType_Windows))
|
||||||
|
isConsoleApplication = true;
|
||||||
|
|
||||||
|
bool isDllMain = (targetType == BfTargetType_BeefLib_DynamicLib) && (mOptions.mPlatformType == BfPlatformType_Windows);
|
||||||
|
bool isPosixDynLib = ((targetType == BfTargetType_BeefLib_DynamicLib) || (targetType == BfTargetType_BeefLib_StaticLib)) &&
|
||||||
|
(mOptions.mPlatformType != BfPlatformType_Windows);
|
||||||
|
|
||||||
|
bool mainHasArgs = (targetType != BfTargetType_BeefLib_DynamicLib) && (targetType != BfTargetType_BeefLib_StaticLib) &&
|
||||||
|
(mOptions.mPlatformType != BfPlatformType_Wasm);
|
||||||
|
bool mainHasRet = (targetType != BfTargetType_BeefLib_DynamicLib) && (targetType != BfTargetType_BeefLib_StaticLib);
|
||||||
|
|
||||||
// Generate "main"
|
// Generate "main"
|
||||||
if (!IsHotCompile())
|
if (!IsHotCompile())
|
||||||
{
|
{
|
||||||
|
@ -1671,7 +1683,9 @@ void BfCompiler::CreateVData(BfVDataModule* bfModule)
|
||||||
|
|
||||||
BfIRFunctionType mainFuncType;
|
BfIRFunctionType mainFuncType;
|
||||||
BfIRFunction mainFunc;
|
BfIRFunction mainFunc;
|
||||||
if ((targetType == BfTargetType_BeefConsoleApplication) || (targetType == BfTargetType_BeefTest))
|
BfIRFunctionType shutdownFuncType;
|
||||||
|
BfIRFunction shutdownFunc;
|
||||||
|
if (isConsoleApplication)
|
||||||
{
|
{
|
||||||
SmallVector<BfIRType, 2> paramTypes;
|
SmallVector<BfIRType, 2> paramTypes;
|
||||||
paramTypes.push_back(int32Type);
|
paramTypes.push_back(int32Type);
|
||||||
|
@ -1680,7 +1694,7 @@ void BfCompiler::CreateVData(BfVDataModule* bfModule)
|
||||||
mainFunc = bfModule->mBfIRBuilder->CreateFunction(mainFuncType, BfIRLinkageType_External, "main");
|
mainFunc = bfModule->mBfIRBuilder->CreateFunction(mainFuncType, BfIRLinkageType_External, "main");
|
||||||
bfModule->SetupIRMethod(NULL, mainFunc, false);
|
bfModule->SetupIRMethod(NULL, mainFunc, false);
|
||||||
}
|
}
|
||||||
else if (targetType == BfTargetType_BeefDynLib)
|
else if (isDllMain)
|
||||||
{
|
{
|
||||||
SmallVector<BfIRType, 4> paramTypes;
|
SmallVector<BfIRType, 4> paramTypes;
|
||||||
paramTypes.push_back(nullPtrType); // hinstDLL
|
paramTypes.push_back(nullPtrType); // hinstDLL
|
||||||
|
@ -1708,15 +1722,43 @@ void BfCompiler::CreateVData(BfVDataModule* bfModule)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SmallVector<BfIRType, 2> paramTypes;
|
BfIRFunction combinedFunc;
|
||||||
if (mOptions.mPlatformType != BfPlatformType_Wasm)
|
|
||||||
|
SmallVector<BfIRType, 2> paramTypes;
|
||||||
|
if (mainHasArgs)
|
||||||
{
|
{
|
||||||
paramTypes.push_back(int32Type);
|
paramTypes.push_back(int32Type);
|
||||||
paramTypes.push_back(nullPtrType);
|
paramTypes.push_back(nullPtrType);
|
||||||
}
|
}
|
||||||
mainFuncType = bfModule->mBfIRBuilder->CreateFunctionType(int32Type, paramTypes, false);
|
mainFuncType = bfModule->mBfIRBuilder->CreateFunctionType(mainHasRet ? int32Type : voidType, paramTypes, false);
|
||||||
mainFunc = bfModule->mBfIRBuilder->CreateFunction(mainFuncType, BfIRLinkageType_External, "BeefMain");
|
mainFunc = bfModule->mBfIRBuilder->CreateFunction(mainFuncType, BfIRLinkageType_External, "BeefStart");
|
||||||
bfModule->SetupIRMethod(NULL, mainFunc, false);
|
bfModule->SetupIRMethod(NULL, mainFunc, false);
|
||||||
|
|
||||||
|
combinedFunc = bfModule->mBfIRBuilder->CreateFunction(mainFuncType, BfIRLinkageType_External, "BeefMain");
|
||||||
|
bfModule->SetupIRMethod(NULL, combinedFunc, false);
|
||||||
|
|
||||||
|
paramTypes.clear();
|
||||||
|
shutdownFuncType = bfModule->mBfIRBuilder->CreateFunctionType(voidType, paramTypes, false);
|
||||||
|
shutdownFunc = bfModule->mBfIRBuilder->CreateFunction(shutdownFuncType, BfIRLinkageType_External, "BeefStop");
|
||||||
|
bfModule->SetupIRMethod(NULL, shutdownFunc, false);
|
||||||
|
|
||||||
|
bfModule->mBfIRBuilder->SetActiveFunction(combinedFunc);
|
||||||
|
auto entryBlock = bfModule->mBfIRBuilder->CreateBlock("entry", true);
|
||||||
|
bfModule->mBfIRBuilder->SetInsertPoint(entryBlock);
|
||||||
|
|
||||||
|
SmallVector<BfIRValue, 1> args;
|
||||||
|
if (mainHasArgs)
|
||||||
|
{
|
||||||
|
args.push_back(bfModule->mBfIRBuilder->GetArgument(0));
|
||||||
|
args.push_back(bfModule->mBfIRBuilder->GetArgument(1));
|
||||||
|
}
|
||||||
|
auto res = bfModule->mBfIRBuilder->CreateCall(mainFunc, args);
|
||||||
|
args.clear();
|
||||||
|
bfModule->mBfIRBuilder->CreateCall(shutdownFunc, args);
|
||||||
|
if (mainHasArgs)
|
||||||
|
bfModule->mBfIRBuilder->CreateRet(res);
|
||||||
|
else
|
||||||
|
bfModule->mBfIRBuilder->CreateRetVoid();
|
||||||
}
|
}
|
||||||
|
|
||||||
bfModule->mBfIRBuilder->SetActiveFunction(mainFunc);
|
bfModule->mBfIRBuilder->SetActiveFunction(mainFunc);
|
||||||
|
@ -1746,13 +1788,16 @@ void BfCompiler::CreateVData(BfVDataModule* bfModule)
|
||||||
bfModule->SetupIRMethod(NULL, setCmdLineFunc, false);
|
bfModule->SetupIRMethod(NULL, setCmdLineFunc, false);
|
||||||
|
|
||||||
SmallVector<BfIRValue, 2> args;
|
SmallVector<BfIRValue, 2> args;
|
||||||
args.push_back(bfModule->mBfIRBuilder->GetArgument(0));
|
if (mainHasArgs)
|
||||||
args.push_back(bfModule->mBfIRBuilder->GetArgument(1));
|
{
|
||||||
|
args.push_back(bfModule->mBfIRBuilder->GetArgument(0));
|
||||||
|
args.push_back(bfModule->mBfIRBuilder->GetArgument(1));
|
||||||
|
}
|
||||||
bfModule->mBfIRBuilder->CreateCall(setCmdLineFunc, args);
|
bfModule->mBfIRBuilder->CreateCall(setCmdLineFunc, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
BfIRBlock initSkipBlock;
|
BfIRBlock initSkipBlock;
|
||||||
if (targetType == BfTargetType_BeefDynLib)
|
if (isDllMain)
|
||||||
{
|
{
|
||||||
auto initBlock = bfModule->mBfIRBuilder->CreateBlock("doInit", false);
|
auto initBlock = bfModule->mBfIRBuilder->CreateBlock("doInit", false);
|
||||||
initSkipBlock = bfModule->mBfIRBuilder->CreateBlock("skipInit", false);
|
initSkipBlock = bfModule->mBfIRBuilder->CreateBlock("skipInit", false);
|
||||||
|
@ -1960,18 +2005,19 @@ void BfCompiler::CreateVData(BfVDataModule* bfModule)
|
||||||
|
|
||||||
if (!hadRet)
|
if (!hadRet)
|
||||||
retValue = bfModule->GetConstValue32(0);
|
retValue = bfModule->GetConstValue32(0);
|
||||||
}
|
}
|
||||||
else if (targetType == BfTargetType_BeefDynLib)
|
else
|
||||||
{
|
{
|
||||||
retValue = bfModule->GetConstValue32(1);
|
if (mainHasRet)
|
||||||
|
retValue = bfModule->GetConstValue32(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (targetType == BfTargetType_BeefTest)
|
if (targetType == BfTargetType_BeefTest)
|
||||||
EmitTestMethod(bfModule, testMethods, retValue);
|
EmitTestMethod(bfModule, testMethods, retValue);
|
||||||
|
|
||||||
BfIRBlock deinitSkipBlock;
|
BfIRBlock deinitSkipBlock;
|
||||||
if (targetType == BfTargetType_BeefDynLib)
|
if (isDllMain)
|
||||||
{
|
{
|
||||||
auto deinitBlock = bfModule->mBfIRBuilder->CreateBlock("doDeinit", false);
|
auto deinitBlock = bfModule->mBfIRBuilder->CreateBlock("doDeinit", false);
|
||||||
deinitSkipBlock = bfModule->mBfIRBuilder->CreateBlock("skipDeinit", false);
|
deinitSkipBlock = bfModule->mBfIRBuilder->CreateBlock("skipDeinit", false);
|
||||||
auto cmpResult = bfModule->mBfIRBuilder->CreateCmpEQ(bfModule->mBfIRBuilder->GetArgument(1), bfModule->mBfIRBuilder->CreateConst(BfTypeCode_Int32, 0));
|
auto cmpResult = bfModule->mBfIRBuilder->CreateCmpEQ(bfModule->mBfIRBuilder->GetArgument(1), bfModule->mBfIRBuilder->CreateConst(BfTypeCode_Int32, 0));
|
||||||
|
@ -1982,6 +2028,14 @@ void BfCompiler::CreateVData(BfVDataModule* bfModule)
|
||||||
|
|
||||||
if (mOptions.mPlatformType != BfPlatformType_Wasm)
|
if (mOptions.mPlatformType != BfPlatformType_Wasm)
|
||||||
{
|
{
|
||||||
|
auto prevBlock = bfModule->mBfIRBuilder->GetInsertBlock();
|
||||||
|
if (shutdownFunc)
|
||||||
|
{
|
||||||
|
bfModule->mBfIRBuilder->SetActiveFunction(shutdownFunc);
|
||||||
|
auto entryBlock = bfModule->mBfIRBuilder->CreateBlock("entry", true);
|
||||||
|
bfModule->mBfIRBuilder->SetInsertPoint(entryBlock);
|
||||||
|
}
|
||||||
|
|
||||||
bfModule->mBfIRBuilder->CreateCall(dtorFunc, SizedArray<BfIRValue, 0>());
|
bfModule->mBfIRBuilder->CreateCall(dtorFunc, SizedArray<BfIRValue, 0>());
|
||||||
|
|
||||||
BfModuleMethodInstance shutdownMethod = bfModule->GetInternalMethod("Shutdown");
|
BfModuleMethodInstance shutdownMethod = bfModule->GetInternalMethod("Shutdown");
|
||||||
|
@ -1989,6 +2043,13 @@ void BfCompiler::CreateVData(BfVDataModule* bfModule)
|
||||||
{
|
{
|
||||||
bfModule->mBfIRBuilder->CreateCall(shutdownMethod.mFunc, SizedArray<BfIRValue, 0>());
|
bfModule->mBfIRBuilder->CreateCall(shutdownMethod.mFunc, SizedArray<BfIRValue, 0>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (shutdownFunc)
|
||||||
|
{
|
||||||
|
bfModule->mBfIRBuilder->CreateRetVoid();
|
||||||
|
bfModule->mBfIRBuilder->SetActiveFunction(mainFunc);
|
||||||
|
bfModule->mBfIRBuilder->SetInsertPoint(prevBlock);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (deinitSkipBlock)
|
if (deinitSkipBlock)
|
||||||
|
@ -6772,7 +6833,7 @@ bool BfCompiler::DoCompile(const StringImpl& outputDirectory)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((bfProject->mTargetType != BfTargetType_BeefConsoleApplication) && (bfProject->mTargetType != BfTargetType_BeefWindowsApplication) &&
|
if ((bfProject->mTargetType != BfTargetType_BeefConsoleApplication) && (bfProject->mTargetType != BfTargetType_BeefWindowsApplication) &&
|
||||||
(bfProject->mTargetType != BfTargetType_BeefDynLib) &&
|
(bfProject->mTargetType != BfTargetType_BeefLib_DynamicLib) && (bfProject->mTargetType != BfTargetType_BeefLib_StaticLib) &&
|
||||||
(bfProject->mTargetType != BfTargetType_C_ConsoleApplication) && (bfProject->mTargetType != BfTargetType_C_WindowsApplication) &&
|
(bfProject->mTargetType != BfTargetType_C_ConsoleApplication) && (bfProject->mTargetType != BfTargetType_C_WindowsApplication) &&
|
||||||
(bfProject->mTargetType != BfTargetType_BeefTest) &&
|
(bfProject->mTargetType != BfTargetType_BeefTest) &&
|
||||||
(bfProject->mTargetType != BfTargetType_BeefApplication_StaticLib) && (bfProject->mTargetType != BfTargetType_BeefApplication_DynamicLib))
|
(bfProject->mTargetType != BfTargetType_BeefApplication_StaticLib) && (bfProject->mTargetType != BfTargetType_BeefApplication_DynamicLib))
|
||||||
|
@ -9072,8 +9133,9 @@ BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetUsedOutputFileNames(BfCompiler*
|
||||||
canReference = false;
|
canReference = false;
|
||||||
if (bfProject != project)
|
if (bfProject != project)
|
||||||
{
|
{
|
||||||
if (project->mTargetType == BfTargetType_BeefDynLib)
|
//TODO: What was this for?
|
||||||
canReference = false;
|
// if (project->mTargetType == BfTargetType_BeefDynLib)
|
||||||
|
// canReference = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!canReference)
|
if (!canReference)
|
||||||
|
|
|
@ -16121,7 +16121,10 @@ void BfModule::SetupIRMethod(BfMethodInstance* methodInstance, BfIRFunction func
|
||||||
if (methodInstance->mReturnType->IsVar())
|
if (methodInstance->mReturnType->IsVar())
|
||||||
mBfIRBuilder->Func_AddAttribute(func, -1, BfIRAttribute_VarRet);
|
mBfIRBuilder->Func_AddAttribute(func, -1, BfIRAttribute_VarRet);
|
||||||
if (methodDef->mImportKind == BfImportKind_Export)
|
if (methodDef->mImportKind == BfImportKind_Export)
|
||||||
mBfIRBuilder->Func_AddAttribute(func, -1, BFIRAttribute_DllExport);
|
{
|
||||||
|
if (methodDef->mDeclaringType->mProject->mTargetType != BfTargetType_BeefLib_StaticLib)
|
||||||
|
mBfIRBuilder->Func_AddAttribute(func, -1, BFIRAttribute_DllExport);
|
||||||
|
}
|
||||||
if (methodDef->mIsNoReturn)
|
if (methodDef->mIsNoReturn)
|
||||||
mBfIRBuilder->Func_AddAttribute(func, -1, BfIRAttribute_NoReturn);
|
mBfIRBuilder->Func_AddAttribute(func, -1, BfIRAttribute_NoReturn);
|
||||||
auto callingConv = GetIRCallingConvention(methodInstance);
|
auto callingConv = GetIRCallingConvention(methodInstance);
|
||||||
|
|
|
@ -1123,14 +1123,15 @@ enum BfTargetType
|
||||||
{
|
{
|
||||||
BfTargetType_BeefConsoleApplication,
|
BfTargetType_BeefConsoleApplication,
|
||||||
BfTargetType_BeefWindowsApplication,
|
BfTargetType_BeefWindowsApplication,
|
||||||
BfTargetType_BeefLib,
|
BfTargetType_BeefLib,
|
||||||
BfTargetType_BeefDynLib,
|
|
||||||
BfTargetType_CustomBuild,
|
BfTargetType_CustomBuild,
|
||||||
BfTargetType_BeefTest,
|
BfTargetType_BeefTest,
|
||||||
BfTargetType_C_ConsoleApplication,
|
BfTargetType_C_ConsoleApplication,
|
||||||
BfTargetType_C_WindowsApplication,
|
BfTargetType_C_WindowsApplication,
|
||||||
BfTargetType_BeefApplication_StaticLib,
|
BfTargetType_BeefApplication_StaticLib,
|
||||||
BfTargetType_BeefApplication_DynamicLib
|
BfTargetType_BeefApplication_DynamicLib,
|
||||||
|
BfTargetType_BeefLib_StaticLib,
|
||||||
|
BfTargetType_BeefLib_DynamicLib,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum BfProjectFlags
|
enum BfProjectFlags
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue