Browse Source

WIP OSX/Linux support for AtomicNET

Josh Engebretson 9 years ago
parent
commit
ad7a02c297

+ 1 - 3
Build/Scripts/BuildCommon.js

@@ -89,9 +89,7 @@ namespace('build', function() {
       // Compile AtomicNET assemblies
       var cmds = [];
 
-      if (os.platform() == "win32") {
-        cmds.push(host.atomicTool + " net compile " + atomicRoot + "Script/AtomicNET/AtomicNETProject.json " + platform + " " + configuration);
-      }
+      cmds.push(host.atomicTool + " net compile " + atomicRoot + "Script/AtomicNET/AtomicNETProject.json " + platform + " " + configuration);
 
       jake.exec(cmds, function() {
 

+ 6 - 2
Script/AtomicNET/AtomicNET/Core/AtomicNET.cs

@@ -89,10 +89,14 @@ namespace AtomicEngine
             NativeCore.Initialize();
             CSComponentCore.Initialize();
 
+            string[] arguments = Environment.GetCommandLineArgs();
+            foreach (string arg in arguments)
+                AppBase.AddArgument(arg);
+
         }
 
         [DllImport(Constants.LIBNAME, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
-        private static extern IntPtr csb_Atomic_NETCore_Initialize(ref CoreDelegates delegates);        
+        private static extern IntPtr csb_Atomic_NETCore_Initialize(ref CoreDelegates delegates);
 
         private static Context context;
         private static CoreDelegates coreDelegates;
@@ -100,4 +104,4 @@ namespace AtomicEngine
 
     }
 
-}
+}

+ 14 - 1
Source/AtomicApp/AppBase.cpp

@@ -38,12 +38,25 @@ namespace Atomic
 {
 
     Vector<String> AppBase::engineConfigSearchPaths_;
+    Vector<String> AppBase::arguments_;
 
     AppBase::AppBase(Context* context) :
         Application(context)
     {
         // Copy arguments
-        arguments_ = GetArguments();
+        if (!arguments_.Size())
+        {
+            arguments_ = GetArguments();
+        }
+        else
+        {
+            String commandline = String::Joined(arguments_, " ");
+
+            ParseArguments(commandline, false);
+
+            arguments_ = GetArguments();
+        }
+
     }
 
     AppBase::~AppBase()

+ 2 - 2
Source/AtomicApp/AppBase.h

@@ -45,7 +45,7 @@ namespace Atomic
         /// Cleanup after the main loop. 
         virtual void Stop();
 
-        void AddArgument(const String& argument) { arguments_.Push(argument); }
+        static void AddArgument(const String& argument) { arguments_.Push(argument); }
 
         virtual void ProcessArguments();
 
@@ -55,7 +55,7 @@ namespace Atomic
 
         void ReadEngineConfig();
 
-        Vector<String> arguments_;
+        static Vector<String> arguments_;
         static Vector<String> engineConfigSearchPaths_;
 
         SharedPtr<JSVM> vm_;

+ 15 - 2
Source/AtomicEditor/EditorMode/AEEditorMode.cpp

@@ -129,6 +129,8 @@ bool EditorMode::PlayProject(String addArgs, bool debug)
 {
     FileSystem* fileSystem = GetSubsystem<FileSystem>();
     ToolSystem* tsystem = GetSubsystem<ToolSystem>();
+    ToolEnvironment* tenv = GetSubsystem<ToolEnvironment>();
+
     Project* project = tsystem->GetProject();
 
     if (!project)
@@ -166,8 +168,12 @@ bool EditorMode::PlayProject(String addArgs, bool debug)
     vargs = args.Split(' ');
 
     if (managed)
-    {            
-        vargs.Insert(0, ToString("\"%s\"", (fileSystem->GetProgramDir() + "Resources/").CString()));        
+    {
+#ifdef ATOMIC_DEV_BUILD
+        vargs.Insert(0, ToString("\"%s/Resources/\"", tenv->GetRootSourceDir().CString()));
+#else
+        vargs.Insert(0, ToString("\"%s\"", (fileSystem->GetProgramDir() + "Resources/").CString()));
+#endif
         vargs.Insert(0, "--resourcePrefix");
     }
 
@@ -177,6 +183,13 @@ bool EditorMode::PlayProject(String addArgs, bool debug)
     if (addArgs.Length() > 0)
         vargs.Insert(0, addArgs.Split(' '));
 
+#ifndef ATOMIC_PLATFORM_WINDOWS
+
+    vargs.Insert(0, playerBinary);
+    playerBinary = "/Library/Frameworks/Mono.framework/Versions/Current/Commands/mono64";
+
+#endif
+
     String dump;
     dump.Join(vargs, " ");
     ATOMIC_LOGINFOF("Launching Broker %s %s", playerBinary.CString(), dump.CString());

+ 0 - 7
Source/AtomicNET/NETNative/NETAtomicPlayer.cpp

@@ -45,13 +45,6 @@ namespace Atomic
         PlayerApp(context)
     {
 
-#ifdef WIN32
-        ParseArguments(GetCommandLineW());
-#else
-        #warning Implement Argument Parsing
-#endif
-        arguments_ = GetArguments();
-
     }
 
     void NETAtomicPlayer::Setup()

+ 0 - 7
Source/AtomicNET/NETNative/NETIPCPlayerApp.cpp

@@ -44,13 +44,6 @@ namespace Atomic
         IPCPlayerApp(context)
     {
 
-#ifdef WIN32
-        ParseArguments(GetCommandLineW());
-#else
-        #warning Implement Argument Parsing
-#endif
-        arguments_ = GetArguments();
-
     }
 
     void NETIPCPlayerApp::Setup()

+ 0 - 7
Source/AtomicNET/NETNative/NETServiceApplication.cpp

@@ -42,13 +42,6 @@ namespace Atomic
         IPCClientApp(context)
     {
 
-#ifdef WIN32
-        ParseArguments(GetCommandLineW());        
-#else
-        #warning Implement Argument Parsing
-#endif
-        arguments_ = GetArguments();
-
     }
 
     void NETServiceApplication::Setup()

+ 0 - 15
Source/ToolCore/Command/NETCmd.cpp

@@ -170,21 +170,6 @@ void NETCmd::Run()
         netService_ = new AtomicNETService(context_);
         context_->RegisterSubsystem(netService_);
 
-        /*
-
-        VariantMap cmd;
-        cmd["command"] = "parse";
-        cmd["assemblyPath"] = assemblyPath_;
-
-        netService_->QueueCommand(cmd);
-
-        cmd.Clear();
-        cmd["command"] = "exit";
-
-        netService_->QueueCommand(cmd);
-
-        */
-
         if (!netService_->Start())
         {
             Error("Unable to start AtomicNETService");

+ 27 - 5
Source/ToolCore/NETTools/NETBuildSystem.cpp

@@ -250,6 +250,12 @@ namespace ToolCore
                 return;
             }
 
+            const String configuration = curBuild_->configuration_;
+
+            Vector<String> args;
+
+#ifdef ATOMIC_PLATFORM_WINDOWS
+
             String cmdToolsPath = Poco::Environment::get("VS140COMNTOOLS").c_str();
 
             if (!cmdToolsPath.Length())
@@ -260,10 +266,8 @@ namespace ToolCore
 
             String vcvars64 = ToString("%s..\\..\\VC\\bin\\amd64\\vcvars64.bat", cmdToolsPath.CString());
 
-            const String configuration = curBuild_->configuration_;
-
             String cmd = "cmd";
-            Vector<String> args;
+
             args.Push("/A");
             args.Push("/C");
 
@@ -279,6 +283,24 @@ namespace ToolCore
 
             args.Push(compile);
 
+#else
+
+            String compile;
+
+            String cmd = "bash";
+            args.Push("-c");
+
+            if (requiresNuGet)
+            {
+                compile += ToString("/Library/Frameworks/Mono.framework/Versions/Current/Commands/nuget restore \"%s\" && ", solutionPath.CString());
+            }
+
+            compile += ToString("/Library/Frameworks/Mono.framework/Versions/Current/Commands/xbuild \"%s\" /p:Configuration=%s /p:Platform=\"Any CPU\"", solutionPath.CString(), configuration.CString());
+
+            args.Push(compile);
+
+#endif
+
             curBuild_->allArgs_.Join(args, " ");
 
             SubprocessSystem* subs = GetSubsystem<SubprocessSystem>();
@@ -286,7 +308,7 @@ namespace ToolCore
 
             try
             {
-                subprocess = subs->Launch(cmd, args, "C:\\");
+                subprocess = subs->Launch(cmd, args, "");
             }
             catch (Poco::SystemException)
             {
@@ -340,7 +362,7 @@ namespace ToolCore
         platform = "LINUX";
 #endif
 
-#ifdef _DEBUG
+#ifdef ATOMIC_DEBUG
         configuration = "Debug";
 #else
         configuration = "Release";

+ 3 - 2
Source/ToolCore/NETTools/NETProjectGen.cpp

@@ -615,8 +615,9 @@ namespace ToolCore
             const String& projectName = p->GetName();
             const String& projectGUID = p->GetProjectGUID();
 
+            const String CSharpProjectGUID = "FAE04EC0-301F-11D3-BF4B-00C04F79EFBC";
             source += ToString("Project(\"{%s}\") = \"%s\", \"%s\\%s.csproj\", \"{%s}\"\n",
-                solutionGUID_.CString(), projectName.CString(), projectName.CString(),
+                CSharpProjectGUID.CString(), projectName.CString(), projectName.CString(),
                 projectName.CString(), projectGUID.CString());
 
             projectGen_->GetCSProjectDependencies(p, depends);
@@ -634,7 +635,7 @@ namespace ToolCore
                 source += "\tEndProjectSection\n";
             }
 
-            source += "\tEndProject\n";
+            source += "EndProject\n";
         }
 
         source += "Global\n";

+ 3 - 6
Source/ToolCore/NETTools/NETProjectSystem.cpp

@@ -159,8 +159,6 @@ namespace ToolCore
             }
         }
 
-#ifdef ATOMIC_PLATFORM_WINDOWS
-
         Project* project = GetSubsystem<ToolSystem>()->GetProject();
         NETBuildSystem* buildSystem = GetSubsystem<NETBuildSystem>();
 
@@ -174,8 +172,6 @@ namespace ToolCore
             }
 
         }
