1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-13 13:54:11 +02:00

Change Beefy::defer to be simpler (no std::function), macOS changes

This commit is contained in:
Brian Fiete 2019-10-15 12:28:21 -07:00
parent 3bf4c792d8
commit c8ca66ec5c
18 changed files with 168 additions and 221 deletions

View file

@ -38,6 +38,18 @@ namespace IDE
Failed
}
Workspace.PlatformType mPlatformType;
Workspace.ToolsetType mToolset;
int mPtrSize;
public this()
{
Workspace.Options workspaceOptions = gApp.GetCurWorkspaceOptions();
mToolset = workspaceOptions.mToolsetType;
mPlatformType = Workspace.PlatformType.GetFromName(gApp.mPlatformName);
mPtrSize = Workspace.PlatformType.GetPtrSizeByName(gApp.mPlatformName);
}
public CustomBuildCommandResult QueueProjectCustomBuildCommands(Project project, String targetPath, Project.BuildCommandTrigger trigger, List<String> cmdList)
{
if (cmdList.IsEmpty)
@ -186,7 +198,8 @@ namespace IDE
linkLine.Append("-mwindows ");
}
linkLine.Append("-no-pie ");
if (mPlatformType == .Linux)
linkLine.Append("-no-pie ");
linkLine.Append(objectsArg);
@ -204,7 +217,7 @@ namespace IDE
String[] mingwFiles;
String fromDir;
if (Workspace.PlatformType.GetPtrSizeByName(gApp.mPlatformName) == 4)
if (mPtrSize == 4)
{
fromDir = scope:: String(llvmDir, "i686-w64-mingw32/bin/");
mingwFiles = scope:: String[] { "libgcc_s_dw2-1.dll", "libstdc++-6.dll" };
@ -298,7 +311,7 @@ namespace IDE
if (workspaceOptions.mToolsetType == .GNU)
{
if (Workspace.PlatformType.GetPtrSizeByName(gApp.mPlatformName) == 4)
if (mPtrSize == 4)
{
}
else
@ -311,7 +324,7 @@ namespace IDE
}
else // Microsoft
{
if (Workspace.PlatformType.GetPtrSizeByName(gApp.mPlatformName) == 4)
if (mPtrSize == 4)
{
//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)
@ -411,33 +424,11 @@ namespace IDE
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)
{
bool is64Bit = Workspace.PlatformType.GetPtrSizeByName(gApp.mPlatformName) == 8;
bool is64Bit = mPtrSize == 8;
String llvmDir = scope String(IDEApp.sApp.mInstallDir);
IDEUtils.FixFilePath(llvmDir);
@ -1060,7 +1051,12 @@ namespace IDE
}
else // MS
{
if (!QueueProjectMSLink(project, targetPath, configSelection.mConfig, workspaceOptions, options, objectsArg))
if (mPlatformType != .Windows)
{
gApp.OutputErrorLine("Project '{}' cannot be linked with the Windows Toolset for platform '{}'", project.mProjectName, mPlatformType);
return false;
}
else if (!QueueProjectMSLink(project, targetPath, configSelection.mConfig, workspaceOptions, options, objectsArg))
return false;
}

View file

@ -107,7 +107,7 @@ namespace IDE
#elif BF_PLATFORM_LINUX
public static readonly String sPlatform64Name = "Linux64";
public static readonly String sPlatform32Name = "Linux32";
#elif BF_PLATFORM_OSX
#elif BF_PLATFORM_MACOS
public static readonly String sPlatform64Name = "macOS";
public static readonly String sPlatform32Name = null;
#else
@ -8358,17 +8358,24 @@ namespace IDE
if (!DoResolveConfigString(platformName, workspaceOptions, project, options, options.mBuildOptions.mTargetName, error, newString))
return false;
#if BF_PLATFORM_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");
#else
if (project.mGeneralOptions.mTargetType == Project.TargetType.BeefLib)
newString.Append(".so");
#endif
let platformType = Workspace.PlatformType.GetFromName(platformName);
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 == Project.TargetType.BeefLib)
newString.Append(".dylib");
default:
if (project.mGeneralOptions.mTargetType == Project.TargetType.BeefLib)
newString.Append(".so");
}
}
case "ProjectDir":
if (project.IsDebugSession)
@ -8390,24 +8397,33 @@ namespace IDE
(project.mGeneralOptions.mTargetType == .BeefDynLib) ||
((options.mBuildOptions.mBuildKind == .Test) && (project == mWorkspace.mStartupProject)))
{
#if BF_PLATFORM_WINDOWS
String rtName = scope String();
String dbgName = scope String();
BuildContext.GetRtLibNames(workspaceOptions, options, false, rtName, dbgName);
newString.Append(rtName);
if (!dbgName.IsEmpty)
newString.Append(" ", dbgName);
switch (workspaceOptions.mAllocType)
let platformType = Workspace.PlatformType.GetFromName(platformName);
switch (platformType)
{
case .JEMalloc:
newString.Append(" jemalloc.lib");
case .TCMalloc:
newString.Append(" tcmalloc.lib");
case .Windows:
String rtName = scope String();
String dbgName = scope String();
BuildContext.GetRtLibNames(workspaceOptions, options, false, rtName, dbgName);
newString.Append(rtName);
if (!dbgName.IsEmpty)
newString.Append(" ", dbgName);
switch (workspaceOptions.mAllocType)
{
case .JEMalloc:
newString.Append(" jemalloc.lib");
case .TCMalloc:
newString.Append(" tcmalloc.lib");
default:
}
case .macOS:
newString.Append("./libBeefRT_d.dylib -Wl,-rpath -Wl,.");
case .iOS:
case .Linux:
newString.Append("./libBeefRT_d.so -Wl,-rpath -Wl,$ORIGIN");
default:
}
#else
newString.Append("./libBeefRT_d.so -Wl,-rpath -Wl,.");
#endif
}
}
case "VSToolPath":
if (Workspace.PlatformType.GetPtrSizeByName(platformName) == 4)
@ -9255,6 +9271,9 @@ namespace IDE
{
canCompile = false;
}
//TODO:
canCompile = true;
if (!canCompile)
{

View file

@ -99,7 +99,7 @@ namespace IDE
{
String fileName = scope String();
GetUserDirectFileName(fileName);
File.WriteAllLines(fileName, mCustomDictionaryWordList.GetEnumerator());
File.WriteAllLines(fileName, mCustomDictionaryWordList.GetEnumerator()).IgnoreError();
}

View file

@ -20,31 +20,13 @@ namespace IDE
ObjectAndIRCode
}
public enum MachineType
{
case x86;
case x64;
public int32 PtrSize
{
get
{
switch (this)
{
case .x86:
return 4;
case .x64:
return 8;
}
}
}
}
public enum PlatformType
{
case Unknown;
case Windows;
case Linux;
case macOS;
case iOS;
public static PlatformType GetFromName(String name)
{
@ -52,6 +34,8 @@ namespace IDE
{
case "Win32", "Win64": return .Windows;
case "Linux32", "Linux64": return .Linux;
case "macOS": return .macOS;
case "iOS": return .iOS;
default: return .Unknown;
}
}
@ -66,6 +50,10 @@ namespace IDE
return .Linux;
#endif
#if BF_PLATFORM_MACOS
return .Linux;
#endif
#unwarn
return .Unknown;
}
@ -585,6 +573,9 @@ namespace IDE
{
var options = platformKeyValue.value;
var platformName = platformKeyValue.key;
let platformType = PlatformType.GetFromName(platformName);
using (data.CreateObject(platformName))
{
using (data.CreateArray("PreprocessorMacros"))
@ -597,11 +588,10 @@ namespace IDE
data.ConditionalAdd("Toolset", options.mToolsetType, ToolsetType.Default);
data.ConditionalAdd("BuildKind", options.mBuildKind, isTest ? .Test : .Normal);
data.ConditionalAdd("BfSIMDSetting", options.mBfSIMDSetting, .SSE2);
#if BF_PLATFORM_WINDOWS
data.ConditionalAdd("BfOptimizationLevel", options.mBfOptimizationLevel, isRelease ? .O2 : (platformName == "Win64") ? .OgPlus : .O0);
#else
data.ConditionalAdd("BfOptimizationLevel", options.mBfOptimizationLevel, isRelease ? .O2 : .O0);
#endif
if (platformType == .Windows)
data.ConditionalAdd("BfOptimizationLevel", options.mBfOptimizationLevel, isRelease ? .O2 : (platformName == "Win64") ? .OgPlus : .O0);
else
data.ConditionalAdd("BfOptimizationLevel", options.mBfOptimizationLevel, isRelease ? .O2 : .O0);
data.ConditionalAdd("LTOType", options.mLTOType, .None);
data.ConditionalAdd("AllocType", options.mAllocType, isRelease ? .CRT : .Debug);
data.ConditionalAdd("AllocMalloc", options.mAllocMalloc, "");
@ -705,15 +695,19 @@ namespace IDE
#unwarn
bool isParanoid = configName.Contains("Paranoid");
bool isTest = configName.Contains("Test");
let platformType = PlatformType.GetFromName(platformName);
options.mBfSIMDSetting = .SSE2;
#if BF_PLATFORM_WINDOWS
options.mBfOptimizationLevel = isRelease ? .O2 : (platformName == "Win64") ? .OgPlus : .O0;
options.mToolsetType = .Microsoft;
#else
options.mBfOptimizationLevel = isRelease ? .O2 : .O0;
options.mToolsetType = .GNU;
#endif
if (platformType == .Windows)
{
options.mBfOptimizationLevel = isRelease ? .O2 : (platformName == "Win64") ? .OgPlus : .O0;
options.mToolsetType = .Microsoft;
}
else
{
options.mBfOptimizationLevel = isRelease ? .O2 : .O0;
options.mToolsetType = .GNU;
}
options.mAllocType = isRelease ? .CRT : .Debug;
options.mEmitDebugInfo = .Yes;
@ -726,13 +720,16 @@ namespace IDE
options.mEnableObjectDebugFlags = !isRelease;
options.mEmitObjectAccessCheck = !isRelease;
#if BF_PLATFORM_WINDOWS
options.mEnableRealtimeLeakCheck = !isRelease;
options.mEnableSideStack = isParanoid;
#else
options.mEnableRealtimeLeakCheck = false;
options.mEnableSideStack = false;
#endif
if (platformType == .Windows)
{
options.mEnableRealtimeLeakCheck = !isRelease;
options.mEnableSideStack = isParanoid;
}
else
{
options.mEnableRealtimeLeakCheck = false;
options.mEnableSideStack = false;
}
options.mAllowHotSwapping = !isRelease;
options.mIncrementalBuild = !isRelease;
@ -784,6 +781,7 @@ namespace IDE
{
Options options = new Options();
let platformName = new String(platformNameKey);
let platformType = PlatformType.GetFromName(platformName);
config.mPlatforms[platformName] = options;
SetupDefault(options, configName, platformName);
@ -798,11 +796,11 @@ namespace IDE
options.mToolsetType = data.GetEnum<ToolsetType>("Toolset", ToolsetType.Default);
options.mBuildKind = data.GetEnum<BuildKind>("BuildKind", isTest ? .Test : .Normal);
options.mBfSIMDSetting = data.GetEnum<BuildOptions.SIMDSetting>("BfSIMDSetting", .SSE2);
#if BF_PLATFORM_WINDOWS
options.mBfOptimizationLevel = data.GetEnum<BuildOptions.BfOptimizationLevel>("BfOptimizationLevel", isRelease ? .O2 : (platformName == "Win64") ? .OgPlus : .O0);
#else
options.mBfOptimizationLevel = data.GetEnum<BuildOptions.BfOptimizationLevel>("BfOptimizationLevel", isRelease ? .O2 : .O0);
#endif
if (platformType == .Windows)
options.mBfOptimizationLevel = data.GetEnum<BuildOptions.BfOptimizationLevel>("BfOptimizationLevel", isRelease ? .O2 : (platformName == "Win64") ? .OgPlus : .O0);
else
options.mBfOptimizationLevel = data.GetEnum<BuildOptions.BfOptimizationLevel>("BfOptimizationLevel", isRelease ? .O2 : .O0);
options.mLTOType = data.GetEnum<BuildOptions.LTOType>("LTOType", .None);
options.mAllocType = data.GetEnum<AllocType>("AllocType", isRelease ? .CRT : .Debug);
data.GetString("AllocMalloc", options.mAllocMalloc);

View file

@ -494,7 +494,6 @@ namespace IDE.ui
var (category, propEntry) = AddPropertiesItem(root, "General");
category.mIsBold = true;
category.mTextColor = cHeaderColor;
AddPropertiesItem(category, "Machine Type", "mMachineType");
AddPropertiesItem(category, "Toolset", "mToolsetType");
AddPropertiesItem(category, "Build Type", "mBuildKind");