Browse Source

Adding OSX/Unix NETHost platform, updating TypeScript compiler to 1.6.2, OS X builds AtomicNET assemblies from generated script bindings

Josh Engebretson 10 years ago
parent
commit
82fec68d24

+ 7 - 4
Script/AtomicNET/AtomicNET/AtomicNETBootstrap/Bootstrap.cs

@@ -36,6 +36,7 @@ public class AtomicLoadContext : LoadContext
     protected override IntPtr LoadUnmanagedDll(String unmanagedDllName)
     protected override IntPtr LoadUnmanagedDll(String unmanagedDllName)
     {
     {
 
 
+      /*
       if (unmanagedDllName == "__Internal")
       if (unmanagedDllName == "__Internal")
       {
       {
         IntPtr result = GetModuleHandle(null);
         IntPtr result = GetModuleHandle(null);
@@ -45,17 +46,19 @@ public class AtomicLoadContext : LoadContext
       // do we need to walk paths here?
       // do we need to walk paths here?
       Console.WriteLine("LoadUnmanagedDll: " + unmanagedDllName);
       Console.WriteLine("LoadUnmanagedDll: " + unmanagedDllName);
       return GetModuleHandle(unmanagedDllName); //RTLD_LAZY
       return GetModuleHandle(unmanagedDllName); //RTLD_LAZY
+      */
+
 
 
-      /*
       if (unmanagedDllName == "__Internal")
       if (unmanagedDllName == "__Internal")
       {
       {
-        return dlopen(null, 1); //RTLD_LAZY
+        IntPtr result = dlopen(null, 1); //RTLD_LAZY
+        return result;
       }
       }
 
 
       // do we need to walk paths here?
       // do we need to walk paths here?
       Console.WriteLine("LoadUnmanagedDll: " + unmanagedDllName);
       Console.WriteLine("LoadUnmanagedDll: " + unmanagedDllName);
       return dlopen(unmanagedDllName, 1 ); //RTLD_LAZY
       return dlopen(unmanagedDllName, 1 ); //RTLD_LAZY
-      */
+
     }
     }
 
 
     public override Assembly LoadAssembly(AssemblyName assemblyName)
     public override Assembly LoadAssembly(AssemblyName assemblyName)
@@ -71,7 +74,7 @@ public class AtomicLoadContext : LoadContext
             assembly = LoadFromAssemblyPath(path + assemblyName.Name + ".dll");
             assembly = LoadFromAssemblyPath(path + assemblyName.Name + ".dll");
             break;
             break;
         }
         }
-        catch (Exception e)
+        catch //(Exception e)
         {
         {
           //Console.WriteLine(e.Message);
           //Console.WriteLine(e.Message);
         }
         }

+ 2 - 2
Script/AtomicNET/AtomicNET/AtomicNETBootstrap/LoadContext.cs

