Skip to content

Commit

Permalink
MGCB Editor dotnet tool (MonoGame#7090)
Browse files Browse the repository at this point in the history
* add Launcher project with conditional runtime refs

* add DotNetProcess and organize platform files

* change mgcb process to use new DotNetProcess class

* add cli

* add Windows file association; clean up dotnet ProcessStartInfo

* clean up csprojs

* add Linux registration; add Mac placeholders

* remove old Directory.build.props

* add new Directory.Build.props

* fix Linux file association

* fix synchronous launch

* fix Mac processes

* cleanup

* more cleanup; fix Mac unpacked search paths

* fix Mac registration search paths

* remove old targets

* fix template copying

* fix linux desktop file and mimetype

* update cake build
  • Loading branch information
jnoyola authored Apr 10, 2020
1 parent 5a75f40 commit 95bf556
Show file tree
Hide file tree
Showing 33 changed files with 1,197 additions and 333 deletions.
14 changes: 14 additions & 0 deletions MonoGame.Tools.Linux.sln
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MonoGame.Tools.Tests", "Too
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MonoGame.Content.Builder.Editor.Linux", "Tools\MonoGame.Content.Builder.Editor\MonoGame.Content.Builder.Editor.Linux.csproj", "{11B8224E-E56D-41E0-867C-DB5E2E757AB2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MonoGame.Content.Builder.Editor", "Tools\MonoGame.Content.Builder.Editor\MonoGame.Content.Builder.Editor.csproj", "{F673A915-308F-4111-8950-A5755BE5CEEA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -111,6 +113,18 @@ Global
{11B8224E-E56D-41E0-867C-DB5E2E757AB2}.Release|x64.Build.0 = Release|Any CPU
{11B8224E-E56D-41E0-867C-DB5E2E757AB2}.Release|x86.ActiveCfg = Release|Any CPU
{11B8224E-E56D-41E0-867C-DB5E2E757AB2}.Release|x86.Build.0 = Release|Any CPU
{F673A915-308F-4111-8950-A5755BE5CEEA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F673A915-308F-4111-8950-A5755BE5CEEA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F673A915-308F-4111-8950-A5755BE5CEEA}.Debug|x64.ActiveCfg = Debug|Any CPU
{F673A915-308F-4111-8950-A5755BE5CEEA}.Debug|x64.Build.0 = Debug|Any CPU
{F673A915-308F-4111-8950-A5755BE5CEEA}.Debug|x86.ActiveCfg = Debug|Any CPU
{F673A915-308F-4111-8950-A5755BE5CEEA}.Debug|x86.Build.0 = Debug|Any CPU
{F673A915-308F-4111-8950-A5755BE5CEEA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F673A915-308F-4111-8950-A5755BE5CEEA}.Release|Any CPU.Build.0 = Release|Any CPU
{F673A915-308F-4111-8950-A5755BE5CEEA}.Release|x64.ActiveCfg = Release|Any CPU
{F673A915-308F-4111-8950-A5755BE5CEEA}.Release|x64.Build.0 = Release|Any CPU
{F673A915-308F-4111-8950-A5755BE5CEEA}.Release|x86.ActiveCfg = Release|Any CPU
{F673A915-308F-4111-8950-A5755BE5CEEA}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
14 changes: 14 additions & 0 deletions MonoGame.Tools.Mac.sln
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoGame.Tools.Tests", "Too
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoGame.Content.Builder.Editor.Mac", "Tools\MonoGame.Content.Builder.Editor\MonoGame.Content.Builder.Editor.Mac.csproj", "{1853CCED-232C-4972-A2F2-D56F7F6DBEAE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoGame.Content.Builder.Editor", "Tools\MonoGame.Content.Builder.Editor\MonoGame.Content.Builder.Editor.csproj", "{F673A915-308F-4111-8950-A5755BE5CEEA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -114,5 +116,17 @@ Global
{1853CCED-232C-4972-A2F2-D56F7F6DBEAE}.Release|x64.Build.0 = Release|Any CPU
{1853CCED-232C-4972-A2F2-D56F7F6DBEAE}.Release|x86.ActiveCfg = Release|Any CPU
{1853CCED-232C-4972-A2F2-D56F7F6DBEAE}.Release|x86.Build.0 = Release|Any CPU
{F673A915-308F-4111-8950-A5755BE5CEEA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F673A915-308F-4111-8950-A5755BE5CEEA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F673A915-308F-4111-8950-A5755BE5CEEA}.Debug|x64.ActiveCfg = Debug|Any CPU
{F673A915-308F-4111-8950-A5755BE5CEEA}.Debug|x64.Build.0 = Debug|Any CPU
{F673A915-308F-4111-8950-A5755BE5CEEA}.Debug|x86.ActiveCfg = Debug|Any CPU
{F673A915-308F-4111-8950-A5755BE5CEEA}.Debug|x86.Build.0 = Debug|Any CPU
{F673A915-308F-4111-8950-A5755BE5CEEA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F673A915-308F-4111-8950-A5755BE5CEEA}.Release|Any CPU.Build.0 = Release|Any CPU
{F673A915-308F-4111-8950-A5755BE5CEEA}.Release|x64.ActiveCfg = Release|Any CPU
{F673A915-308F-4111-8950-A5755BE5CEEA}.Release|x64.Build.0 = Release|Any CPU
{F673A915-308F-4111-8950-A5755BE5CEEA}.Release|x86.ActiveCfg = Release|Any CPU
{F673A915-308F-4111-8950-A5755BE5CEEA}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
14 changes: 14 additions & 0 deletions MonoGame.Tools.Windows.sln
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MonoGame.Tools.Tests", "Too
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MonoGame.Content.Builder.Editor.Windows", "Tools\MonoGame.Content.Builder.Editor\MonoGame.Content.Builder.Editor.Windows.csproj", "{332EFBC3-D4C2-43A6-BBA8-F54956160BBB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MonoGame.Content.Builder.Editor", "Tools\MonoGame.Content.Builder.Editor\MonoGame.Content.Builder.Editor.csproj", "{F673A915-308F-4111-8950-A5755BE5CEEA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -111,6 +113,18 @@ Global
{332EFBC3-D4C2-43A6-BBA8-F54956160BBB}.Release|x64.Build.0 = Release|Any CPU
{332EFBC3-D4C2-43A6-BBA8-F54956160BBB}.Release|x86.ActiveCfg = Release|Any CPU
{332EFBC3-D4C2-43A6-BBA8-F54956160BBB}.Release|x86.Build.0 = Release|Any CPU
{F673A915-308F-4111-8950-A5755BE5CEEA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F673A915-308F-4111-8950-A5755BE5CEEA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F673A915-308F-4111-8950-A5755BE5CEEA}.Debug|x64.ActiveCfg = Debug|Any CPU
{F673A915-308F-4111-8950-A5755BE5CEEA}.Debug|x64.Build.0 = Debug|Any CPU
{F673A915-308F-4111-8950-A5755BE5CEEA}.Debug|x86.ActiveCfg = Debug|Any CPU
{F673A915-308F-4111-8950-A5755BE5CEEA}.Debug|x86.Build.0 = Debug|Any CPU
{F673A915-308F-4111-8950-A5755BE5CEEA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F673A915-308F-4111-8950-A5755BE5CEEA}.Release|Any CPU.Build.0 = Release|Any CPU
{F673A915-308F-4111-8950-A5755BE5CEEA}.Release|x64.ActiveCfg = Release|Any CPU
{F673A915-308F-4111-8950-A5755BE5CEEA}.Release|x64.Build.0 = Release|Any CPU
{F673A915-308F-4111-8950-A5755BE5CEEA}.Release|x86.ActiveCfg = Release|Any CPU
{F673A915-308F-4111-8950-A5755BE5CEEA}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 0 additions & 2 deletions Tools/MonoGame.Content.Builder.Editor/Common/IView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ public interface IView

bool CopyOrLinkFolder(string folder, bool exists, out IncludeType action, out bool applyforall);

Process CreateProcess(string exe, string commands);

void UpdateCommands(MenuInfo info);

void UpdateRecentList(List<string> recentList);
Expand Down
43 changes: 16 additions & 27 deletions Tools/MonoGame.Content.Builder.Editor/Common/PipelineController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using System.Text;
using System.Threading.Tasks;
using MonoGame.Content.Builder;
using MonoGame.Tools.Pipeline.Utilities;
using PathHelper = MonoGame.Framework.Content.Pipeline.Builder.PathHelper;

namespace MonoGame.Tools.Pipeline
Expand All @@ -36,7 +37,6 @@ public partial class PipelineController : IController
Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "../../../MonoGame.Content.Builder/Release"),
Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "../../../../../../MonoGame.Content.Builder/Release"),
#endif

};

public IEnumerable<ContentItemTemplate> Templates
Expand Down Expand Up @@ -481,25 +481,6 @@ public void Clean()
UpdateMenu();
}

private string FindMGCB()
{
foreach (var root in _mgcbSearchPaths)
{
var mgcbPath = Path.Combine(root, "mgcb.exe");
if (File.Exists(mgcbPath))
return Path.GetFullPath(mgcbPath);

if (Global.Unix)
{
mgcbPath = Path.Combine(root, "mgcb");
if (File.Exists(mgcbPath))
return Path.GetFullPath(mgcbPath);
}
}

throw new FileNotFoundException("mgcb is not in the search path!");
}

private void DoBuild(string commands)
{
Encoding encoding;
Expand All @@ -515,16 +496,24 @@ private void DoBuild(string commands)
try
{
// Prepare the process.
_buildProcess = View.CreateProcess(FindMGCB(), commands);
_buildProcess.StartInfo.WorkingDirectory = Path.GetDirectoryName(_project.OriginalPath);
_buildProcess.StartInfo.CreateNoWindow = true;
_buildProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
_buildProcess.StartInfo.UseShellExecute = false;
_buildProcess.StartInfo.RedirectStandardOutput = true;
_buildProcess.StartInfo.StandardOutputEncoding = encoding;
_buildProcess = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = "mgcb",
Arguments = commands,
WorkingDirectory = Path.GetDirectoryName(_project.OriginalPath),
CreateNoWindow = true,
WindowStyle = ProcessWindowStyle.Hidden,
UseShellExecute = false,
RedirectStandardOutput = true,
StandardOutputEncoding = encoding
}.ResolveDotnetApp(_mgcbSearchPaths, waitForExit: true)
};
_buildProcess.OutputDataReceived += (sender, args) => View.OutputAppend(args.Data);

// Fire off the process.
Console.WriteLine(_buildProcess.StartInfo.FileName + " " + _buildProcess.StartInfo.Arguments);
Environment.CurrentDirectory = _buildProcess.StartInfo.WorkingDirectory;
_buildProcess.Start();
_buildProcess.BeginOutputReadLine();
Expand Down
13 changes: 13 additions & 0 deletions Tools/MonoGame.Content.Builder.Editor/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project>

<!-- This is needed to differentiate intermediate output directories if you have
multiple projects in the same folder and build them in the same solution.
See more: https://github.com/NuGet/Home/issues/4463#issuecomment-404806889 -->
<PropertyGroup>
<MSBuildProjectExtensionsPath>obj\$(MSBuildProjectName)\</MSBuildProjectExtensionsPath>
</PropertyGroup>

<!-- Continue up the folder tree for any additional Directory.Build.props files. -->
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)..\'))" />

</Project>
39 changes: 35 additions & 4 deletions Tools/MonoGame.Content.Builder.Editor/Info.plist
Original file line number Diff line number Diff line change
@@ -1,7 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<dict>
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeIconFile</key>
<string>Icon.icns</string>
<key>UTTypeConformsTo</key>
<array>
<string>public.text</string>
</array>
<key>UTTypeIdentifier</key>
<string>net.monogame.mgcb</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<string>mgcb</string>
</dict>
</dict>
</array>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>LSItemContentTypes</key>
<array>
<string>net.monogame.mgcb</string>
</array>
<key>CFBundleTypeName</key>
<string>MGCB</string>
<key>LSHandlerRank</key>
<string>Owner</string>
</dict>
</array>
<key>LSEnvironment</key>
<dict>
<key>MONO_MANAGED_WATCHER</key>
Expand All @@ -18,12 +49,12 @@
<key>LSApplicationCategoryType</key>
<string>public.app-category.developer-tools</string>
<key>CFBundleDisplayName</key>
<string>MonoGame Content Pipeline Tool</string>
<string>MGCB Editor</string>
<key>CFBundleIdentifier</key>
<string>net.monogame.mgcb-editor</string>
<key>CFBundleShortVersionString</key>
<string>3.3</string>
<key>CFBundleIconFile</key>
<string>Icon.icns</string>
<key>CFBundleIconFile</key>
<string>Icon.icns</string>
</dict>
</plist>
55 changes: 0 additions & 55 deletions Tools/MonoGame.Content.Builder.Editor/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -306,61 +306,6 @@ public bool CopyOrLinkFolder(string folder, bool exists, out IncludeType action,
return false;
}

public Process CreateProcess(string exe, string commands)
{
var proc = new Process();

if (Global.Unix && exe.EndsWith(".exe"))
{
string monoLoc = null;

foreach (var path in monoLocations)
{
if (File.Exists(path))
{
monoLoc = path;
break;
}
}

if (string.IsNullOrEmpty(monoLoc))
{
monoLoc = "mono";
OutputAppend("Could not find mono. Please install the latest version from http://www.mono-project.com");
}

proc.StartInfo.FileName = monoLoc;

if (PipelineSettings.Default.DebugMode)
{
var port = Environment.GetEnvironmentVariable("MONO_DEBUGGER_PORT");
port = !string.IsNullOrEmpty(port) ? port : "55555";
var monodebugger = string.Format("--debug --debugger-agent=transport=dt_socket,server=y,address=127.0.0.1:{0}",
port);
proc.StartInfo.Arguments = string.Format("{0} \"{1}\" {2}", monodebugger, exe, commands);
OutputAppend("************************************************");
OutputAppend("RUNNING MGCB IN DEBUG MODE!!!");
OutputAppend(string.Format("Attach your Debugger to localhost:{0}", port));
OutputAppend("************************************************");
}
else
{
proc.StartInfo.Arguments = string.Format("\"{0}\" {1}", exe, commands);
}
}
else
{
proc.StartInfo.FileName = exe;
proc.StartInfo.Arguments = commands;

// TODO: Fix debugging .NET Core stuff from Unix

System.Console.WriteLine(exe + " " + commands);
}

return proc;
}

public void UpdateCommands(MenuInfo info)
{
// Title
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<BaseOutputPath>..\..\Artifacts\MonoGame.Content.Builder.Editor\Gtk</BaseOutputPath>
<DefineConstants>GTK</DefineConstants>
<AppendTargetFrameworkToOutputPath>False</AppendTargetFrameworkToOutputPath>
<AssemblyName>mgcb-editor</AssemblyName>
<AssemblyName>mgcb-editor-gtk</AssemblyName>
</PropertyGroup>

<ItemGroup>
Expand All @@ -17,16 +17,23 @@
</ItemGroup>

<ItemGroup>
<Compile Remove="Global.Mac.cs" />
<Compile Remove="Global.Windows.cs" />
<Compile Remove="Styles.Mac.cs" />
<Compile Remove="Styles.Windows.cs" />
<None Remove="Platform\**\*" />
<Compile Remove="Platform\**\*" />

<Compile Include="Platform\Linux\**\*.cs" />
<Compile Include="Platform\Utilities\**\*.cs" />

<Content Include="Platform\Linux\Content\**\*">
<Link>Content\%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Eto.Forms" Version="2.5.0" />
<PackageReference Include="Eto.Platform.Gtk" Version="2.5.0" />
<PackageReference Include="GtkSharp" Version="3.22.25.56" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.20158.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,23 @@
<BaseOutputPath>..\..\Artifacts\MonoGame.Content.Builder.Editor\Mac</BaseOutputPath>
<DefineConstants>MONOMAC;MAC</DefineConstants>
<AppendTargetFrameworkToOutputPath>False</AppendTargetFrameworkToOutputPath>
<AssemblyName>mgcb-editor</AssemblyName>
<AssemblyName>mgcb-editor-mac</AssemblyName>
<MacBundleName>$(AssemblyName)</MacBundleName>
<RuntimeIdentifiers>osx-x64</RuntimeIdentifiers>
</PropertyGroup>

<ItemGroup>
<Compile Remove="Global.Linux.cs" />
<Compile Remove="Global.Windows.cs" />
<Compile Remove="Styles.Linux.cs" />
<Compile Remove="Styles.Windows.cs" />
<None Remove="Platform\**\*" />
<Compile Remove="Platform\**\*" />

<Compile Include="Platform\Mac\**\*.cs" />
<Compile Include="Platform\Utilities\**\*.cs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Eto.Forms" Version="2.5.0" />
<PackageReference Include="Eto.Platform.Mac64" Version="2.5.0" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.20158.1" />
</ItemGroup>

<ItemGroup>
Expand All @@ -30,7 +33,7 @@
</ItemGroup>

<ItemGroup>
<None Remove="App.icns" />
<None Remove="Icon.icns" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="Icon.icns" />
Expand Down
Loading

0 comments on commit 95bf556

Please sign in to comment.