diff options
author | vnugent <public@vaughnnugent.com> | 2024-05-07 17:01:22 -0400 |
---|---|---|
committer | vnugent <public@vaughnnugent.com> | 2024-05-07 17:01:22 -0400 |
commit | 79d824cfb0e0cc9ff4fab0e0c546a83c0edaae1c (patch) | |
tree | d69e962a15493b2e36882810a2cc43d5a0de1a0b /src/Modules/GitCodeModule.cs | |
parent | b3015399591bd81b8519f0efa2ec177163f7d04a (diff) |
initial commit
Diffstat (limited to 'src/Modules/GitCodeModule.cs')
-rw-r--r-- | src/Modules/GitCodeModule.cs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/Modules/GitCodeModule.cs b/src/Modules/GitCodeModule.cs new file mode 100644 index 0000000..630922d --- /dev/null +++ b/src/Modules/GitCodeModule.cs @@ -0,0 +1,42 @@ +using System.IO; +using System.Linq; +using System.Threading.Tasks; + +using VNLib.Tools.Build.Executor.Constants; +using VNLib.Tools.Build.Executor.Model; + +namespace VNLib.Tools.Build.Executor.Modules +{ + internal sealed class GitCodeModule : ModuleBase + { + private string _moduleName; + + public override IProjectExplorer ModuleExplorer { get; } + + public override string ModuleName => _moduleName; + + public GitCodeModule(BuildConfig config, DirectoryInfo root) + : base(config, root) + { + ModuleExplorer = new MsBuildModuleExplorer(config, this, root); + _moduleName = root.Name; //Default to dir name + } + + ///<inheritdoc/> + public override Task LoadAsync(TaskfileVars vars) + { + //Try to load a solution file in the top-level module directory + FileInfo? sln = WorkingDir.EnumerateFiles("*.sln", SearchOption.TopDirectoryOnly).FirstOrDefault(); + + if(sln is not null) + { + //Remove the .build extension from the solution file name for proper module name + _moduleName = Path.GetFileNameWithoutExtension(sln.Name).Replace(".build", string.Empty); + + vars.Set("SOLUTION_FILE_NAME", sln.Name); + } + + return base.LoadAsync(vars); + } + } +}
\ No newline at end of file |