@@ -13,7 +13,7 @@ namespace Atomic.Bootstrap
     public abstract class LoadContext : AssemblyLoadContext, IAssemblyLoadContext
     public abstract class LoadContext : AssemblyLoadContext, IAssemblyLoadContext
     {
     {
         private readonly AssemblyLoaderCache _cache = new AssemblyLoaderCache();
         private readonly AssemblyLoaderCache _cache = new AssemblyLoaderCache();
-        private readonly string _friendlyName;
+        //private readonly string _friendlyName;
 
 
         public LoadContext()
         public LoadContext()
         {
         {
@@ -21,7 +21,7 @@ namespace Atomic.Bootstrap
 
 
         public LoadContext(string friendlyName)
         public LoadContext(string friendlyName)
         {
         {
-            _friendlyName = friendlyName;
+            //_friendlyName = friendlyName;
         }
         }
 
 
         protected override Assembly Load(AssemblyName assemblyName)
         protected override Assembly Load(AssemblyName assemblyName)

+ 4 - 4
Script/AtomicNET/AtomicNET/build.cmd

@@ -1,6 +1,6 @@
 
 
 csc /out:../../../Artifacts/AtomicNET/TPA/AtomicNETBootstrap.dll /nostdlib+ /noconfig /t:library ^
 csc /out:../../../Artifacts/AtomicNET/TPA/AtomicNETBootstrap.dll /nostdlib+ /noconfig /t:library ^
-/lib:../../../Submodules/CoreCLR/Windows/Release/x64/;../../../Submodules/CoreCLR/Windows/Release/x64/ ^
+/lib:../../../Submodules/CoreCLR/Windows/Release/x64/ ^
 /r:../../../Submodules/CoreCLR/Windows/Release/x64/System.Collections.Concurrent.dll ^
 /r:../../../Submodules/CoreCLR/Windows/Release/x64/System.Collections.Concurrent.dll ^
 /r:../../../Submodules/CoreCLR/Windows/Release/x64/System.Runtime.dll ^
 /r:../../../Submodules/CoreCLR/Windows/Release/x64/System.Runtime.dll ^
 /r:../../../Submodules/CoreCLR/Windows/Release/x64/System.Linq.dll ^
 /r:../../../Submodules/CoreCLR/Windows/Release/x64/System.Linq.dll ^
@@ -9,7 +9,7 @@ csc /out:../../../Artifacts/AtomicNET/TPA/AtomicNETBootstrap.dll /nostdlib+ /noc
 AtomicNETBootstrap/*.cs
 AtomicNETBootstrap/*.cs
 
 
 csc /out:../../../Artifacts/AtomicNET/AtomicNETEngine.dll /nostdlib+ /noconfig /t:library /w:0 ^
 csc /out:../../../Artifacts/AtomicNET/AtomicNETEngine.dll /nostdlib+ /noconfig /t:library /w:0 ^
-/lib:../../../Submodules/CoreCLR/Windows/Release/x64/;../../../Submodules/CoreCLR/Windows/Release/x64/ ^
+/lib:../../../Submodules/CoreCLR/Windows/Release/x64/ ^
 /r:../../../Submodules/CoreCLR/Windows/Release/x64/System.Runtime.dll ^
 /r:../../../Submodules/CoreCLR/Windows/Release/x64/System.Runtime.dll ^
 /r:../../../Submodules/CoreCLR/Windows/Release/x64/System.IO.dll ^
 /r:../../../Submodules/CoreCLR/Windows/Release/x64/System.IO.dll ^
 /r:../../../Submodules/CoreCLR/Windows/Release/x64/System.IO.FileSystem.dll ^
 /r:../../../Submodules/CoreCLR/Windows/Release/x64/System.IO.FileSystem.dll ^
@@ -21,7 +21,7 @@ csc /out:../../../Artifacts/AtomicNET/AtomicNETEngine.dll /nostdlib+ /noconfig /
 AtomicNETEngine/*.cs
 AtomicNETEngine/*.cs
 
 
 csc /unsafe /out:../../../Artifacts/AtomicNET/AtomicNETTools.dll /nostdlib+ /noconfig /t:library /w:0 ^
 csc /unsafe /out:../../../Artifacts/AtomicNET/AtomicNETTools.dll /nostdlib+ /noconfig /t:library /w:0 ^
-/lib:../../../Submodules/CoreCLR/Windows/Release/x64/;../../../Submodules/CoreCLR/Windows/Release/x64/ ^
+/lib:../../../Submodules/CoreCLR/Windows/Release/x64/ ^
 /r:../../../Submodules/CoreCLR/Windows/Release/x64/System.Runtime.dll ^
 /r:../../../Submodules/CoreCLR/Windows/Release/x64/System.Runtime.dll ^
 /r:../../../Submodules/CoreCLR/Windows/Release/x64/System.IO.dll ^
 /r:../../../Submodules/CoreCLR/Windows/Release/x64/System.IO.dll ^
 /r:../../../Submodules/CoreCLR/Windows/Release/x64/System.Linq.dll ^
 /r:../../../Submodules/CoreCLR/Windows/Release/x64/System.Linq.dll ^
@@ -35,7 +35,7 @@ AtomicNETTools/*.cs
 
 
 csc /out:../../../Artifacts/AtomicNET/AtomicNETTestCompile.dll ^
 csc /out:../../../Artifacts/AtomicNET/AtomicNETTestCompile.dll ^
 /debug+ /nostdlib+ /noconfig /t:library /w:0 ^
 /debug+ /nostdlib+ /noconfig /t:library /w:0 ^
-/lib:../../../Submodules/CoreCLR/Windows/Release/x64/;../../../Submodules/CoreCLR/Windows/Release/x64/ ^
+/lib:../../../Submodules/CoreCLR/Windows/Release/x64/ ^
 /r:../../../Submodules/CoreCLR/Windows/Release/x64/System.Runtime.dll ^
 /r:../../../Submodules/CoreCLR/Windows/Release/x64/System.Runtime.dll ^
 /r:../../../Submodules/CoreCLR/Windows/Release/x64/System.IO.dll ^
 /r:../../../Submodules/CoreCLR/Windows/Release/x64/System.IO.dll ^
 /r:../../../Submodules/CoreCLR/Windows/Release/x64/System.IO.FileSystem.dll ^
 /r:../../../Submodules/CoreCLR/Windows/Release/x64/System.IO.FileSystem.dll ^

+ 19 - 16
Script/AtomicNET/AtomicNET/build.sh

@@ -1,26 +1,29 @@
 
 
-mcs /out:/Users/josh/Desktop/OSX.x64.Debug/AtomicNETBootstrap.dll /nostdlib /noconfig /t:library /lib:/Users/josh/Desktop/OSX.x64.Debug \
+/usr/local/bin/mcs /out:../../../Artifacts/AtomicNET/TPA/AtomicNETBootstrap.dll /nostdlib /noconfig /t:library \
+/lib:../../../Submodules/CoreCLR/MacOSX/Debug/x64/ \
 /r:System.Console.dll /r:System.Runtime.dll /r:System.IO.dll /r:System.IO.FileSystem.dll /r:mscorlib.dll \
 /r:System.Console.dll /r:System.Runtime.dll /r:System.IO.dll /r:System.IO.FileSystem.dll /r:mscorlib.dll \
-/r:System.Collections.Concurrent.dll \
-/Users/josh/Dev/atomic/AtomicGameEngine/Build/AtomicNET/AtomicNETBootstrap/*.cs
+/r:System.Collections.dll /r:System.Collections.Concurrent.dll /r:System.Linq.dll \
+AtomicNETBootstrap/*.cs
 
 
-mcs /out:/Users/josh/Desktop/AtomicNETEngine.dll /nostdlib /noconfig /t:library /w:0 /lib:/Users/josh/Desktop/OSX.x64.Debug \
+/usr/local/bin/mcs /out:../../../Artifacts/AtomicNET/AtomicNETEngine.dll /nostdlib /noconfig /t:library /w:0 \
+/lib:../../../Submodules/CoreCLR/MacOSX/Debug/x64/ \
 /r:System.Console.dll /r:System.Runtime.dll /r:System.IO.dll /r:System.IO.FileSystem.dll /r:mscorlib.dll \
 /r:System.Console.dll /r:System.Runtime.dll /r:System.IO.dll /r:System.IO.FileSystem.dll /r:mscorlib.dll \
 /r:System.Linq.dll \
 /r:System.Linq.dll \
-/Users/josh/Dev/atomic/AtomicGameEngine/Build/Source/Generated/MACOSX/CSharp/Packages/Atomic/Managed/*.cs \
-/Users/josh/Dev/atomic/AtomicGameEngine/Build/Source/Generated/MACOSX/CSharp/Packages/AtomicNET/Managed/*.cs \
-/Users/josh/Dev/atomic/AtomicGameEngine/Build/Source/Generated/MACOSX/CSharp/Packages/AtomicPlayer/Managed/*.cs \
-/Users/josh/Dev/atomic/AtomicGameEngine/Build/AtomicNET/AtomicNETEngine/*.cs
+../../../Build/Source/Generated/MACOSX/CSharp/Packages/Atomic/Managed/*.cs \
+../../../Build/Source/Generated/MACOSX/CSharp/Packages/AtomicNET/Managed/*.cs \
+../../../Build/Source/Generated/MACOSX/CSharp/Packages/AtomicPlayer/Managed/*.cs \
+AtomicNETEngine/*.cs
 
 
-mcs /unsafe /out:/Users/josh/Desktop/AtomicNETTools.dll /nostdlib /noconfig /t:library /w:0 /lib:/Users/josh/Desktop/OSX.x64.Debug \
+/usr/local/bin/mcs /unsafe /out:../../../Artifacts/AtomicNET/AtomicNETTools.dll /nostdlib /noconfig /t:library /w:0 \
+/lib:../../../Submodules/CoreCLR/MacOSX/Debug/x64/ \
 /r:System.Console.dll /r:System.Runtime.dll /r:System.IO.dll /r:System.IO.FileSystem.dll /r:mscorlib.dll \
 /r:System.Console.dll /r:System.Runtime.dll /r:System.IO.dll /r:System.IO.FileSystem.dll /r:mscorlib.dll \
 /r:System.Linq.dll /r:System.Reflection.Primitives.dll /r:System.Reflection.Metadata.dll \
 /r:System.Linq.dll /r:System.Reflection.Primitives.dll /r:System.Reflection.Metadata.dll \
-/r:System.Collections.dll /r:System.Collections.Immutable.dll /r:/Users/josh/Desktop/AtomicNETEngine.dll \
-/Users/josh/Dev/atomic/AtomicGameEngine/Build/AtomicNET/AtomicNETTools/*.cs
+/r:System.Collections.dll /r:System.Collections.Immutable.dll \
+/r:../../../Artifacts/AtomicNET/AtomicNETEngine.dll \
+AtomicNETTools/*.cs
 
 
-mcs /out:/Users/josh/Dev/atomic/AtomicExamples/NET/Basic3D/Resources/Assemblies/AtomicNETTest.dll /nostdlib /noconfig /t:library /w:0 /lib:/Users/josh/Desktop/OSX.x64.Debug \
+/usr/local/bin/mcs /out:../../../Artifacts/AtomicNET/AtomicNETTestCompile.dll /nostdlib /noconfig /t:library /w:0 \
+/lib:../../../Submodules/CoreCLR/MacOSX/Debug/x64/ \
 /r:System.Console.dll /r:System.Runtime.dll /r:System.IO.dll /r:System.IO.FileSystem.dll /r:mscorlib.dll \
 /r:System.Console.dll /r:System.Runtime.dll /r:System.IO.dll /r:System.IO.FileSystem.dll /r:mscorlib.dll \
-/r:/Users/josh/Desktop/AtomicNETEngine.dll \
-/Users/josh/Dev/atomic/AtomicGameEngine/Build/AtomicNETTest/MyClass.cs
-
-cp /Users/josh/Dev/atomic/AtomicExamples/NET/Basic3D/Resources/Assemblies/AtomicNETTest.dll /Users/josh/Desktop/AtomicNETTest.dll
+/r:../../../Artifacts/AtomicNET/AtomicNETEngine.dll \
+../AtomicNETTest/MyClass.cs

+ 33 - 335
Source/AtomicNET/NETCore/NETCore.cpp

@@ -1,6 +1,4 @@
 
 
-#include <ThirdParty/SDL/include/SDL.h>
-
 #include <Atomic/Core/CoreEvents.h>
 #include <Atomic/Core/CoreEvents.h>
 #include <Atomic/IO/FileSystem.h>
 #include <Atomic/IO/FileSystem.h>
 #include <Atomic/IO/Log.h>
 #include <Atomic/IO/Log.h>
@@ -15,63 +13,12 @@
 #ifdef ATOMIC_PLATFORM_WINDOWS
 #ifdef ATOMIC_PLATFORM_WINDOWS
 #include "Platforms/Windows/NETHostWindows.h"
 #include "Platforms/Windows/NETHostWindows.h"
 #else
 #else
+#include "Platforms/Unix/NETHostUnix.h"
 #endif
 #endif
 
 
 namespace Atomic
 namespace Atomic
 {
 {
 
 
-/*
-mcs /nostdlib /noconfig /r:System.Console.dll /r:System.Runtime.dll /r:System.IO.dll /r:System.IO.FileSystem.dll /r:mscorlib.dll HelloWorld.cs
-
-export PAL_DBG_CHANNELS="+all.all"
-*/
-
-
-#ifdef ATOMIC_PLATFORM_OSX
-static const char * const sCoreClrDll = "libcoreclr.dylib";
-#elif ATOMIC_PLATFORM_WINDOWS
-static const char * const sCoreClrDll = "coreclr.dll";
-#else
-static const char * const sCoreClrDll = "libcoreclr.so";
-#endif
-
-// Prototype of the coreclr_initialize function from the libcoreclr.so
-typedef int (*InitializeCoreCLRFunction)(
-            const char* exePath,
-            const char* appDomainFriendlyName,
-            int propertyCount,
-            const char** propertyKeys,
-            const char** propertyValues,
-            void** hostHandle,
-            unsigned int* domainId);
-
-// Prototype of the coreclr_shutdown function from the libcoreclr.so
-typedef int (*ShutdownCoreCLRFunction)(
-            void* hostHandle,
-            unsigned int domainId);
-
-// Prototype of the coreclr_execute_assembly function from the libcoreclr.so
-typedef int (*ExecuteAssemblyFunction)(
-            void* hostHandle,
-            unsigned int domainId,
-            int argc,
-            const char** argv,
-            const char* managedAssemblyPath,
-            unsigned int* exitCode);
-
-typedef int (*CreateDelegateFunction)(
-            void* hostHandle,
-            unsigned int domainId,
-            const char* entryPointAssemblyName,
-            const char* entryPointTypeName,
-            const char* entryPointMethodName,
-            void** delegate);
-
-static InitializeCoreCLRFunction sInitializeCoreCLR = 0;
-static ExecuteAssemblyFunction sExecuteAssembly = 0;
-static CreateDelegateFunction sCreateDelegate = 0;
-static ShutdownCoreCLRFunction sShutdownCoreCLR = 0;
-
 /// Register NETCore library objects.
 /// Register NETCore library objects.
 void ATOMIC_API RegisterNETCoreLibrary(Context* context);
 void ATOMIC_API RegisterNETCoreLibrary(Context* context);
 
 
@@ -79,10 +26,7 @@ WeakPtr<Context> NETCore::csContext_;
 WeakPtr<NETCore> NETCore::instance_;
 WeakPtr<NETCore> NETCore::instance_;
 
 
 NETCore::NETCore(Context* context) :
 NETCore::NETCore(Context* context) :
-    Object(context),
-    coreCLRDLLHandle_(0),
-    hostHandle_(0),
-    domainId_(0)
+    Object(context)
 {
 {
     RegisterNETCoreLibrary(context_);
     RegisterNETCoreLibrary(context_);
 
 
@@ -93,6 +37,7 @@ NETCore::NETCore(Context* context) :
 
 
 NETCore::~NETCore()
 NETCore::~NETCore()
 {
 {
+    Shutdown();
     context_->RemoveGlobalEventListener(context_->GetSubsystem<CSEventDispatcher>());
     context_->RemoveGlobalEventListener(context_->GetSubsystem<CSEventDispatcher>());
     context_->RemoveSubsystem(CSEventDispatcher::GetTypeStatic());
     context_->RemoveSubsystem(CSEventDispatcher::GetTypeStatic());
     context_->RemoveSubsystem(NETManaged::GetTypeStatic());
     context_->RemoveSubsystem(NETManaged::GetTypeStatic());
@@ -100,110 +45,18 @@ NETCore::~NETCore()
     instance_ = NULL;
     instance_ = NULL;
 }
 }
 
 
-void NETCore::GenerateTPAList(String& tpaList)
-{
-#ifdef disabled
-    tpaList = String::EMPTY;
-
-    FileSystem* fs = GetSubsystem<FileSystem>();
-    Vector<String> results;
-    fs->ScanDir(results, coreCLRFilesAbsPath_, "*.dll", SCAN_FILES, true);
-
-    Vector<String> trustedAssemblies;
-
-    for (unsigned i = 0; i < results.Size(); i++)
-    {
-        const String& assembly = results[i];
-
-        // TODO: apply filtering if necessary
-        trustedAssemblies.Push(coreCLRFilesAbsPath_ + assembly);
-    }
-
-    // trustedAssemblies.Push(coreCLRFilesAbsPath_ + "HelloWorld.exe");
-
-    tpaList.Join(trustedAssemblies, ":");
-
-    // LOGINFOF("NetCore:: TPALIST - %s", tpaList.CString());
-#endif
-
-}
-
 void NETCore::Shutdown()
 void NETCore::Shutdown()
 {
 {
-    RefCounted::SetRefCountedDeletedFunction(0);
-
-    if (sShutdownCoreCLR && hostHandle_)
-    {
-        sShutdownCoreCLR(hostHandle_, domainId_);
-    }
-
-    if (coreCLRDLLHandle_)
-    {
-        SDL_UnloadObject(coreCLRDLLHandle_);
-    }
-
-    coreCLRDLLHandle_ = 0;
-    hostHandle_ = 0;
-    domainId_ = 0;
-    sInitializeCoreCLR = 0;
-    sExecuteAssembly = 0;
-    sCreateDelegate = 0;
-    sShutdownCoreCLR = 0;
-
-}
-
-bool NETCore::InitCoreCLRDLL(String& errorMsg)
-{
-#ifdef disabled
-    String coreClrDllPath = AddTrailingSlash(coreCLRFilesAbsPath_) + sCoreClrDll;
-
-    coreCLRDLLHandle_ = SDL_LoadObject(coreClrDllPath.CString());
-
-    if (coreCLRDLLHandle_ == NULL)
-    {
-        errorMsg = ToString("NETCore: Unable to load %s with error %s",
-            coreClrDllPath.CString(),
-            SDL_GetError());
-        return false;
-    }
-
-    sInitializeCoreCLR = (InitializeCoreCLRFunction) SDL_LoadFunction(coreCLRDLLHandle_, "coreclr_initialize");
-
-    if (!sInitializeCoreCLR)
-    {
-        errorMsg = ToString("NETCore: Unable to get coreclr_initialize entry point in %s", coreClrDllPath.CString());
-        return false;
-    }
-
-    sShutdownCoreCLR = (ShutdownCoreCLRFunction) SDL_LoadFunction(coreCLRDLLHandle_, "coreclr_shutdown");
 
 
-    if (!sShutdownCoreCLR)
-    {
-        errorMsg = ToString("NETCore: Unable to get coreclr_shutdown entry point in %s", coreClrDllPath.CString());
-        return false;
-    }
-
-    sCreateDelegate = (CreateDelegateFunction) SDL_LoadFunction(coreCLRDLLHandle_, "coreclr_create_delegate");
-
-    if (!sCreateDelegate)
-    {
-        errorMsg = ToString("NETCore: Unable to get coreclr_create_delegate entry point in %s", coreClrDllPath.CString());
-        return false;
-    }
-
-    sExecuteAssembly = (ExecuteAssemblyFunction) SDL_LoadFunction(coreCLRDLLHandle_, "coreclr_execute_assembly");
+    RefCounted::SetRefCountedDeletedFunction(0);
 
 
-    if (!sExecuteAssembly)
+    if (netHost_.NotNull())
     {
     {
-        errorMsg = ToString("NETCore: Unable to get coreclr_execute_assembly entry point in %s", coreClrDllPath.CString());
-        return false;
+        netHost_->Shutdown();
+        netHost_ = 0;
     }
     }
-#endif
-
-    return true;
 }
 }
 
 
-
 extern "C"
 extern "C"
 {
 {
 
 
@@ -268,232 +121,77 @@ void NETCore::AddAssemblyLoadPath(const String& assemblyPath)
 
 
 bool NETCore::CreateDelegate(const String& assemblyName, const String& qualifiedClassName, const String& methodName, void** funcOut)
 bool NETCore::CreateDelegate(const String& assemblyName, const String& qualifiedClassName, const String& methodName, void** funcOut)
 {
 {
-
     return netHost_->CreateDelegate(assemblyName, qualifiedClassName, methodName, funcOut);
     return netHost_->CreateDelegate(assemblyName, qualifiedClassName, methodName, funcOut);
-
-    /*
-    if (!sCreateDelegate)
-        return false;
-
-    *funcOut = 0;
-
-    // TODO: wrap in SharedPtr to control delegate lifetime?
-    int st = sCreateDelegate(hostHandle_,
-                    domainId_,
-                    assemblyName.CString(),
-                    qualifiedClassName.CString(),
-                    methodName.CString(),
-                    funcOut);
-
-    // ensure ptr isn't uninitialized
-    if (st < 0)
-        *funcOut = 0;
-
-    return st >= 0;
-    */
-
 }
 }
 
 
 bool NETCore::Initialize(String& errorMsg)
 bool NETCore::Initialize(String& errorMsg)
 {
 {
+
 #ifdef ATOMIC_PLATFORM_WINDOWS
 #ifdef ATOMIC_PLATFORM_WINDOWS
     netHost_ = new NETHostWindows(context_);
     netHost_ = new NETHostWindows(context_);
 #else
 #else
+    netHost_ = new NETHostUnix(context_);
 #endif
 #endif
 
 
-    netHost_->Initialize();
-
-    SharedPtr<NETManaged> managed(new NETManaged(context_));
-    context_->RegisterSubsystem(managed);
-
-    SharedPtr<CSEventDispatcher> dispatcher(new CSEventDispatcher(context_));
-    context_->RegisterSubsystem(dispatcher);
-    context_->AddGlobalEventListener(dispatcher);
-
-    if (!context_->GetEditorContext())
+    if (!netHost_->Initialize())
     {
     {
-        SubscribeToEvent(E_UPDATE, HANDLER(NETCore, HandleUpdate));
-    }
-
-    managed->Initialize();
-
-
-#ifdef disabled
-
-    if (!InitCoreCLRDLL(errorMsg))
-    {
-        Shutdown();
+        errorMsg = "NETHost Failed to Initialize";
         return false;
         return false;
     }
     }
 
 
-    // Allowed property names:
-    // APPBASE
-    // - The base path of the application from which the exe and other assemblies will be loaded
-    //
-    // TRUSTED_PLATFORM_ASSEMBLIES
-    // - The list of complete paths to each of the fully trusted assemblies
-    //
-    // APP_PATHS
-    // - The list of paths which will be probed by the assembly loader
-    //
-    // APP_NI_PATHS
-    // - The list of additional paths that the assembly loader will probe for ngen images
-    //
-    // NATIVE_DLL_SEARCH_DIRECTORIES
-    // - The list of paths that will be probed for native DLLs called by PInvoke
-    //
-
-    const char *propertyKeys[] = {
-        "TRUSTED_PLATFORM_ASSEMBLIES",
-        "APP_PATHS",
-        "APP_NI_PATHS",
-        "NATIVE_DLL_SEARCH_DIRECTORIES",
-        "AppDomainCompatSwitch"
-    };
-
-    String tpaList;
-    GenerateTPAList(tpaList);
-
-    String appPath = coreCLRFilesAbsPath_;// "/Users/josh/Desktop/";
-    Vector<String> nativeSearch;
-    nativeSearch.Push(coreCLRFilesAbsPath_);
-    //nativeSearch.Push("/Users/josh/Dev/atomic/AtomicGameEngine-build/Source/AtomicNET/NETNative");
-    //nativeSearch.Push("/Users/josh/Dev/atomic/AtomicGameEngine-build/Source/AtomicEditor/AtomicEditor.app/Contents/MacOS");
-
-    String nativeDllSearchDirs;
-    nativeDllSearchDirs.Join(nativeSearch, ":");
-
-    const char *propertyValues[] = {
-        // TRUSTED_PLATFORM_ASSEMBLIES
-        tpaList.CString(),
-        // APP_PATHS
-        appPath.CString(),
-        // APP_NI_PATHS
-        appPath.CString(),
-        // NATIVE_DLL_SEARCH_DIRECTORIES
-        nativeDllSearchDirs.CString(),
-        // AppDomainCompatSwitch
-        "UseLatestBehaviorWhenTFMNotSpecified"
-    };
-
-    int st = sInitializeCoreCLR(
-                "AtomicEditor.exe",
-                "NETCore",
-                sizeof(propertyKeys) / sizeof(propertyKeys[0]),
-                propertyKeys,
-                propertyValues,
-                &hostHandle_,
-                &domainId_);
-
-    if (st < 0)
-    {
-        Shutdown();
-        errorMsg = ToString("NETCore: coreclr_initialize failed - status: 0x%08x\n", st);
-        return false;
-    }
-
-    typedef void (*StartupFunction)();
+    // MOVE THIS!
+    typedef void (*StartupFunction)(const char* assemblyLoadPaths);
     StartupFunction startup;
     StartupFunction startup;
 
 
     // The coreclr binding model will become locked upon loading the first assembly that is not on the TPA list, or
     // The coreclr binding model will become locked upon loading the first assembly that is not on the TPA list, or
     // upon initializing the default context for the first time. For this test, test assemblies are located alongside
     // upon initializing the default context for the first time. For this test, test assemblies are located alongside
     // corerun, and hence will be on the TPA list. So, we should be able to set the default context once successfully,
     // corerun, and hence will be on the TPA list. So, we should be able to set the default context once successfully,
-    // and fail on the second try.    
+    // and fail on the second try.
 
 
     // AssemblyLoadContext
     // AssemblyLoadContext
     // https://github.com/dotnet/corefx/issues/3054
     // https://github.com/dotnet/corefx/issues/3054
     // dnx loader
     // dnx loader
     // https://github.com/aspnet/dnx/tree/dev/src/Microsoft.Dnx.Loader
     // https://github.com/aspnet/dnx/tree/dev/src/Microsoft.Dnx.Loader
 
 
-    st = sCreateDelegate(hostHandle_,
-                    domainId_,
+    bool result = netHost_->CreateDelegate(
                     "AtomicNETBootstrap",
                     "AtomicNETBootstrap",
                     "Atomic.Bootstrap.AtomicLoadContext",
                     "Atomic.Bootstrap.AtomicLoadContext",
                     "Startup",
                     "Startup",
                     (void**) &startup);
                     (void**) &startup);
 
 
-    if (st >= 0)
+    if (result)
     {
     {
-        startup();
+        startup(netHost_->GetCoreCLRAssemblyLoadPaths().CString());
     }
     }
 
 
-    st = sCreateDelegate(hostHandle_,
-                    domainId_,
+    // MOVE THIS!
+    typedef void (*InitializeFunction)();
+    InitializeFunction init;
+
+    result = netHost_->CreateDelegate(
                     "AtomicNETEngine",
                     "AtomicNETEngine",
                     "AtomicEngine.Atomic",
                     "AtomicEngine.Atomic",
                     "Initialize",
                     "Initialize",
-                    (void**) &startup);
-
-    if (st >= 0)
-    {
-        startup();
-    }
-
-    /*
-
-
-    RefCountedDeletedFunction rcdFunction;
-
-    st = sCreateDelegate(hostHandle_,
-                    domainId_,
-                    "AtomicNETEngine",
-                    "AtomicEngine.NativeCore",
-                    "RefCountedDeleted",
-                    (void**) &rcdFunction);
-
-    if (st >= 0)
-    {
-        RefCounted::SetRefCountedDeletedFunction(rcdFunction);
-    }
-
-    NETUpdateFunctionPtr updateFunction;
-
-    st = sCreateDelegate(hostHandle_,
-                    domainId_,
-                    "AtomicNETEngine",
-                    "AtomicEngine.NativeCore",
-                    "NETUpdate",
-                    (void**) &updateFunction);
+                    (void**) &init);
 
 
-    if (st >= 0)
+    if (result)
     {
     {
-        GetSubsystem<NETManaged>()->SetNETUpdate(updateFunction);
+        init();
     }
     }
 
 
-    typedef void (*InpectAssemblyFuctionPtr)(const char* path);
-
-    InpectAssemblyFuctionPtr inspectAssembly;
+    SharedPtr<NETManaged> managed(new NETManaged(context_));
+    context_->RegisterSubsystem(managed);
 
 
-    st = sCreateDelegate(hostHandle_,
-                    domainId_,
-                    "AtomicEditor",
-                    "AtomicEditor.AtomicEditor",
-                    "InspectAssembly",
-                    (void**) &inspectAssembly);
+    SharedPtr<CSEventDispatcher> dispatcher(new CSEventDispatcher(context_));
+    context_->RegisterSubsystem(dispatcher);
+    context_->AddGlobalEventListener(dispatcher);
 
 
-    if (st >= 0)
+    if (!context_->GetEditorContext())
     {
     {
-        //inspectAssembly("/Users/josh/Desktop/AtomicNETTest.dll");
+        SubscribeToEvent(E_UPDATE, HANDLER(NETCore, HandleUpdate));
     }
     }
-    */
-
-
-    /*
-    unsigned int exitCode;
-
-    st = sExecuteAssembly(
-            hostHandle_,
-            domainId_,
-            0,
-            0,
-            "/Users/josh/Desktop/OSX.x64.Debug/HelloWorld.exe",
-            (unsigned int*)&exitCode);
-    */
-
-
-#endif
 
 
-    return true;
+    return managed->Initialize();
 
 
 }
 }
 
 

+ 0 - 7
Source/AtomicNET/NETCore/NETCore.h

@@ -57,13 +57,6 @@ private:
 
 
     void HandleUpdate(StringHash eventType, VariantMap& eventData);
     void HandleUpdate(StringHash eventType, VariantMap& eventData);
 
 
-    bool InitCoreCLRDLL(String &errorMsg);
-    void GenerateTPAList(String& tpaList);
-
-    void* coreCLRDLLHandle_;
-    void* hostHandle_;
-    unsigned domainId_;
-
     SharedPtr<NETHost> netHost_;
     SharedPtr<NETHost> netHost_;
 
 
     /// weak local context ref, so avoid recursion in static GetContext call
     /// weak local context ref, so avoid recursion in static GetContext call

+ 3 - 0
Source/AtomicNET/NETCore/NETHost.h

@@ -25,9 +25,12 @@ public:
     // ; (semicolon) delimited list of paths to trusted platform assemblies
     // ; (semicolon) delimited list of paths to trusted platform assemblies
     static void SetCoreCLRTPAPaths(const String& path) { coreCLRTPAPaths_ = path; }
     static void SetCoreCLRTPAPaths(const String& path) { coreCLRTPAPaths_ = path; }
 
 
+    static const String& GetCoreCLRAssemblyLoadPaths() { return coreCLRAssemblyLoadPaths_; }
+
     virtual bool Initialize() = 0;
     virtual bool Initialize() = 0;
     virtual bool CreateDelegate(const String& assemblyName, const String& qualifiedClassName, const String& methodName, void** funcOut) = 0;
     virtual bool CreateDelegate(const String& assemblyName, const String& qualifiedClassName, const String& methodName, void** funcOut) = 0;
     virtual void WaitForDebuggerConnect() = 0;
     virtual void WaitForDebuggerConnect() = 0;
+    virtual void Shutdown() = 0;
 
 
 protected:
 protected:
 
 

+ 330 - 0
Source/AtomicNET/NETCore/Platforms/Unix/NETHostUnix.cpp

@@ -0,0 +1,330 @@
+
+#include <ThirdParty/SDL/include/SDL.h>
+
+#include <Atomic/IO/Log.h>
+#include <Atomic/Core/StringUtils.h>
+#include "NETHostUnix.h"
+
+/*
+mcs /nostdlib /noconfig /r:System.Console.dll /r:System.Runtime.dll /r:System.IO.dll /r:System.IO.FileSystem.dll /r:mscorlib.dll HelloWorld.cs
+
+export PAL_DBG_CHANNELS="+all.all"
+export PAL_DBG_CHANNELS="+PAL.TRACE:+LOADER.TRACE:+ARCH.TRACE:+EXCEPT.ENTRY:+DEBUG.TRACE:+LOCALE.TRACE:+MISC.WARN:+HANDLE.TRACE:+UNICODE.TRACE:-FILE.ERROR"
+
+// see bottom of file for channels
+
+*/
+
+
+#ifdef ATOMIC_PLATFORM_OSX
+static const char * const sCoreClrDll = "libcoreclr.dylib";
+#elif ATOMIC_PLATFORM_WINDOWS
+static const char * const sCoreClrDll = "coreclr.dll";
+#else
+static const char * const sCoreClrDll = "libcoreclr.so";
+#endif
+
+namespace Atomic
+{
+
+/// Construct.
+NETHostUnix::NETHostUnix(Context* context) : NETHost(context),
+   InitializeCoreCLR_(0),
+   ExecuteAssembly_(0),
+   CreateDelegate_(0),
+   ShutdownCoreCLR_(0),
+   coreCLRDLLHandle_(0),
+   hostHandle_(0),
+   domainId_(0)
+{
+
+}
+
+/// Destruct.
+NETHostUnix::~NETHostUnix()
+{
+
+}
+
+bool NETHostUnix::Initialize()
+{
+    if (!coreCLRFilesAbsPath_.Length())
+        return false;
+
+    if (!coreCLRTPAPaths_.Length())
+        return false;
+
+    if (!coreCLRAssemblyLoadPaths_.Length())
+        return false;
+
+    String errorMsg;
+    if (!LoadCLRDLL(errorMsg))
+        return false;
+
+    if (!CreateAppDomain(errorMsg))
+        return false;
+
+    return true;
+}
+
+bool NETHostUnix::CreateDelegate(const String& assemblyName, const String& qualifiedClassName, const String& methodName, void** funcOut)
+{
+
+    if (!CreateDelegate_)
+        return false;
+
+    *funcOut = 0;
+
+    // TODO: wrap in SharedPtr to control delegate lifetime?
+    int st = CreateDelegate_(hostHandle_,
+                    domainId_,
+                    assemblyName.CString(),
+                    qualifiedClassName.CString(),
+                    methodName.CString(),
+                    funcOut);
+
+    // ensure ptr isn't uninitialized
+    if (st < 0)
+        *funcOut = 0;
+
+    return st >= 0;
+
+}
+
+void NETHostUnix::WaitForDebuggerConnect()
+{
+
+}
+
+void NETHostUnix::AddFilesFromDirectoryToTPAList(const String& targetPath, Vector<String>& trustedAssemblies)
+{
+    String _targetPath = AddTrailingSlash(targetPath);
+
+    FileSystem* fs = GetSubsystem<FileSystem>();
+    Vector<String> results;
+    fs->ScanDir(results, _targetPath, "*.dll", SCAN_FILES, true);
+
+    for (unsigned i = 0; i < results.Size(); i++)
+    {
+        const String& assembly = results[i];
+
+        // TODO: apply filtering to catch duplicates/handle native images, etc
+        trustedAssemblies.Push(_targetPath + assembly);
+    }
+
+
+}
+
+void NETHostUnix::GenerateTPAList(String& tpaList)
+{
+    tpaList = String::EMPTY;
+
+    Vector<String> trustedAssemblies;
+
+    // Add the CoreCLR assemblies to TPA
+    AddFilesFromDirectoryToTPAList(coreCLRFilesAbsPath_, trustedAssemblies);
+
+    Vector<String> paths = coreCLRTPAPaths_.Split(';');
+    for (unsigned i = 0; i < paths.Size(); i++)
+    {
+        AddFilesFromDirectoryToTPAList(paths[i], trustedAssemblies);
+    }
+
+    /*
+    for (unsigned i = 0; i < trustedAssemblies.Size(); i++)
+    {
+        LOGINFOF("TPA: %s", trustedAssemblies[i].CString());
+    }
+    */
+
+    // Note : instead of ; here
+    tpaList.Join(trustedAssemblies, ":");
+
+}
+
+
+bool NETHostUnix::CreateAppDomain(String& errorMsg)
+{
+    // Allowed property names:
+    // APPBASE
+    // - The base path of the application from which the exe and other assemblies will be loaded
+    //
+    // TRUSTED_PLATFORM_ASSEMBLIES
+    // - The list of complete paths to each of the fully trusted assemblies
+    //
+    // APP_PATHS
+    // - The list of paths which will be probed by the assembly loader
+    //
+    // APP_NI_PATHS
+    // - The list of additional paths that the assembly loader will probe for ngen images
+    //
+    // NATIVE_DLL_SEARCH_DIRECTORIES
+    // - The list of paths that will be probed for native DLLs called by PInvoke
+    //
+
+    const char *propertyKeys[] = {
+        "TRUSTED_PLATFORM_ASSEMBLIES",
+        "APP_PATHS",
+        "APP_NI_PATHS",
+        "NATIVE_DLL_SEARCH_DIRECTORIES",
+        "AppDomainCompatSwitch"
+    };
+
+    String tpaList;
+    GenerateTPAList(tpaList);
+
+    String appPath = "";
+    Vector<String> nativeSearch;
+    nativeSearch.Push(coreCLRFilesAbsPath_);
+    nativeSearch.Push("");
+
+    String nativeDllSearchDirs;
+    nativeDllSearchDirs.Join(nativeSearch, ";");
+
+    const char *propertyValues[] = {
+        // TRUSTED_PLATFORM_ASSEMBLIES
+        tpaList.CString(),
+        // APP_PATHS
+        appPath.CString(),
+        // APP_NI_PATHS
+        appPath.CString(),
+        // NATIVE_DLL_SEARCH_DIRECTORIES
+        nativeDllSearchDirs.CString(),
+        // AppDomainCompatSwitch
+        "UseLatestBehaviorWhenTFMNotSpecified"
+    };
+
+    int st = InitializeCoreCLR_(
+                "AtomicEditor",
+                "AtomicNETDomain",
+                sizeof(propertyKeys) / sizeof(propertyKeys[0]),
+                propertyKeys,
+                propertyValues,
+                &hostHandle_,
+                &domainId_);
+
+    if (st < 0)
+    {
+        Shutdown();
+        errorMsg = ToString("NETCore: coreclr_initialize failed - status: 0x%08x\n", st);
+        return false;
+    }
+
+    return true;
+}
+
+bool NETHostUnix::LoadCLRDLL(String& errorMsg)
+{
+    String coreClrDllPath = AddTrailingSlash(coreCLRFilesAbsPath_) + sCoreClrDll;
+
+    coreCLRDLLHandle_ = SDL_LoadObject(coreClrDllPath.CString());
+
+    if (coreCLRDLLHandle_ == NULL)
+    {
+        errorMsg = ToString("NETCore: Unable to load %s with error %s",
+            coreClrDllPath.CString(),
+            SDL_GetError());
+        return false;
+    }
+
+    InitializeCoreCLR_ = (InitializeCoreCLRFunction) SDL_LoadFunction(coreCLRDLLHandle_, "coreclr_initialize");
+
+    if (!InitializeCoreCLR_)
+    {
+        errorMsg = ToString("NETCore: Unable to get coreclr_initialize entry point in %s", coreClrDllPath.CString());
+        return false;
+    }
+
+    ShutdownCoreCLR_ = (ShutdownCoreCLRFunction) SDL_LoadFunction(coreCLRDLLHandle_, "coreclr_shutdown");
+
+    if (!ShutdownCoreCLR_)
+    {
+        errorMsg = ToString("NETCore: Unable to get coreclr_shutdown entry point in %s", coreClrDllPath.CString());
+        return false;
+    }
+
+    CreateDelegate_ = (CreateDelegateFunction) SDL_LoadFunction(coreCLRDLLHandle_, "coreclr_create_delegate");
+
+    if (!CreateDelegate_)
+    {
+        errorMsg = ToString("NETCore: Unable to get coreclr_create_delegate entry point in %s", coreClrDllPath.CString());
+        return false;
+    }
+
+    ExecuteAssembly_ = (ExecuteAssemblyFunction) SDL_LoadFunction(coreCLRDLLHandle_, "coreclr_execute_assembly");
+
+    if (!ExecuteAssembly_)
+    {
+        errorMsg = ToString("NETCore: Unable to get coreclr_execute_assembly entry point in %s", coreClrDllPath.CString());
+        return false;
+    }
+
+    return true;
+}
+
+void NETHostUnix::Shutdown()
+{
+    if (ShutdownCoreCLR_ && hostHandle_)
+    {
+        ShutdownCoreCLR_(hostHandle_, domainId_);
+    }
+
+    if (coreCLRDLLHandle_)
+    {
+        SDL_UnloadObject(coreCLRDLLHandle_);
+    }
+
+    coreCLRDLLHandle_ = 0;
+    hostHandle_ = 0;
+    domainId_ = 0;
+    InitializeCoreCLR_ = 0;
+    ExecuteAssembly_ = 0;
+    CreateDelegate_ = 0;
+    ShutdownCoreCLR_ = 0;
+
+}
+
+
+
+}
+
+/*
+static const char *dbg_channel_names[]=
+{
+    "PAL",
+    "LOADER",
+    "HANDLE",
+    "SHMEM",
+    "THREAD",
+    "EXCEPT",
+    "CRT",
+    "UNICODE",
+    "ARCH",
+    "SYNC",
+    "FILE",
+    "VIRTUAL",
+    "MEM",
+    "SOCKET",
+    "DEBUG",
+    "LOCALE",
+    "MISC",
+    "MUTEX",
+    "CRITSEC",
+    "POLL",
+    "CRYPT",
+    "SHFOLDER"
+#ifdef FEATURE_PAL_SXS
+  , "SXS"
+#endif // FEATURE_PAL_SXS
+};
+
+static const char *dbg_level_names[]=
+{
+    "ENTRY",
+    "TRACE",
+    "WARN",
+    "ERROR",
+    "ASSERT",
+    "EXIT"
+};
+*/

+ 78 - 0
Source/AtomicNET/NETCore/Platforms/Unix/NETHostUnix.h

@@ -0,0 +1,78 @@
+
+#pragma once
+
+#include "../../NETHost.h"
+
+#include <stdio.h>
+
+namespace Atomic
+{
+
+// Prototype of the coreclr_initialize function from the libcoreclr.so
+typedef int (*InitializeCoreCLRFunction)(
+            const char* exePath,
+            const char* appDomainFriendlyName,
+            int propertyCount,
+            const char** propertyKeys,
+            const char** propertyValues,
+            void** hostHandle,
+            unsigned int* domainId);
+
+// Prototype of the coreclr_shutdown function from the libcoreclr.so
+typedef int (*ShutdownCoreCLRFunction)(
+            void* hostHandle,
+            unsigned int domainId);
+
+// Prototype of the coreclr_execute_assembly function from the libcoreclr.so
+typedef int (*ExecuteAssemblyFunction)(
+            void* hostHandle,
+            unsigned int domainId,
+            int argc,
+            const char** argv,
+            const char* managedAssemblyPath,
+            unsigned int* exitCode);
+
+typedef int (*CreateDelegateFunction)(
+            void* hostHandle,
+            unsigned int domainId,
+            const char* entryPointAssemblyName,
+            const char* entryPointTypeName,
+            const char* entryPointMethodName,
+            void** delegate);
+
+class ATOMIC_API NETHostUnix : public NETHost
+{
+
+    OBJECT(NETHostUnix);
+
+public:
+    /// Construct.
+    NETHostUnix(Context* context);
+    /// Destruct.
+    virtual ~NETHostUnix();
+
+    bool Initialize();
+    bool CreateDelegate(const String& assemblyName, const String& qualifiedClassName, const String& methodName, void** funcOut);
+    void WaitForDebuggerConnect();
+    void Shutdown();
+
+private:
+
+    bool LoadCLRDLL(String& errorMsg);
+    bool CreateAppDomain(String &errorMsg);
+    void AddFilesFromDirectoryToTPAList(const String& targetPath, Vector<String>& trustedAssemblies);
+    void GenerateTPAList(String& tpaList);
+
+    InitializeCoreCLRFunction InitializeCoreCLR_;
+    ExecuteAssemblyFunction ExecuteAssembly_;
+    CreateDelegateFunction CreateDelegate_;
+    ShutdownCoreCLRFunction ShutdownCoreCLR_;
+
+    void* coreCLRDLLHandle_;
+    void* hostHandle_;
+    unsigned domainId_;
+
+
+};
+
+}

+ 0 - 40
Source/AtomicNET/NETCore/Platforms/Windows/NETHostWindows.cpp

@@ -65,46 +65,6 @@ bool NETHostWindows::Initialize()
     if (!CreateAppDomain())
     if (!CreateAppDomain())
         return false;
         return false;
 
 
-    // MOVE THIS!
-    typedef void (*StartupFunction)(const char* assemblyLoadPaths);
-    StartupFunction startup;
-
-    // The coreclr binding model will become locked upon loading the first assembly that is not on the TPA list, or
-    // upon initializing the default context for the first time. For this test, test assemblies are located alongside
-    // corerun, and hence will be on the TPA list. So, we should be able to set the default context once successfully,
-    // and fail on the second try.
-
-    // AssemblyLoadContext
-    // https://github.com/dotnet/corefx/issues/3054
-    // dnx loader
-    // https://github.com/aspnet/dnx/tree/dev/src/Microsoft.Dnx.Loader
-
-    bool result = CreateDelegate(
-                    "AtomicNETBootstrap",
-                    "Atomic.Bootstrap.AtomicLoadContext",
-                    "Startup",
-                    (void**) &startup);
-
-    if (result)
-    {
-        startup(coreCLRAssemblyLoadPaths_.CString());
-    }
-
-    // MOVE THIS!
-    typedef void (*InitializeFunction)();
-    InitializeFunction init;
-
-    result = CreateDelegate(
-                    "AtomicNETEngine",
-                    "AtomicEngine.Atomic",
-                    "Initialize",
-                    (void**) &init);
-
-    if (result)
-    {
-        init();
-    }
-
 
 
     return true;
     return true;
 }
 }

+ 2 - 0
Source/AtomicPlayer/Application/AtomicPlayer.cpp

@@ -165,6 +165,8 @@ void AtomicPlayerApp::Start()
 
 
 #else
 #else
 
 
+    String rootNETDir = fileSystem->GetProgramDir() + "AtomicPlayer_Resources/AtomicNET/";
+
 #endif
 #endif
 
 
     NETHost::SetCoreCLRFilesAbsPath(GetNativePath(rootNETDir + "CoreCLR/"));
     NETHost::SetCoreCLRFilesAbsPath(GetNativePath(rootNETDir + "CoreCLR/"));

+ 11 - 4
Source/AtomicTool/CMakeLists.txt

@@ -32,16 +32,23 @@ add_custom_command(TARGET AtomicTool POST_BUILD
                    COMMAND $<TARGET_FILE:AtomicTool> bind "\"${CMAKE_SOURCE_DIR}\"" "Script/Packages/AtomicNET/" "${JAVASCRIPT_BINDINGS_PLATFORM}"
                    COMMAND $<TARGET_FILE:AtomicTool> bind "\"${CMAKE_SOURCE_DIR}\"" "Script/Packages/AtomicNET/" "${JAVASCRIPT_BINDINGS_PLATFORM}"
                    COMMENT "Generating Script Bindings")
                    COMMENT "Generating Script Bindings")
 
 
-if (MSVC)
-
 if (NOT EXISTS ${CMAKE_SOURCE_DIR}/Artifacts/AtomicNET/TPA)
 if (NOT EXISTS ${CMAKE_SOURCE_DIR}/Artifacts/AtomicNET/TPA)
-  file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/Artifacts/AtomicNET/TPA)
+ file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/Artifacts/AtomicNET/TPA)
 endif()
 endif()
 
 
+if (MSVC)
+
 add_custom_command(TARGET AtomicTool POST_BUILD
 add_custom_command(TARGET AtomicTool POST_BUILD
                    WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/Script/AtomicNET/AtomicNET/
                    WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/Script/AtomicNET/AtomicNET/
                    COMMAND  ${CMAKE_SOURCE_DIR}/Script/AtomicNET/AtomicNET/build.cmd
                    COMMAND  ${CMAKE_SOURCE_DIR}/Script/AtomicNET/AtomicNET/build.cmd
                    COMMENT "Compiling AtomicNET Assemblies")
                    COMMENT "Compiling AtomicNET Assemblies")
-else()
+elseif(APPLE)
+
+if (NOT IOS)
+add_custom_command(TARGET AtomicTool POST_BUILD
+                   WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/Script/AtomicNET/AtomicNET/
+                   COMMAND  ${CMAKE_SOURCE_DIR}/Script/AtomicNET/AtomicNET/build.sh
+                   COMMENT "Compiling AtomicNET Assemblies")
+endif()
 
 
 endif()
 endif()

+ 4 - 2
Source/ToolCore/ToolEnvironment.cpp

@@ -63,7 +63,8 @@ bool ToolEnvironment::InitFromPackage()
     netCoreCLRAbsPath_ = GetNativePath(ToString("%sAtomicNET/Windows/x64/", resourcesDir.CString()));
     netCoreCLRAbsPath_ = GetNativePath(ToString("%sAtomicNET/Windows/x64/", resourcesDir.CString()));
     netTPAPaths_ = ToString("%sAtomicNET/Windows/Atomic/TPA/", resourcesDir.CString());
     netTPAPaths_ = ToString("%sAtomicNET/Windows/Atomic/TPA/", resourcesDir.CString());
 #else
 #else
-    String  coreCLRAbsPath = GetNativePath(ToString("%s/Submodules/CoreCLR/OSX/Debug/x64/", ATOMIC_ROOT_SOURCE_DIR);
+    netCoreCLRAbsPath_ = GetNativePath(ToString("%sAtomicNET/Windows/x64/", resourcesDir.CString()));
+    netTPAPaths_ = ToString("%sAtomicNET/Windows/Atomic/TPA/", resourcesDir.CString());
 #endif
 #endif
 
 
     return true;
     return true;
@@ -92,7 +93,8 @@ bool ToolEnvironment::InitFromJSON(bool atomicTool)
         netCoreCLRAbsPath_ = GetNativePath(ToString("%s/Submodules/CoreCLR/Windows/Release/x64/", ATOMIC_ROOT_SOURCE_DIR));
         netCoreCLRAbsPath_ = GetNativePath(ToString("%s/Submodules/CoreCLR/Windows/Release/x64/", ATOMIC_ROOT_SOURCE_DIR));
         netTPAPaths_ = ToString("%s/Artifacts/AtomicNET/TPA/", ATOMIC_ROOT_SOURCE_DIR);
         netTPAPaths_ = ToString("%s/Artifacts/AtomicNET/TPA/", ATOMIC_ROOT_SOURCE_DIR);
 #else
 #else
-        String  coreCLRAbsPath = GetNativePath(ToString("%s/Submodules/CoreCLR/OSX/Debug/x64/", ATOMIC_ROOT_SOURCE_DIR);
+        netCoreCLRAbsPath_ = GetNativePath(ToString("%s/Submodules/CoreCLR/MacOSX/Debug/x64/", ATOMIC_ROOT_SOURCE_DIR));
+        netTPAPaths_ = ToString("%s/Artifacts/AtomicNET/TPA/", ATOMIC_ROOT_SOURCE_DIR);
 #endif
 #endif
 
 
         return true;
         return true;