mirror of
https://github.com/antopilo/Nuake.git
synced 2026-01-04 22:10:34 +03:00
Basic .Net Core POC successful
This commit is contained in:
@@ -24,6 +24,11 @@ namespace Nuake
|
||||
return instance;
|
||||
}
|
||||
|
||||
void Log(Coral::NativeString string)
|
||||
{
|
||||
Logger::Log(string.ToString(), ".net", VERBOSE);
|
||||
}
|
||||
|
||||
void ScriptingEngineNet::Initialize()
|
||||
{
|
||||
auto coralDir = "";
|
||||
@@ -36,5 +41,13 @@ namespace Nuake
|
||||
hostInstance.Initialize(settings);
|
||||
|
||||
auto loadContext = hostInstance.CreateAssemblyLoadContext("NuakeEngineContext");
|
||||
auto& assembly = loadContext.LoadAssembly("NuakeNet.dll");
|
||||
|
||||
assembly.AddInternalCall("Nuake.Net.Engine", "LoggerLogIcall", reinterpret_cast<void*>(&Log));
|
||||
assembly.UploadInternalCalls();
|
||||
|
||||
auto& engineType = assembly.GetType("Nuake.Net.Engine");
|
||||
auto engineInstance = engineType.CreateInstance();
|
||||
engineInstance.InvokeMethod("Log");
|
||||
}
|
||||
}
|
||||
22
NuakeNet/premake5.lua
Normal file
22
NuakeNet/premake5.lua
Normal file
@@ -0,0 +1,22 @@
|
||||
project "NuakeNet"
|
||||
language "C#"
|
||||
dotnetframework "net7.0"
|
||||
kind "SharedLib"
|
||||
clr "Unsafe"
|
||||
|
||||
-- Don't specify architecture here. (see https://github.com/premake/premake-core/issues/1758)
|
||||
|
||||
propertytags {
|
||||
{ "AppendTargetFrameworkToOutputPath", "false" },
|
||||
{ "Nullable", "enable" },
|
||||
}
|
||||
|
||||
files
|
||||
{
|
||||
"src/**.cs"
|
||||
}
|
||||
|
||||
links
|
||||
{
|
||||
"Coral.Managed"
|
||||
}
|
||||
28
NuakeNet/src/main.cs
Normal file
28
NuakeNet/src/main.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using Coral.Managed.Interop;
|
||||
|
||||
using System;
|
||||
|
||||
namespace Nuake.Net
|
||||
{
|
||||
/// <summary>
|
||||
/// This is the core Nuake.Net API.
|
||||
/// All internal call should happen in this file.
|
||||
/// </summary>
|
||||
|
||||
public class Engine
|
||||
{
|
||||
internal static unsafe delegate*<NativeString, void> LoggerLogIcall;
|
||||
|
||||
public Engine() { }
|
||||
|
||||
/// <summary>
|
||||
/// Prints a message to the console log
|
||||
/// </summary>
|
||||
/// <param name="message">message to be printed</param>
|
||||
public void Log()
|
||||
{
|
||||
NativeString str = "Hello from C#";
|
||||
unsafe { LoggerLogIcall(str); }
|
||||
}
|
||||
}
|
||||
}
|
||||
12
premake5.lua
12
premake5.lua
@@ -36,6 +36,8 @@ include "Nuake/dependencies/soloud_p5.lua"
|
||||
include "Nuake/dependencies/optick_p5.lua"
|
||||
include "Nuake/dependencies/coral_p5.lua"
|
||||
|
||||
include "NuakeNet/premake5.lua"
|
||||
|
||||
project "Nuake"
|
||||
location "Nuake"
|
||||
kind "StaticLib"
|
||||
@@ -340,7 +342,8 @@ project "Editor"
|
||||
'{ECHO} Copying "%{wks.location}/NetCore/7.0.7/nethost.dll" to "%{cfg.targetdir}"',
|
||||
'{COPYFILE} "%{wks.location}/Nuake/dependencies/Coral/NetCore/7.0.7/nethost.dll" "%{cfg.targetdir}"',
|
||||
'{COPYFILE} "%{wks.location}/Nuake/dependencies/Coral/Coral.Managed/Coral.Managed.runtimeconfig.json" "%{wks.location}/%{prj.name}"',
|
||||
'{COPYFILE} "%{wks.location}/Nuake/dependencies/Coral/Coral.Managed/Build/%{cfg.buildcfg}-%{cfg.system}/Coral.Managed.dll" "%{wks.location}/%{prj.name}"'
|
||||
'{COPYFILE} "%{wks.location}/Nuake/dependencies/Coral/Coral.Managed/Build/%{cfg.buildcfg}-%{cfg.system}/Coral.Managed.dll" "%{wks.location}/%{prj.name}"',
|
||||
'{COPYFILE} "%{wks.location}/NuakeNet/bin/%{cfg.buildcfg}/NuakeNet.dll" "%{wks.location}/%{prj.name}"'
|
||||
}
|
||||
|
||||
|
||||
@@ -366,10 +369,8 @@ project "Editor"
|
||||
{
|
||||
"/usr/include/gtk-3.0/",
|
||||
"/usr/lib/glib-2.0/include",
|
||||
"/usr/include/glib-2.0",
|
||||
"/usr/include/glib-2.0",
|
||||
}
|
||||
|
||||
|
||||
|
||||
defines
|
||||
{
|
||||
@@ -405,4 +406,5 @@ project "Editor"
|
||||
-- copy a file from the objects directory to the target directory
|
||||
postbuildcommands {
|
||||
--"{COPY} "Nuake/dependencies/GLFW/lib-vc2019/glfw3.dll" " .. "./bin/" .. outputdir .. "/%{prj.name}/glfw3.dll"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user