-#endif
-
     }
 
     bool NETProjectSystem::GenerateSolution()
@@ -336,8 +332,6 @@ namespace ToolCore
     {
         Clear();
 
-#ifdef ATOMIC_PLATFORM_WINDOWS
-
         SubscribeToEvent(E_UPDATE, ATOMIC_HANDLER(NETProjectSystem, HandleUpdate));
 
         SubscribeToEvent(E_PROJECTLOADED, ATOMIC_HANDLER(NETProjectSystem, HandleProjectLoaded));
@@ -355,6 +349,9 @@ namespace ToolCore
         SubscribeToEvent(E_ASSETRENAMED, ATOMIC_HANDLER(NETProjectSystem, HandleAssetRenamed));
         SubscribeToEvent(E_ASSETMOVED, ATOMIC_HANDLER(NETProjectSystem, HandleAssetMoved));
 
+
+#ifdef ATOMIC_PLATFORM_WINDOWS
+
         FileSystem* fileSystem = GetSubsystem<FileSystem>();
 
         // Query for Visual Studio 2015 path

+ 1 - 1
Source/ToolCore/ToolEnvironment.cpp

@@ -169,7 +169,7 @@ void ToolEnvironment::SetRootSourceDir(const String& sourceDir)
 
     // AtomicNET
 
-#ifdef _DEBUG
+#ifdef ATOMIC_DEBUG
     String config = "Debug";
 #else
     String config = "Release";