Skip to content

Commit

Permalink
- WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
tgiphil committed Nov 3, 2023
1 parent 6b64b34 commit 20dcd99
Show file tree
Hide file tree
Showing 14 changed files with 103 additions and 167 deletions.
30 changes: 15 additions & 15 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ jobs:
name: windows-build-artifact
path: bin
- name: Unit Test
run: bin\Mosa.Utility.UnitTests.exe -check -o${{ matrix.optimization }}
run: bin\Mosa.Utility.UnitTests.exe -check -output-counters -o${{ matrix.optimization }}

linux-unit-testing:
strategy:
Expand Down Expand Up @@ -247,7 +247,7 @@ jobs:
- name: Install Qemu and Dependencies
run: sudo apt-get -y -o Acquire::Retries=5 install qemu-system-x86
- name: Unit Test
run: dotnet bin/Mosa.Utility.UnitTests.dll -check -o${{ matrix.optimization }}
run: dotnet bin/Mosa.Utility.UnitTests.dll -check -output-counters -o${{ matrix.optimization }}

macos-unit-testing:
strategy:
Expand All @@ -273,7 +273,7 @@ jobs:
name: macos-build-artifact
path: bin
- name: Unit Test
run: dotnet bin/Mosa.Utility.UnitTests.dll -check -o${{ matrix.optimization }}
run: dotnet bin/Mosa.Utility.UnitTests.dll -check -output-counters -o${{ matrix.optimization }}

windows-demo-testing:
strategy:
Expand All @@ -295,13 +295,13 @@ jobs:
name: windows-build-artifact
path: bin
- name: Demo Test - BareMetal Starter
run: bin\Mosa.Tool.Launcher.Console.exe bin\Mosa.BareMetal.Starter.x86.dll -o${{ matrix.optimization }} -check -test
run: bin\Mosa.Tool.Launcher.Console.exe bin\Mosa.BareMetal.Starter.x86.dll -o${{ matrix.optimization }} -check -test -output-counters
- name: Demo Test - BareMetal TestWorld
run: bin\Mosa.Tool.Launcher.Console.exe bin\Mosa.BareMetal.TestWorld.x86.dll -o${{ matrix.optimization }} -check -test
run: bin\Mosa.Tool.Launcher.Console.exe bin\Mosa.BareMetal.TestWorld.x86.dll -o${{ matrix.optimization }} -check -test -output-counters
- name: Demo Test - BareMetal HelloWorld
run: bin\Mosa.Tool.Launcher.Console.exe bin\Mosa.BareMetal.HelloWorld.x86.dll -o${{ matrix.optimization }} -check -test
run: bin\Mosa.Tool.Launcher.Console.exe bin\Mosa.BareMetal.HelloWorld.x86.dll -o${{ matrix.optimization }} -check -test -output-counters
- name: Demo Test - BareMetal CoolWorld
run: bin\Mosa.Tool.Launcher.Console.exe bin\Mosa.BareMetal.CoolWorld.x86.dll -o${{ matrix.optimization }} -check -test -vmware-svga -include bin\Include
run: bin\Mosa.Tool.Launcher.Console.exe bin\Mosa.BareMetal.CoolWorld.x86.dll -o${{ matrix.optimization }} -check -test -output-counters -vmware-svga -include bin\Include

linux-demo-testing:
strategy:
Expand Down Expand Up @@ -331,13 +331,13 @@ jobs:
- name: Install Qemu and Dependencies
run: sudo apt-get -y -o Acquire::Retries=5 install qemu-system-x86
- name: Demo Test - BareMetal Starter
run: dotnet bin/Mosa.Tool.Launcher.Console.dll bin/Mosa.BareMetal.Starter.x86.dll -o${{ matrix.optimization }} -check -test
run: dotnet bin/Mosa.Tool.Launcher.Console.dll bin/Mosa.BareMetal.Starter.x86.dll -o${{ matrix.optimization }} -check -test -output-counters
- name: Demo Test - BareMetal TestWorld
run: dotnet bin/Mosa.Tool.Launcher.Console.dll bin/Mosa.BareMetal.TestWorld.x86.dll -o${{ matrix.optimization }} -check -test
run: dotnet bin/Mosa.Tool.Launcher.Console.dll bin/Mosa.BareMetal.TestWorld.x86.dll -o${{ matrix.optimization }} -check -test -output-counters
- name: Demo Test - BareMetal HelloWorld
run: dotnet bin/Mosa.Tool.Launcher.Console.dll bin/Mosa.BareMetal.HelloWorld.x86.dll -o${{ matrix.optimization }} -check -test
run: dotnet bin/Mosa.Tool.Launcher.Console.dll bin/Mosa.BareMetal.HelloWorld.x86.dll -o${{ matrix.optimization }} -check -test -output-counters
- name: Demo Test - BareMetal CoolWorld
run: dotnet bin/Mosa.Tool.Launcher.Console.dll bin/Mosa.BareMetal.CoolWorld.x86.dll -o${{ matrix.optimization }} -check -test -vmware-svga -include bin/Include
run: dotnet bin/Mosa.Tool.Launcher.Console.dll bin/Mosa.BareMetal.CoolWorld.x86.dll -o${{ matrix.optimization }} -check -test -output-counters -vmware-svga -include bin/Include

