mirror of
https://github.com/beefytech/Beef.git
synced 2025-07-04 15:26:00 +02:00
Added Android support, and generalized target triple support
Added PICLevel, RelocKind DarwinCommon/LinuxCommon/AndroidCommon merged into PosixCommon Mangling changed to avoid '@'
This commit is contained in:
parent
7a27ab75bf
commit
3883a3674d
39 changed files with 3457 additions and 5636 deletions
|
@ -157,9 +157,91 @@ namespace IDE
|
|||
return didCommands ? .HadCommands : .NoCommands;
|
||||
}
|
||||
|
||||
bool QueueProjectGNUArchive(Project project, String targetPath, Workspace.Options workspaceOptions, Project.Options options, String objectsArg)
|
||||
{
|
||||
#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();
|
||||
|
||||
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)
|
||||
return true;
|
||||
|
||||
String arCmds = scope String(""); //-O2 -Rpass=inline
|
||||
//(doClangCPP ? "-lc++abi " : "") +
|
||||
|
||||
arCmds.AppendF("CREATE {}\n", targetPath);
|
||||
|
||||
for (let obj in objectsArg.Split(' '))
|
||||
{
|
||||
if (!obj.IsEmpty)
|
||||
{
|
||||
arCmds.AppendF("ADDMOD {}\n", obj);
|
||||
}
|
||||
}
|
||||
arCmds.AppendF("SAVE\n");
|
||||
|
||||
if (project.mNeedsTargetRebuild)
|
||||
{
|
||||
if (File.Delete(targetPath) case .Err)
|
||||
{
|
||||
gApp.OutputLine("Failed to delete {0}", targetPath);
|
||||
return false;
|
||||
}
|
||||
|
||||
String arPath = scope .();
|
||||
#if BF_PLATFORM_WINDOWS
|
||||
arPath.Clear();
|
||||
arPath.Append(gApp.mInstallDir);
|
||||
arPath.Append(@"llvm\bin\llvm-ar.exe");
|
||||
#else
|
||||
arPath.Append("/usr/bin/ar");
|
||||
#endif
|
||||
|
||||
String workingDir = scope String();
|
||||
workingDir.Append(gApp.mInstallDir);
|
||||
|
||||
String scriptPath = scope .();
|
||||
if (Path.GetTempFileName(scriptPath) case .Err)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (File.WriteAllText(scriptPath, arCmds) case .Err)
|
||||
{
|
||||
gApp.OutputLine("Failed to write archive script {0}", scriptPath);
|
||||
return false;
|
||||
}
|
||||
|
||||
String cmdLine = scope .();
|
||||
cmdLine.AppendF("-M");
|
||||
|
||||
var runCmd = gApp.QueueRun(arPath, cmdLine, workingDir, .UTF8);
|
||||
runCmd.mOnlyIfNotFailed = true;
|
||||
runCmd.mStdInData = new .(arCmds);
|
||||
var tagetCompletedCmd = new IDEApp.TargetCompletedCmd(project);
|
||||
tagetCompletedCmd.mOnlyIfNotFailed = true;
|
||||
gApp.mExecutionQueue.Add(tagetCompletedCmd);
|
||||
|
||||
project.mLastDidBuild = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
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);
|
||||
|
@ -1070,7 +1152,12 @@ namespace IDE
|
|||
|
||||
if (workspaceOptions.mToolsetType == .GNU)
|
||||
{
|
||||
if (!QueueProjectGNULink(project, targetPath, workspaceOptions, options, objectsArg))
|
||||
if ((options.mBuildOptions.mBuildKind == .StaticLib) || (options.mBuildOptions.mBuildKind == .DynamicLib))
|
||||
{
|
||||
if (!QueueProjectGNUArchive(project, targetPath, workspaceOptions, options, objectsArg))
|
||||
return false;
|
||||
}
|
||||
else if (!QueueProjectGNULink(project, targetPath, workspaceOptions, options, objectsArg))
|
||||
return false;
|
||||
}
|
||||
else // MS
|
||||
|
|
|
@ -45,6 +45,25 @@ namespace IDE
|
|||
return (this != .Og) && (this != .OgPlus) && (this != .O0);
|
||||
}
|
||||
}
|
||||
|
||||
public enum RelocType
|
||||
{
|
||||
NotSet,
|
||||
Static,
|
||||
PIC,
|
||||
DynamicNoPIC,
|
||||
ROPI,
|
||||
RWPI,
|
||||
ROPI_RWPI
|
||||
}
|
||||
|
||||
public enum PICLevel
|
||||
{
|
||||
NotSet,
|
||||
Not,
|
||||
Small,
|
||||
Big
|
||||
}
|
||||
}
|
||||
|
||||
public class DistinctBuildOptions
|
||||
|
|
|
@ -7,6 +7,7 @@ using System.Diagnostics;
|
|||
using Beefy.widgets;
|
||||
using Beefy;
|
||||
using Beefy.utils;
|
||||
using IDE.Util;
|
||||
|
||||
namespace IDE.Compiler
|
||||
{
|
||||
|
@ -465,7 +466,10 @@ namespace IDE.Compiler
|
|||
|
||||
var options = IDEApp.sApp.GetCurWorkspaceOptions();
|
||||
String targetTriple = scope .();
|
||||
Workspace.PlatformType.GetTargetTripleByName(gApp.mPlatformName, options.mToolsetType, targetTriple);
|
||||
if (TargetTriple.IsTargetTriple(gApp.mPlatformName))
|
||||
targetTriple.Set(gApp.mPlatformName);
|
||||
else
|
||||
Workspace.PlatformType.GetTargetTripleByName(gApp.mPlatformName, options.mToolsetType, targetTriple);
|
||||
|
||||
bool enableObjectDebugFlags = options.mEnableObjectDebugFlags;
|
||||
bool emitObjectAccessCheck = options.mEmitObjectAccessCheck && enableObjectDebugFlags;
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace IDE.Compiler
|
|||
|
||||
[StdCall, CLink]
|
||||
extern static void BfProject_SetOptions(void* nativeBfProject, int32 targetType, char8* startupObject, char8* preprocessorMacros,
|
||||
int32 optLevel, int32 ltoType, Flags flags);
|
||||
int32 optLevel, int32 ltoType, int32 relocType, int32 picLevel, Flags flags);
|
||||
|
||||
public void* mNativeBfProject;
|
||||
public bool mDisabled;
|
||||
|
@ -61,7 +61,8 @@ namespace IDE.Compiler
|
|||
}
|
||||
|
||||
public void SetOptions(Project.TargetType targetType, String startupObject, List<String> preprocessorMacros,
|
||||
BuildOptions.BfOptimizationLevel optLevel, BuildOptions.LTOType ltoType, bool mergeFunctions, bool combineLoads, bool vectorizeLoops, bool vectorizeSLP)
|
||||
BuildOptions.BfOptimizationLevel optLevel, BuildOptions.LTOType ltoType, BuildOptions.RelocType relocType, BuildOptions.PICLevel picLevel,
|
||||
bool mergeFunctions, bool combineLoads, bool vectorizeLoops, bool vectorizeSLP)
|
||||
{
|
||||
Flags flags = default;
|
||||
void SetFlags(bool val, Flags flag)
|
||||
|
@ -77,7 +78,7 @@ namespace IDE.Compiler
|
|||
String macrosStr = scope String();
|
||||
macrosStr.Join("\n", preprocessorMacros.GetEnumerator());
|
||||
BfProject_SetOptions(mNativeBfProject, (int32)targetType, startupObject, macrosStr,
|
||||
(int32)optLevel, (int32)ltoType, flags);
|
||||
(int32)optLevel, (int32)ltoType, (int32)relocType, (int32)picLevel, flags);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -420,6 +420,7 @@ namespace IDE
|
|||
public ArgsFileKind mUseArgsFile;
|
||||
public int32 mParallelGroup = -1;
|
||||
public bool mIsTargetRun;
|
||||
public String mStdInData ~ delete _;
|
||||
}
|
||||
public List<ExecutionCmd> mExecutionQueue = new List<ExecutionCmd>() ~ DeleteContainerAndItems!(_);
|
||||
|
||||
|
@ -435,9 +436,11 @@ namespace IDE
|
|||
public Task<String> mErrorTask /*~ delete _*/;
|
||||
public Action<Task<String>> mOnErrorTaskComplete /*~ delete _*/;
|
||||
public Monitor mMonitor = new Monitor() ~ delete _;
|
||||
public String mStdInData ~ delete _;
|
||||
|
||||
public Thread mOutputThread;
|
||||
public Thread mErrorThread;
|
||||
public Thread mInputThread;
|
||||
|
||||
public int? mExitCode;
|
||||
public bool mAutoDelete = true;
|
||||
|
@ -450,12 +453,17 @@ namespace IDE
|
|||
/*if (mProcess != null)
|
||||
mProcess.Close();*/
|
||||
|
||||
if (mInputThread != null)
|
||||
mInputThread.Join();
|
||||
delete mInputThread;
|
||||
|
||||
if (mOutputThread != null)
|
||||
mOutputThread.Join();
|
||||
delete mOutputThread;
|
||||
|
||||
if (mErrorThread != null)
|
||||
mErrorThread.Join();
|
||||
delete mErrorThread;
|
||||
delete mErrorThread;
|
||||
|
||||
delete mReadTask;
|
||||
delete mOnReadTaskComplete;
|
||||
|
@ -7092,6 +7100,26 @@ namespace IDE
|
|||
}
|
||||
}
|
||||
|
||||
static void WriteInputThread(Object obj)
|
||||
{
|
||||
ExecutionInstance executionInstance = (ExecutionInstance)obj;
|
||||
|
||||
FileStream fileStream = scope FileStream();
|
||||
if (executionInstance.mProcess.AttachStandardInput(fileStream) case .Err)
|
||||
return;
|
||||
|
||||
while (!executionInstance.mStdInData.IsEmpty)
|
||||
{
|
||||
switch (fileStream.TryWrite(.((.)executionInstance.mStdInData.Ptr, executionInstance.mStdInData.Length)))
|
||||
{
|
||||
case .Ok(int len):
|
||||
executionInstance.mStdInData.Remove(0, len);
|
||||
case .Err:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void ReadOutputThread(Object obj)
|
||||
{
|
||||
ExecutionInstance executionInstance = (ExecutionInstance)obj;
|
||||
|
@ -7131,7 +7159,7 @@ namespace IDE
|
|||
}
|
||||
}
|
||||
|
||||
public ExecutionInstance DoRun(String inFileName, String args, String workingDir, ArgsFileKind useArgsFile, Dictionary<String, String> envVars = null)
|
||||
public ExecutionInstance DoRun(String inFileName, String args, String workingDir, ArgsFileKind useArgsFile, Dictionary<String, String> envVars = null, String stdInData = null)
|
||||
{
|
||||
//Debug.Assert(executionInstance == null);
|
||||
|
||||
|
@ -7146,6 +7174,8 @@ namespace IDE
|
|||
startInfo.SetArguments(args);
|
||||
startInfo.RedirectStandardOutput = true;
|
||||
startInfo.RedirectStandardError = true;
|
||||
if (stdInData != null)
|
||||
startInfo.RedirectStandardInput = true;
|
||||
startInfo.CreateNoWindow = true;
|
||||
if (envVars != null)
|
||||
{
|
||||
|
@ -7224,6 +7254,13 @@ namespace IDE
|
|||
executionInstance.mErrorThread = new Thread(new => ReadErrorThread);
|
||||
executionInstance.mErrorThread.Start(executionInstance, false);
|
||||
|
||||
if (stdInData != null)
|
||||
{
|
||||
executionInstance.mStdInData = new String(stdInData);
|
||||
executionInstance.mInputThread = new Thread(new => WriteInputThread);
|
||||
executionInstance.mInputThread.Start(executionInstance, false);
|
||||
}
|
||||
|
||||
return executionInstance;
|
||||
}
|
||||
|
||||
|
@ -7502,7 +7539,7 @@ namespace IDE
|
|||
else if (next is ExecutionQueueCmd)
|
||||
{
|
||||
var executionQueueCmd = (ExecutionQueueCmd)next;
|
||||
var executionInstance = DoRun(executionQueueCmd.mFileName, executionQueueCmd.mArgs, executionQueueCmd.mWorkingDir, executionQueueCmd.mUseArgsFile, executionQueueCmd.mEnvVars);
|
||||
var executionInstance = DoRun(executionQueueCmd.mFileName, executionQueueCmd.mArgs, executionQueueCmd.mWorkingDir, executionQueueCmd.mUseArgsFile, executionQueueCmd.mEnvVars, executionQueueCmd.mStdInData);
|
||||
executionInstance.mParallelGroup = executionQueueCmd.mParallelGroup;
|
||||
executionInstance.mIsTargetRun = executionQueueCmd.mIsTargetRun;
|
||||
}
|
||||
|
@ -7903,12 +7940,23 @@ namespace IDE
|
|||
success = false;
|
||||
}
|
||||
}
|
||||
else if (options.mBuildOptions.mBuildKind == .StaticLib)
|
||||
{
|
||||
if (project.mGeneralOptions.mTargetType.IsBeefApplication)
|
||||
targetType = .BeefApplication_StaticLib;
|
||||
}
|
||||
else if (options.mBuildOptions.mBuildKind == .DynamicLib)
|
||||
{
|
||||
if (project.mGeneralOptions.mTargetType.IsBeefApplication)
|
||||
targetType = .BeefApplication_DynamicLib;
|
||||
}
|
||||
}
|
||||
|
||||
bfProject.SetOptions(targetType,
|
||||
project.mBeefGlobalOptions.mStartupObject,
|
||||
preprocessorMacros.mDefines,
|
||||
optimizationLevel, ltoType, options.mBeefOptions.mMergeFunctions, options.mBeefOptions.mCombineLoads,
|
||||
optimizationLevel, ltoType, options.mBeefOptions.mRelocType, options.mBeefOptions.mPICLevel,
|
||||
options.mBeefOptions.mMergeFunctions, options.mBeefOptions.mCombineLoads,
|
||||
options.mBeefOptions.mVectorizeLoops, options.mBeefOptions.mVectorizeSLP);
|
||||
|
||||
List<Project> depProjectList = scope List<Project>();
|
||||
|
@ -8378,21 +8426,43 @@ namespace IDE
|
|||
return false;
|
||||
|
||||
let platformType = Workspace.PlatformType.GetFromName(platformName);
|
||||
switch (platformType)
|
||||
|
||||
if (options.mBuildOptions.mBuildKind.IsApplicationLib)
|
||||
{
|
||||
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");
|
||||
switch (platformType)
|
||||
{
|
||||
case .Windows:
|
||||
newString.Append(".lib");
|
||||
case .iOS:
|
||||
if (options.mBuildOptions.mBuildKind == .DynamicLib)
|
||||
newString.Append(".dylib");
|
||||
else
|
||||
newString.Append(".a");
|
||||
default:
|
||||
if (options.mBuildOptions.mBuildKind == .DynamicLib)
|
||||
newString.Append(".so");
|
||||
else
|
||||
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 == Project.TargetType.BeefLib)
|
||||
newString.Append(".dylib");
|
||||
default:
|
||||
if (project.mGeneralOptions.mTargetType == Project.TargetType.BeefLib)
|
||||
newString.Append(".so");
|
||||
}
|
||||
}
|
||||
}
|
||||
case "ProjectDir":
|
||||
|
@ -8633,7 +8703,10 @@ namespace IDE
|
|||
else
|
||||
{
|
||||
clangOptions.Append("--target=");
|
||||
Workspace.PlatformType.GetTargetTripleByName(gApp.mPlatformName, workspaceOptions.mToolsetType, clangOptions);
|
||||
if (TargetTriple.IsTargetTriple(gApp.mPlatformName))
|
||||
clangOptions.Append(gApp.mPlatformName);
|
||||
else
|
||||
Workspace.PlatformType.GetTargetTripleByName(gApp.mPlatformName, workspaceOptions.mToolsetType, clangOptions);
|
||||
clangOptions.Append(" ");
|
||||
|
||||
if (workspaceOptions.mToolsetType == .GNU)
|
||||
|
|
|
@ -792,6 +792,16 @@ namespace IDE
|
|||
{
|
||||
case Normal;
|
||||
case Test;
|
||||
case StaticLib;
|
||||
case DynamicLib;
|
||||
|
||||
public bool IsApplicationLib
|
||||
{
|
||||
get
|
||||
{
|
||||
return (this == .StaticLib) || (this == .DynamicLib);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum COptimizationLevel
|
||||
|
@ -838,20 +848,39 @@ namespace IDE
|
|||
CustomBuild,
|
||||
C_ConsoleApplication,
|
||||
C_WindowsApplication,
|
||||
BeefTest;
|
||||
BeefTest,
|
||||
BeefApplication_StaticLib,
|
||||
BeefApplication_DynamicLib;
|
||||
|
||||
public bool IsBeef
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (this)
|
||||
{
|
||||
case BeefConsoleApplication,
|
||||
BeefWindowsApplication,
|
||||
BeefLib,
|
||||
BeefDynLib,
|
||||
BeefTest: return true;
|
||||
default: return false;
|
||||
get
|
||||
{
|
||||
switch (this)
|
||||
{
|
||||
case BeefConsoleApplication,
|
||||
BeefWindowsApplication,
|
||||
BeefLib,
|
||||
BeefDynLib,
|
||||
BeefTest:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsBeefApplication
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (this)
|
||||
{
|
||||
case BeefConsoleApplication,
|
||||
BeefWindowsApplication:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1005,6 +1034,10 @@ namespace IDE
|
|||
[Reflect]
|
||||
public List<String> mPreprocessorMacros = new List<String>() ~ DeleteContainerAndItems!(_);
|
||||
[Reflect]
|
||||
public BuildOptions.RelocType mRelocType;
|
||||
[Reflect]
|
||||
public BuildOptions.PICLevel mPICLevel;
|
||||
[Reflect]
|
||||
public BuildOptions.BfOptimizationLevel? mOptimizationLevel;
|
||||
[Reflect]
|
||||
public BuildOptions.LTOType? mLTOType;
|
||||
|
@ -1103,6 +1136,8 @@ namespace IDE
|
|||
Set!(newOptions.mBeefOptions.mPreprocessorMacros, mBeefOptions.mPreprocessorMacros);
|
||||
Set!(newOptions.mBeefOptions.mOptimizationLevel, mBeefOptions.mOptimizationLevel);
|
||||
Set!(newOptions.mBeefOptions.mLTOType, mBeefOptions.mLTOType);
|
||||
Set!(newOptions.mBeefOptions.mRelocType, mBeefOptions.mRelocType);
|
||||
Set!(newOptions.mBeefOptions.mPICLevel, mBeefOptions.mPICLevel);
|
||||
Set!(newOptions.mBeefOptions.mMergeFunctions, mBeefOptions.mMergeFunctions);
|
||||
Set!(newOptions.mBeefOptions.mCombineLoads, mBeefOptions.mCombineLoads);
|
||||
Set!(newOptions.mBeefOptions.mVectorizeLoops, mBeefOptions.mVectorizeLoops);
|
||||
|
@ -1522,6 +1557,8 @@ namespace IDE
|
|||
data.Add(macro);
|
||||
}
|
||||
}
|
||||
data.ConditionalAdd("RelocType", options.mBeefOptions.mRelocType, .NotSet);
|
||||
data.ConditionalAdd("PICLevel", options.mBeefOptions.mPICLevel, .NotSet);
|
||||
data.ConditionalAdd("OptimizationLevel", options.mBeefOptions.mOptimizationLevel);
|
||||
data.ConditionalAdd("LTOType", options.mBeefOptions.mLTOType);
|
||||
data.ConditionalAdd("MergeFunctions", options.mBeefOptions.mMergeFunctions);
|
||||
|
@ -1826,6 +1863,8 @@ namespace IDE
|
|||
options.mBeefOptions.mPreprocessorMacros.Add(new String("TEST"));
|
||||
}
|
||||
|
||||
options.mBeefOptions.mRelocType = data.GetEnum<BuildOptions.RelocType>("RelocType");
|
||||
options.mBeefOptions.mPICLevel = data.GetEnum<BuildOptions.PICLevel>("PICLevel");
|
||||
if (data.Contains("OptimizationLevel"))
|
||||
options.mBeefOptions.mOptimizationLevel = data.GetEnum<BuildOptions.BfOptimizationLevel>("OptimizationLevel");
|
||||
if (data.Contains("LTOType"))
|
||||
|
@ -2135,6 +2174,7 @@ namespace IDE
|
|||
bool isParanoid = configName.Contains("Paranoid");
|
||||
bool isDebug = isParanoid || configName.Contains("Debug");
|
||||
bool isTest = configName.Contains("Test");
|
||||
let platformType = Workspace.PlatformType.GetFromName(platformName);
|
||||
|
||||
if (isRelease)
|
||||
options.mBeefOptions.mPreprocessorMacros.Add(new String("RELEASE"));
|
||||
|
@ -2149,7 +2189,20 @@ namespace IDE
|
|||
options.mBuildOptions.mBeefLibType = isRelease ? .Static : .Dynamic;
|
||||
options.mBuildOptions.mStackSize = 0;
|
||||
|
||||
options.mBuildOptions.mBuildKind = isTest ? .Test : .Normal;
|
||||
switch (platformType)
|
||||
{
|
||||
case .Linux,
|
||||
.Windows,
|
||||
.macOS:
|
||||
options.mBuildOptions.mBuildKind = isTest ? .Test : .Normal;
|
||||
default:
|
||||
options.mBuildOptions.mBuildKind = .StaticLib;
|
||||
}
|
||||
|
||||
if (platformType == .Android)
|
||||
{
|
||||
options.mBeefOptions.mRelocType = .PIC;
|
||||
}
|
||||
|
||||
options.mBuildOptions.mOtherLinkFlags.Set("$(LinkFlags)");
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ namespace IDE
|
|||
case Linux;
|
||||
case macOS;
|
||||
case iOS;
|
||||
case Android;
|
||||
|
||||
public static PlatformType GetFromName(String name)
|
||||
{
|
||||
|
@ -36,7 +37,8 @@ namespace IDE
|
|||
case "Linux32", "Linux64": return .Linux;
|
||||
case "macOS": return .macOS;
|
||||
case "iOS": return .iOS;
|
||||
default: return .Unknown;
|
||||
default:
|
||||
return TargetTriple.GetPlatformType(name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,7 +62,11 @@ namespace IDE
|
|||
|
||||
public static int GetPtrSizeByName(String name)
|
||||
{
|
||||
if (name.EndsWith("32"))
|
||||
if ((name.EndsWith("32")) && (!TargetTriple.IsTargetTriple(name)))
|
||||
return 4;
|
||||
if (name.StartsWith("armv"))
|
||||
return 4;
|
||||
if (name.StartsWith("i686-"))
|
||||
return 4;
|
||||
return 8;
|
||||
}
|
||||
|
@ -80,7 +86,7 @@ namespace IDE
|
|||
case "macOS":
|
||||
outTriple.Append("x86_64-apple-macosx10.14.0");
|
||||
case "iOS":
|
||||
outTriple.Append("aarch64-apple-ios");
|
||||
outTriple.Append("arm64-apple-ios");
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
@ -167,6 +173,8 @@ namespace IDE
|
|||
{
|
||||
[Reflect]
|
||||
public List<String> mPreprocessorMacros = new List<String>() ~ DeleteContainerAndItems!(_);
|
||||
/*[Reflect]
|
||||
public String mTargetTriple = new .() ~ delete _;*/
|
||||
[Reflect]
|
||||
public List<DistinctBuildOptions> mDistinctBuildOptions = new List<DistinctBuildOptions>() ~ DeleteContainerAndItems!(_);
|
||||
}
|
||||
|
@ -505,6 +513,7 @@ namespace IDE
|
|||
if (mStartupProject != null)
|
||||
data.Add("StartupProject", mStartupProject.mProjectName);
|
||||
WriteStrings("PreprocessorMacros", mBeefGlobalOptions.mPreprocessorMacros);
|
||||
//data.ConditionalAdd("TargetTriple", mBeefGlobalOptions.mTargetTriple, "");
|
||||
WriteDistinctOptions(mBeefGlobalOptions.mDistinctBuildOptions);
|
||||
data.RemoveIfEmpty();
|
||||
}
|
||||
|
@ -697,15 +706,20 @@ namespace IDE
|
|||
bool isTest = configName.Contains("Test");
|
||||
let platformType = PlatformType.GetFromName(platformName);
|
||||
|
||||
/*if (TargetTriple.IsTargetTriple(platformName))
|
||||
{
|
||||
options.mToolsetType = .None;
|
||||
}*/
|
||||
|
||||
options.mBfOptimizationLevel = isRelease ? .O2 : .O0;
|
||||
options.mBfSIMDSetting = .SSE2;
|
||||
if (platformType == .Windows)
|
||||
{
|
||||
options.mBfOptimizationLevel = isRelease ? .O2 : (platformName == "Win64") ? .OgPlus : .O0;
|
||||
options.mToolsetType = .Microsoft;
|
||||
}
|
||||
else
|
||||
else if ((platformType == .macOS) == (platformType == .Linux))
|
||||
{
|
||||
options.mBfOptimizationLevel = isRelease ? .O2 : .O0;
|
||||
options.mToolsetType = .GNU;
|
||||
}
|
||||
|
||||
|
@ -757,6 +771,7 @@ namespace IDE
|
|||
data.GetCurString(str);
|
||||
mBeefGlobalOptions.mPreprocessorMacros.Add(str);
|
||||
}
|
||||
//data.GetString("TargetTriple", mBeefGlobalOptions.mTargetTriple);
|
||||
|
||||
for (data.Enumerate("DistinctOptions"))
|
||||
{
|
||||
|
|
|
@ -823,7 +823,9 @@ namespace IDE.ui
|
|||
|
||||
(category, propEntry) = AddPropertiesItem(root, "Code Generation");
|
||||
category.mIsBold = true;
|
||||
category.mTextColor = cHeaderColor;
|
||||
category.mTextColor = cHeaderColor;
|
||||
AddPropertiesItem(category, "Reloc Model", "mBeefOptions.mRelocType");
|
||||
AddPropertiesItem(category, "PIC Level", "mBeefOptions.mPICLevel");
|
||||
AddPropertiesItem(category, "Optimization Level", "mBeefOptions.mOptimizationLevel",
|
||||
scope String[] { "O0", "O1", "O2", "O3", "Og", "Og+" }); // -O0 .. -O3, -Os, -Ofast, -Og
|
||||
AddPropertiesItem(category, "LTO", "mBeefOptions.mLTOType");
|
||||
|
|
|
@ -724,17 +724,20 @@ namespace IDE.ui
|
|||
void PopulateBeefGlobalOptions()
|
||||
{
|
||||
var root = (DarkListViewItem)mPropPage.mPropertiesListView.GetRoot();
|
||||
var (category, ?) = AddPropertiesItem(root, "General");
|
||||
/*var (category, ?) = AddPropertiesItem(root, "General");
|
||||
category.mIsBold = true;
|
||||
category.mTextColor = 0xFFE8E8E8;
|
||||
category.mTextColor = 0xFFE8E8E8;*/
|
||||
|
||||
AddPropertiesItem(category, "Preprocessor Macros", "mPreprocessorMacros");
|
||||
AddPropertiesItem(root, "Preprocessor Macros", "mPreprocessorMacros");
|
||||
DistinctOptionBuilder dictinctOptionBuilder = scope .(this);
|
||||
dictinctOptionBuilder.Add(gApp.mWorkspace.mBeefGlobalOptions.mDistinctBuildOptions);
|
||||
dictinctOptionBuilder.Finish();
|
||||
|
||||
//AddPropertiesItem(root, "Target Triple", "mTargetTriple");
|
||||
|
||||
AddNewDistinctBuildOptions();
|
||||
//parent.MakeParent();
|
||||
category.Open(true, true);
|
||||
//category.Open(true, true);
|
||||
}
|
||||
|
||||
void PopulateBeefTargetedOptions()
|
||||
|
|
55
IDE/src/util/TargetTriple.bf
Normal file
55
IDE/src/util/TargetTriple.bf
Normal file
|
@ -0,0 +1,55 @@
|
|||
using System;
|
||||
|
||||
namespace IDE.Util
|
||||
{
|
||||
class TargetTriple
|
||||
{
|
||||
public static bool IsTargetTriple(StringView str)
|
||||
{
|
||||
int dashCount = 0;
|
||||
for (let c in str.RawChars)
|
||||
if (c == '-')
|
||||
dashCount++;
|
||||
return dashCount >= 2;
|
||||
}
|
||||
|
||||
public static Workspace.PlatformType GetPlatformType(StringView str)
|
||||
{
|
||||
var str;
|
||||
|
||||
// Remove version from the end
|
||||
while (!str.IsEmpty)
|
||||
{
|
||||
char8 c = str[str.Length - 1];
|
||||
if ((c.IsDigit) || (c == '.'))
|
||||
str.RemoveFromEnd(1);
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
bool hasLinux = false;
|
||||
|
||||
for (let elem in str.Split('-'))
|
||||
{
|
||||
switch (elem)
|
||||
{
|
||||
case "linux":
|
||||
hasLinux = true;
|
||||
case "windows":
|
||||
return .Windows;
|
||||
case "macosx":
|
||||
return .macOS;
|
||||
case "ios":
|
||||
return .iOS;
|
||||
case "android",
|
||||
"androideabi":
|
||||
return .Android;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasLinux)
|
||||
return .Linux;
|
||||
return .Unknown;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue