Fix build on Linux
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include "Engine/Scripting/MException.h"
|
||||
#include "Engine/Content/Assets/SkinnedModel.h"
|
||||
|
||||
#if !COMPILE_WITHOUT_CSHARP
|
||||
#if USE_MONO
|
||||
#include <ThirdParty/mono-2.0/mono/metadata/appdomain.h>
|
||||
#endif
|
||||
@@ -86,6 +87,8 @@ namespace AnimGraphInternal
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void AnimGraphExecutor::initRuntime()
|
||||
{
|
||||
#if USE_MONO
|
||||
|
||||
@@ -1387,7 +1387,7 @@ void NetworkInternal::OnNetworkMessageObjectSpawn(NetworkEvent& event, NetworkCl
|
||||
// Reuse parent object as prefab instance
|
||||
prefabInstance = parentActor;
|
||||
}
|
||||
else if (parentActor = Scripting::TryFindObject<Actor>(rootItem.ParentId))
|
||||
else if ((parentActor = Scripting::TryFindObject<Actor>(rootItem.ParentId)))
|
||||
{
|
||||
// Try to find that spawned prefab (eg. prefab with networked script was spawned before so now we need to link it)
|
||||
for (Actor* child : parentActor->Children)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
|
||||
|
||||
#include "CoreCLR.h"
|
||||
#if USE_NETCORE
|
||||
#include "Engine/Core/Log.h"
|
||||
#include "Engine/Platform/Platform.h"
|
||||
#include "Engine/Platform/FileSystem.h"
|
||||
@@ -130,3 +131,5 @@ void CoreCLR::Free(void* ptr)
|
||||
{
|
||||
Platform::Free(ptr);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include "Engine/Core/Collections/Array.h"
|
||||
#include "Engine/Scripting/Types.h"
|
||||
|
||||
#if USE_NETCORE
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define CORECLR_DELEGATE_CALLTYPE __stdcall
|
||||
#define FLAX_CORECLR_STRING String
|
||||
@@ -59,5 +61,7 @@ public:
|
||||
static bool HasCustomAttribute(void* klass, void* attribClass);
|
||||
static bool HasCustomAttribute(void* klass);
|
||||
static void* GetCustomAttribute(void* klass, void* attribClass);
|
||||
static Array<void*> GetCustomAttributes(void* klass);
|
||||
static Array<MObject*> GetCustomAttributes(void* klass);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
|
||||
|
||||
#include "CoreCLR.h"
|
||||
#if USE_NETCORE
|
||||
#include "Engine/Scripting/Types.h"
|
||||
#include "Engine/Core/Collections/Dictionary.h"
|
||||
#include "Engine/Graphics/RenderView.h"
|
||||
@@ -614,24 +615,25 @@ bool CoreCLR::HasCustomAttribute(void* klass, void* attribClass)
|
||||
{
|
||||
return CoreCLR::GetCustomAttribute(klass, attribClass) != nullptr;
|
||||
}
|
||||
|
||||
bool CoreCLR::HasCustomAttribute(void* klass)
|
||||
{
|
||||
return CoreCLR::GetCustomAttribute(klass, nullptr) != nullptr;
|
||||
}
|
||||
|
||||
void* CoreCLR::GetCustomAttribute(void* klass, void* attribClass)
|
||||
{
|
||||
static void* GetCustomAttributePtr = CoreCLR::GetStaticMethodPointer(TEXT("GetCustomAttribute"));
|
||||
return CoreCLR::CallStaticMethod<void*, void*, void*>(GetCustomAttributePtr, ((CoreCLRClass*)klass)->GetTypeHandle(), ((CoreCLRClass*)attribClass)->GetTypeHandle());
|
||||
}
|
||||
Array<void*> CoreCLR::GetCustomAttributes(void* klass)
|
||||
|
||||
Array<MObject*> CoreCLR::GetCustomAttributes(void* klass)
|
||||
{
|
||||
Array<CoreCLRCustomAttribute*> attribs = ((CoreCLRClass*)klass)->GetCustomAttributes();
|
||||
|
||||
Array<void*> attributes;
|
||||
const Array<CoreCLRCustomAttribute*>& attribs = ((CoreCLRClass*)klass)->GetCustomAttributes();
|
||||
Array<MObject*> attributes;
|
||||
attributes.Resize(attribs.Count(), false);
|
||||
for (int i = 0; i < attribs.Count(); i++)
|
||||
attributes.Add(attribs[i]->GetHandle());
|
||||
|
||||
for (int32 i = 0; i < attribs.Count(); i++)
|
||||
attributes.Add((MObject*)attribs[i]->GetHandle());
|
||||
return attributes;
|
||||
}
|
||||
|
||||
@@ -1616,3 +1618,5 @@ MONO_API void mono_gc_finalize_notify(void)
|
||||
}
|
||||
|
||||
#pragma warning(default : 4297)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include "Engine/Scripting/MException.h"
|
||||
#include "Engine/Scripting/ManagedCLR/MUtils.h"
|
||||
|
||||
#if !COMPILE_WITHOUT_CSHARP
|
||||
|
||||
namespace UtilsInternal
|
||||
{
|
||||
MonoObject* ExtractArrayFromList(MonoObject* obj)
|
||||
@@ -84,6 +86,8 @@ namespace FlaxLogWriterInternal
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void registerFlaxEngineInternalCalls()
|
||||
{
|
||||
AnimGraphExecutor::initRuntime();
|
||||
|
||||
@@ -336,7 +336,6 @@ const Array<MProperty*>& MClass::GetProperties()
|
||||
{
|
||||
if (_hasCachedProperties)
|
||||
return _properties;
|
||||
|
||||
#if USE_MONO
|
||||
void* iter = nullptr;
|
||||
MonoProperty* curClassProperty;
|
||||
@@ -346,7 +345,6 @@ const Array<MProperty*>& MClass::GetProperties()
|
||||
GetProperty(propertyName);
|
||||
}
|
||||
#endif
|
||||
|
||||
_hasCachedProperties = true;
|
||||
return _properties;
|
||||
}
|
||||
@@ -416,10 +414,9 @@ const Array<MObject*>& MClass::GetAttributes()
|
||||
{
|
||||
if (_hasCachedAttributes)
|
||||
return _attributes;
|
||||
|
||||
_hasCachedAttributes = true;
|
||||
#if USE_NETCORE
|
||||
_attributes = *(Array<MObject*>*)(&CoreCLR::GetCustomAttributes(_monoClass));
|
||||
_attributes = MoveTemp(CoreCLR::GetCustomAttributes(_monoClass));
|
||||
#elif USE_MONO
|
||||
MonoCustomAttrInfo* attrInfo = GET_CUSTOM_ATTR();
|
||||
if (attrInfo == nullptr)
|
||||
|
||||
@@ -16,10 +16,11 @@
|
||||
|
||||
#if USE_NETCORE
|
||||
#include "Engine/Scripting/DotNet/CoreCLR.h"
|
||||
#include "Engine/Core/Collections/BitArray.h"
|
||||
#endif
|
||||
|
||||
struct Version;
|
||||
template<typename AllocationType>
|
||||
class BitArray;
|
||||
|
||||
namespace MUtils
|
||||
{
|
||||
@@ -612,13 +613,25 @@ namespace MUtils
|
||||
/// </summary>
|
||||
/// <param name="data">The input data.</param>
|
||||
/// <returns>The output array.</returns>
|
||||
FORCE_INLINE bool* ToBoolArray(const BitArray<>& data)
|
||||
template<typename AllocationType = HeapAllocation>
|
||||
FORCE_INLINE bool* ToBoolArray(const BitArray<AllocationType>& data)
|
||||
{
|
||||
bool* arr = (bool*)CoreCLR::Allocate(data.Count() * sizeof(bool));
|
||||
for (int i = 0; i < data.Count(); i++)
|
||||
arr[i] = data[i];
|
||||
return arr;
|
||||
}
|
||||
#else
|
||||
FORCE_INLINE bool* ToBoolArray(const Array<bool>& data)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template<typename AllocationType = HeapAllocation>
|
||||
FORCE_INLINE bool* ToBoolArray(const BitArray<AllocationType>& data)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
FORCE_INLINE MGCHandle NewGCHandle(MonoObject* obj, bool pinned)
|
||||
@@ -635,7 +648,7 @@ namespace MUtils
|
||||
#if USE_NETCORE
|
||||
return CoreCLR::NewGCHandleWeakref(obj, track_resurrection);
|
||||
#else
|
||||
return mono_gchandle_new_weak_ref(obj, track_resurrection);
|
||||
return mono_gchandle_new_weakref(obj, track_resurrection);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ public class Scripting : EngineModule
|
||||
|
||||
if (EngineConfiguration.WithCSharp(options))
|
||||
{
|
||||
if (EngineConfiguration.UseDotNet)
|
||||
if (EngineConfiguration.WithDotNet(options))
|
||||
options.PublicDependencies.Add("nethost");
|
||||
else
|
||||
options.PublicDependencies.Add("mono");
|
||||
|
||||
@@ -27,11 +27,16 @@ class MType;
|
||||
#define USE_MONO 0
|
||||
#define USE_NETCORE 0
|
||||
typedef void MObject;
|
||||
typedef unsigned int MGCHandle;
|
||||
|
||||
#else
|
||||
|
||||
#define USE_MONO 1
|
||||
#if COMPILE_WITH_MONO
|
||||
#define USE_NETCORE 0
|
||||
#else
|
||||
#define USE_NETCORE 1
|
||||
#endif
|
||||
|
||||
// Enables using single (root) app domain for the user scripts
|
||||
#define USE_SCRIPTING_SINGLE_DOMAIN 1
|
||||
@@ -42,7 +47,7 @@ typedef void MObject;
|
||||
#define USE_MONO_PROFILER (COMPILE_WITH_PROFILER)
|
||||
|
||||
// Enable/disable mono debugging
|
||||
#define MONO_DEBUG_ENABLE (!BUILD_RELEASE && !USE_MONO)
|
||||
#define MONO_DEBUG_ENABLE (!BUILD_RELEASE && !USE_NETCORE)
|
||||
|
||||
#ifndef USE_MONO_AOT
|
||||
#define USE_MONO_AOT 0
|
||||
@@ -57,7 +62,7 @@ struct _MonoThread {};
|
||||
#if USE_NETCORE
|
||||
typedef unsigned long long MGCHandle;
|
||||
#else
|
||||
typedef uint32 MGCHandle;
|
||||
typedef unsigned int MGCHandle;
|
||||
#endif
|
||||
|
||||
// Mono types declarations
|
||||
|
||||
15
Source/ThirdParty/nethost/nethost.Build.cs
vendored
15
Source/ThirdParty/nethost/nethost.Build.cs
vendored
@@ -8,7 +8,7 @@ using Microsoft.Win32;
|
||||
using System.Linq;
|
||||
|
||||
/// <summary>
|
||||
/// Module for nethost (.NET runtime host library)
|
||||
/// Module for nethost (.NET runtime host library).
|
||||
/// </summary>
|
||||
public class nethost : ThirdPartyModule
|
||||
{
|
||||
@@ -24,19 +24,6 @@ public class nethost : ThirdPartyModule
|
||||
BinaryModuleName = "FlaxEngine";
|
||||
}
|
||||
|
||||
private static Version ParseVersion(string version)
|
||||
{
|
||||
// Give precedence to final releases over release candidate / beta releases
|
||||
int rev = 9999;
|
||||
if (version.Contains("-")) // e.g. 7.0.0-rc.2.22472.3
|
||||
{
|
||||
version = version.Substring(0, version.IndexOf("-"));
|
||||
rev = 0;
|
||||
}
|
||||
Version ver = new Version(version);
|
||||
return new Version(ver.Major, ver.Minor, ver.Build, rev);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Setup(BuildOptions options)
|
||||
{
|
||||
|
||||
@@ -71,6 +71,10 @@ namespace Flax.Build
|
||||
{
|
||||
options.CompileEnv.PreprocessorDefinitions.Add("COMPILE_WITHOUT_CSHARP");
|
||||
}
|
||||
else if (!EngineConfiguration.WithDotNet(options))
|
||||
{
|
||||
options.CompileEnv.PreprocessorDefinitions.Add("COMPILE_WITH_MONO");
|
||||
}
|
||||
if (EngineConfiguration.WithLargeWorlds(options))
|
||||
{
|
||||
options.CompileEnv.PreprocessorDefinitions.Add("USE_LARGE_WORLDS");
|
||||
|
||||
@@ -95,6 +95,7 @@ namespace Flax.Build.Platforms
|
||||
args.Add("-pthread");
|
||||
args.Add("-ldl");
|
||||
args.Add("-lrt");
|
||||
args.Add("-lz");
|
||||
|
||||
// Link X11
|
||||
args.Add("-L/usr/X11R6/lib");
|
||||
|
||||
Reference in New Issue
Block a user