macos-demo-testing:
strategy:
Expand All @@ -363,10 +363,10 @@ jobs:
name: macos-build-artifact
path: bin
- name: Demo Test - BareMetal Starter
run: dotnet bin/Mosa.Tool.Launcher.Console.dll bin/Mosa.BareMetal.Starter.x86.dll -o${{ matrix.optimization }} -check -test
run: dotnet bin/Mosa.Tool.Launcher.Console.dll bin/Mosa.BareMetal.Starter.x86.dll -o${{ matrix.optimization }} -check -test -output-counters
- name: Demo Test - BareMetal TestWorld
run: dotnet bin/Mosa.Tool.Launcher.Console.dll bin/Mosa.BareMetal.TestWorld.x86.dll -o${{ matrix.optimization }} -check -test
run: dotnet bin/Mosa.Tool.Launcher.Console.dll bin/Mosa.BareMetal.TestWorld.x86.dll -o${{ matrix.optimization }} -check -test -output-counters
- name: Demo Test - BareMetal HelloWorld
run: dotnet bin/Mosa.Tool.Launcher.Console.dll bin/Mosa.BareMetal.HelloWorld.x86.dll -o${{ matrix.optimization }} -check -test
run: dotnet bin/Mosa.Tool.Launcher.Console.dll bin/Mosa.BareMetal.HelloWorld.x86.dll -o${{ matrix.optimization }} -check -test -output-counters
- name: Demo Test - BareMetal CoolWorld
run: dotnet bin/Mosa.Tool.Launcher.Console.dll bin/Mosa.BareMetal.CoolWorld.x86.dll -o${{ matrix.optimization }} -check -test -vmware-svga -include bin/Include
run: dotnet bin/Mosa.Tool.Launcher.Console.dll bin/Mosa.BareMetal.CoolWorld.x86.dll -o${{ matrix.optimization }} -check -test -output-counters -vmware-svga -include bin/Include
50 changes: 50 additions & 0 deletions Source/Mosa.Compiler.Common/FileFinder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright (c) MOSA Project. Licensed under the New BSD License.

namespace Mosa.Compiler.Common;

public static class FileFinder
{
public static string Find(string file, IList<string> searchpaths)
{
if (File.Exists(file))
return file;

foreach (var path in searchpaths)
{
var fullpath = Path.Combine(path, file);

if (File.Exists(fullpath))
{
return fullpath;
}
}

return null;
}

public static string SearchSubdirectories(string path, string filename)
{
if (!Directory.Exists(path))
return null;

var enumerationOptions = new EnumerationOptions()
{
IgnoreInaccessible = true,
MaxRecursionDepth = 5,
RecurseSubdirectories = true,
MatchType = MatchType.Simple,
MatchCasing = MatchCasing.PlatformDefault,
ReturnSpecialDirectories = false,
AttributesToSkip = FileAttributes.ReparsePoint | FileAttributes.Device
};

var result = Directory.GetFiles(path, filename, enumerationOptions);

if (result?.Length >= 1)
{
return Path.GetDirectoryName(result[0]);
}

return null;
}
}
18 changes: 2 additions & 16 deletions Source/Mosa.Compiler.Framework/Compiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

using System.Diagnostics;
using System.Reflection;
using Mosa.Compiler.Common;
using Mosa.Compiler.Common.Exceptions;
using Mosa.Compiler.Framework.CompilerStages;
using Mosa.Compiler.Framework.Linker;
Expand Down Expand Up @@ -568,24 +569,9 @@ private void EmitCounters()
}
}

