Browse Source

Xamarin Studio integration

Josh Engebretson 9 years ago
parent
commit
ed1f134a9c

+ 1 - 1
Script/AtomicEditor/hostExtensions/languageExtensions/CSharpLanguageExtension.ts

@@ -139,7 +139,7 @@ export default class CSharpLanguageExtension implements Editor.HostExtensions.Re
         if (isCompileOnSave && ToolCore.netProjectSystem) {
 
             // for now, only support compile on save when not using VS
-            if (!ToolCore.netProjectSystem.visualStudioAvailable)
+            if (!ToolCore.netProjectSystem.iDEAvailable)
                 ToolCore.netProjectSystem.buildAtomicProject();
         }
 

+ 1 - 1
Script/AtomicEditor/ui/resourceEditors/CSharpResourceEditorBuilder.ts

@@ -31,7 +31,7 @@ export default class CSharpResourceEditorBuilder extends AbstractTextResourceEdi
     canHandleResource(resourcePath: string) : boolean {
 
         /// Handled externally by VS, TODO: make this a preference
-        if (ToolCore.netProjectSystem.visualStudioAvailable)
+        if (ToolCore.netProjectSystem.iDEAvailable)
             return false;
 
         var ext = Atomic.getExtension(resourcePath).toLowerCase();

+ 1 - 1
Script/AtomicEditor/ui/resourceEditors/VisualStudioResourceEditorBuilder.ts

@@ -37,7 +37,7 @@ export default class VisualStudioResourceEditorBuilder extends AbstractTextResou
     canHandleResource(resourcePath: string) : boolean {
 
         /// Handled externally by VS, TODO: make this a preference
-        if (!ToolCore.netProjectSystem.visualStudioAvailable)
+        if (!ToolCore.netProjectSystem.iDEAvailable)
             return false;
 
         var ext = Atomic.getExtension(resourcePath).toLowerCase();

+ 1 - 1
Source/ToolCore/NETTools/NETBuildSystem.h

@@ -59,7 +59,7 @@ namespace ToolCore
     public:
 
         NETBuild(Context* context, const String& solutionPath, const String& platform, const String& configuration);
-        virtual ~NETBuild() {};
+        virtual ~NETBuild() {}
 
     private:
         /// .sln or .json configuration file

+ 43 - 14
Source/ToolCore/NETTools/NETProjectSystem.cpp

@@ -65,7 +65,7 @@ namespace ToolCore
 
     void NETProjectSystem::OpenSolution()
     {
-        if (!visualStudioPath_.Length())
+        if (!idePath_.Length())
             return;
 
         FileSystem* fileSystem = GetSubsystem<FileSystem>();
@@ -82,28 +82,37 @@ namespace ToolCore
 
     void NETProjectSystem::OpenSourceFile(const String& sourceFilePath)
     {
-        if (!visualStudioPath_.Length())
+        if (!idePath_.Length())
             return;
 
+        String command = idePath_;
         StringVector args;
 
-        if (vsSubprocess_.Expired())
+        if (ideSubprocess_.Expired())
         {
             SubprocessSystem* subs = GetSubsystem<SubprocessSystem>();
-            vsSubprocess_ = 0;
+            ideSubprocess_ = 0;
+
+#ifdef ATOMIC_PLATFORM_OSX
+
+            command = "open";
+            args.Push("-W");
+            args.Push("-a");
+            args.Push(idePath_);
+#endif
 
             args.Push(solutionPath_);
 
             if (sourceFilePath.Length())
-                args.Push(sourceFilePath);
+                args.Push(sourceFilePath);                       
 
             try
             {
-                vsSubprocess_ = subs->Launch(visualStudioPath_, args);
+                ideSubprocess_ = subs->Launch(command, args);
             }
             catch (Poco::SystemException)
             {
-                vsSubprocess_ = 0;
+                ideSubprocess_ = 0;
             }
 
         }
@@ -113,11 +122,22 @@ namespace ToolCore
                 return;
 
             try
-            {
+            {                
                 std::vector<std::string> args;
+
+#ifdef ATOMIC_PLATFORM_WINDOWS
+
                 args.push_back("/edit");
+
+#elif defined ATOMIC_PLATFORM_OSX
+
+                command = "open";
+                args.push_back("-a");
+                args.push_back(idePath_.CString());
+
+#endif
                 args.push_back(sourceFilePath.CString());
-                Poco::Process::launch(visualStudioPath_.CString(), args);
+                Poco::Process::launch(command.CString(), args);
 
             }
             catch (Poco::SystemException)
@@ -355,14 +375,23 @@ namespace ToolCore
         FileSystem* fileSystem = GetSubsystem<FileSystem>();
 
         // Query for Visual Studio 2015 path
-        visualStudioPath_ = Poco::Environment::get("VS140COMNTOOLS").c_str();
+        idePath_ = Poco::Environment::get("VS140COMNTOOLS").c_str();
 
-        if (visualStudioPath_.Length())
+        if (idePath_.Length())
         {
-            visualStudioPath_.Replace("Tools\\", "IDE\\devenv.exe");
+            idePath_.Replace("Tools\\", "IDE\\devenv.exe");
+
+            if (!fileSystem->FileExists(idePath_))
+                idePath_.Clear();
+        }
 
-            if (!fileSystem->FileExists(visualStudioPath_))
-                visualStudioPath_.Clear();
+#elif defined ATOMIC_PLATFORM_OSX
+
+        FileSystem* fileSystem = GetSubsystem<FileSystem>();
+
+        if (fileSystem->DirExists("/Applications/Xamarin Studio.app"))
+        {
+            idePath_ = "/Applications/Xamarin Studio.app/Contents/MacOS/XamarinStudio";
         }
 
 #endif

+ 3 - 3
Source/ToolCore/NETTools/NETProjectSystem.h

@@ -50,7 +50,7 @@ namespace ToolCore
         NETProjectSystem(Context* context);
         virtual ~NETProjectSystem();
 
-        bool GetVisualStudioAvailable() const { return visualStudioPath_.Length() != 0; }
+        bool GetIDEAvailable() const { return idePath_.Length() != 0; }
 
         const String& GetSolutionPath() const { return solutionPath_; }
 
@@ -86,7 +86,7 @@ namespace ToolCore
         void Clear();
         void Initialize();
 
-        String visualStudioPath_;
+        String idePath_;
 
         String solutionPath_;
         String projectAssemblyPath_;
@@ -97,7 +97,7 @@ namespace ToolCore
         bool  projectAssemblyDirty_;
 
         // Visual Studio subprocess
-        WeakPtr<Subprocess> vsSubprocess_;
+        WeakPtr<Subprocess> ideSubprocess_;
 
     };