public string SearchPathsForFile(string filename)
{
foreach (var path in MosaSettings.SearchPaths)
{
var file = Path.Combine(path, filename);

if (File.Exists(file))
{
return file;
}
}

return null;
}

public byte[] SearchPathsForFileAndLoad(string filename)
{
var file = SearchPathsForFile(filename);
var file = FileFinder.Find(filename, MosaSettings.SearchPaths);

if (file == null)
return null;
Expand Down
5 changes: 4 additions & 1 deletion Source/Mosa.Compiler.MosaTypeSystem.CLR/ClrModuleLoader.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) MOSA Project. Licensed under the New BSD License.

using dnlib.DotNet;
using Mosa.Compiler.Common;
using Mosa.Compiler.MosaTypeSystem.CLR.Metadata;

namespace Mosa.Compiler.MosaTypeSystem.CLR;
Expand All @@ -24,7 +25,9 @@ public ClrModuleLoader()

public void LoadModuleFromFile(string file)
{
var module = ModuleDefMD.Load(file, Resolver.DefaultModuleContext);
var fullpath = FileFinder.Find(file, Resolver.PostSearchPaths);

var module = ModuleDefMD.Load(fullpath, Resolver.DefaultModuleContext);
module.EnableTypeDefFindCache = true;

LoadDependencies(module);
Expand Down
2 changes: 1 addition & 1 deletion Source/Mosa.Compiler.MosaTypeSystem/IModuleLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Mosa.Compiler.MosaTypeSystem;

public interface IModuleLoader : IDisposable
{
public void AddSearchPaths(List<string>? paths)
public void AddSearchPaths(List<string> paths)
{
if (paths == null)
return;
Expand Down
12 changes: 6 additions & 6 deletions Source/Mosa.Tool.Bootstrap/LauncherHunter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static void Hunt(IClassicDesktopStyleApplicationLifetime desktop, string[
Environment.Exit(0);
}

private static string? FindLauncher(string source)
private static string FindLauncher(string source)
{
var location = FindLauncherInCurrentDirectory();

Expand All @@ -57,12 +57,12 @@ public static void Hunt(IClassicDesktopStyleApplicationLifetime desktop, string[
return FindLauncherInGlobalCatalog(targetVersion);
}

private static string? FindLauncherInCurrentDirectory()
private static string FindLauncherInCurrentDirectory()
{
return CheckLauncher(Environment.CurrentDirectory);
}

private static string? CheckLauncher(string? directory)
private static string CheckLauncher(string? directory)
{
if (directory == null) return null;

Expand All @@ -71,15 +71,15 @@ public static void Hunt(IClassicDesktopStyleApplicationLifetime desktop, string[
return File.Exists(location) ? location : null;
}

private static string? FindLauncherInGlobalCatalog(FileVersionInfo? targetVersion)
private static string FindLauncherInGlobalCatalog(FileVersionInfo? targetVersion)
{
var userProfile = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
var globalPackageDirectory = Path.Combine(userProfile, GlobalPackageDirectory, ToolsPackage);

if (!Directory.Exists(globalPackageDirectory)) return null;

string? bestLocation = null;
FileVersionInfo? bestVersion = null;
FileVersionInfo bestVersion = null;

foreach (var directory in Directory.GetDirectories(globalPackageDirectory))
{
Expand Down Expand Up @@ -107,7 +107,7 @@ public static void Hunt(IClassicDesktopStyleApplicationLifetime desktop, string[
return bestLocation;
}

private static FileVersionInfo? GetIdealFileVersion(string directory)
private static FileVersionInfo GetIdealFileVersion(string directory)
{
var location = Path.Combine(directory, Korlib);

Expand Down
7 changes: 4 additions & 3 deletions Source/Mosa.Tool.Compiler/Compiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class Compiler
{
#region Data

private static Stopwatch Stopwatch = new Stopwatch();
private static readonly Stopwatch Stopwatch = new();

#endregion Data

Expand All @@ -32,7 +32,7 @@ public int Run(string[] args)
Console.WriteLine("MOSA Compiler, Version {0}.", CompilerVersion.VersionString);
Console.WriteLine("Copyright 2023 by the MOSA Project. Licensed under the New BSD License.");

OutputStatus($"Current Directory: {Environment.CurrentDirectory}");
//OutputStatus($"Current Directory: {Environment.CurrentDirectory}");

Stopwatch.Start();

Expand All @@ -45,8 +45,8 @@ public int Run(string[] args)
mosaSettings.LoadArguments(args);
SetRequiredSettings(mosaSettings);
mosaSettings.ExpandSearchPaths();
mosaSettings.NormalizeSettings();
mosaSettings.AddStandardPlugs();
mosaSettings.NormalizeSettings();
mosaSettings.UpdateFileAndPathSettings();

OutputStatus($"Compiling: {mosaSettings.SourceFiles[0]}");
Expand Down Expand Up @@ -75,6 +75,7 @@ public int Run(string[] args)
Debug.AutoFlush = true;

OutputStatus($"Input file(s): {string.Join(", ", new List<string>(compiler.MosaSettings.SourceFiles.ToArray()))}");
OutputStatus($"Search Folder(s): {string.Join(", ", new List<string>(compiler.MosaSettings.SearchPaths.ToArray()))}");
OutputStatus($"Output file: {compiler.MosaSettings.OutputFile}");
OutputStatus($"Platform: {compiler.MosaSettings.Platform}");

Expand Down
3 changes: 0 additions & 3 deletions Source/Mosa.Tool.Explorer/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1180,9 +1180,6 @@ private void UpdateSettings()

private void UpdateSettings(string filename)
{
var sourceDirectory = Path.GetDirectoryName(filename);
var fileHunter = new FileHunter(sourceDirectory);

// Source Files
MosaSettings.ClearSourceFiles();
MosaSettings.AddSourceFile(filename);
Expand Down
6 changes: 3 additions & 3 deletions Source/Mosa.Tool.Launcher.Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal static class Program
{
private static Builder Builder;

private static Stopwatch Stopwatch = new Stopwatch();
private static readonly Stopwatch Stopwatch = new();

internal static int Main(string[] args)
{
Expand All @@ -20,7 +20,7 @@ internal static int Main(string[] args)
System.Console.WriteLine("MOSA Launcher, Version {0}.", CompilerVersion.VersionString);
System.Console.WriteLine("Copyright 2023 by the MOSA Project. Licensed under the New BSD License.");

OutputStatus($"Current Directory: {Environment.CurrentDirectory}");
//OutputStatus($"Current Directory: {Environment.CurrentDirectory}");

Stopwatch.Start();

Expand All @@ -33,8 +33,8 @@ internal static int Main(string[] args)
mosaSettings.LoadArguments(args);
SetRequiredSettings(mosaSettings);
mosaSettings.ExpandSearchPaths();
mosaSettings.NormalizeSettings();
mosaSettings.AddStandardPlugs();
mosaSettings.NormalizeSettings();
mosaSettings.UpdateFileAndPathSettings();

var compilerHooks = CreateCompilerHooks();
Expand Down
10 changes: 7 additions & 3 deletions Source/Mosa.Tool.Launcher/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ public void Initialize(string[] args)
mosaSettings.LoadArguments(args);
SetRequiredSettings();
mosaSettings.ExpandSearchPaths();
mosaSettings.NormalizeSettings();
mosaSettings.AddStandardPlugs();
mosaSettings.NormalizeSettings();
mosaSettings.UpdateFileAndPathSettings();

UpdateGuiSettings();
Expand All @@ -80,11 +80,12 @@ public void Initialize(string[] args)
}

OutputStatus($"Arguments: {sb}");
OutputStatus($"Current Directory: {Environment.CurrentDirectory}");
//OutputStatus($"Current Directory: {Environment.CurrentDirectory}");

if (mosaSettings.SourceFiles is { Count: > 0 })
{
var src = mosaSettings.SourceFiles[0];

if (!string.IsNullOrEmpty(src))
{
OsNameTxt.Text = Path.GetFileNameWithoutExtension(src);
Expand All @@ -94,7 +95,10 @@ public void Initialize(string[] args)
foreach (var file in mosaSettings.SourceFiles)
{
var path = Path.GetDirectoryName(Path.GetFullPath(file));
if (!string.IsNullOrWhiteSpace(path)) mosaSettings.AddSearchPath(path);
if (!string.IsNullOrWhiteSpace(path))
{
mosaSettings.AddSearchPath(path);
}
}
}
else mosaSettings.ExplorerStart = false;
Expand Down
2 changes: 1 addition & 1 deletion Source/Mosa.Utility.Configuration/MOSASettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ public void ExpandSearchPaths()

if (!string.IsNullOrWhiteSpace(path))
{
Settings.AddPropertyListValueIfNew("SearchPaths", path);
AddSearchPath(path);
}
}
}
Expand Down
Loading

0 comments on commit 20dcd99

Please sign in to comment.