diff --git a/oneware-extension.json b/oneware-extension.json index 5c7febb..3546315 100644 --- a/oneware-extension.json +++ b/oneware-extension.json @@ -47,6 +47,27 @@ "url": "https://github.com/ProtopSolutions/OneWare.Vhdp/releases/download/0.3/OneWare.VhdpExtension_0.3_osx-arm64.zip" } ] + }, + { + "version": "0.4", + "targets": [ + { + "target": "win-x64", + "url": "https://github.com/ProtopSolutions/OneWare.Vhdp/releases/download/0.4/OneWare.VhdpExtension_0.4_win-x64.zip" + }, + { + "target": "linux-x64", + "url": "https://github.com/ProtopSolutions/OneWare.Vhdp/releases/download/0.4/OneWare.VhdpExtension_0.4_linux-x64.zip" + }, + { + "target": "osx-x64", + "url": "https://github.com/ProtopSolutions/OneWare.Vhdp/releases/download/0.4/OneWare.VhdpExtension_0.4_osx-x64.zip" + }, + { + "target": "osx-arm64", + "url": "https://github.com/ProtopSolutions/OneWare.Vhdp/releases/download/0.4/OneWare.VhdpExtension_0.4_osx-arm64.zip" + } + ] } ] } diff --git a/src/OneWare.Vhdp/Assets/Templates/VhdpBlink/%PROJECTNAME%.vhdp b/src/OneWare.Vhdp/Assets/Templates/VhdpBlink/%PROJECTNAME%.vhdp new file mode 100644 index 0000000..a3fb19f --- /dev/null +++ b/src/OneWare.Vhdp/Assets/Templates/VhdpBlink/%PROJECTNAME%.vhdp @@ -0,0 +1,16 @@ +Main +( + led: OUT STD_LOGIC := '0'; +) +{ + Process() + { + Thread + { + led <= '0'; + Wait(250ms); + led <= '1'; + Wait(250ms); + } + } +} \ No newline at end of file diff --git a/src/OneWare.Vhdp/HdpProjectContext.cs b/src/OneWare.Vhdp/HdpProjectContext.cs index 5888aeb..4859369 100644 --- a/src/OneWare.Vhdp/HdpProjectContext.cs +++ b/src/OneWare.Vhdp/HdpProjectContext.cs @@ -37,7 +37,8 @@ public void Deactivate() public void ProcessChanges(string fullPath, Container changes) { - _documents[fullPath] = ApplyChanges(_documents[fullPath], changes); + if (_documents.TryGetValue(fullPath, out string? value)) + _documents[fullPath] = ApplyChanges(value, changes); } private static string ApplyChanges(string document, IEnumerable changes) @@ -164,7 +165,7 @@ public void AddPath(string fullPath) public void RemovePath(string fullPath) { - if (_projectRoot?.Search(fullPath) is { } entry) + if (_projectRoot?.SearchFullPath(fullPath) is { } entry) { _analyzerContexts.Remove(fullPath); } diff --git a/src/OneWare.Vhdp/OneWare.Vhdp.csproj b/src/OneWare.Vhdp/OneWare.Vhdp.csproj index cd81bcc..2c766e0 100644 --- a/src/OneWare.Vhdp/OneWare.Vhdp.csproj +++ b/src/OneWare.Vhdp/OneWare.Vhdp.csproj @@ -1,7 +1,7 @@  - 0.3 + 0.4 net8.0 enable enable @@ -12,12 +12,15 @@ - + + + PreserveNewest + - - + + diff --git a/src/OneWare.Vhdp/OneWareVhdpModule.cs b/src/OneWare.Vhdp/OneWareVhdpModule.cs index 5171fc0..b2635cd 100644 --- a/src/OneWare.Vhdp/OneWareVhdpModule.cs +++ b/src/OneWare.Vhdp/OneWareVhdpModule.cs @@ -1,6 +1,8 @@ using OneWare.Essentials.Models; using OneWare.Essentials.Services; using OneWare.Essentials.ViewModels; +using OneWare.UniversalFpgaProjectSystem.Services; +using OneWare.Vhdp.Templates; using Prism.Ioc; using Prism.Modularity; @@ -18,5 +20,7 @@ public void OnInitialized(IContainerProvider containerProvider) containerProvider.Resolve().RegisterErrorSource("VHDP"); containerProvider.Resolve().RegisterService(typeof(LanguageServiceVhdp),true, ".vhdp"); + + containerProvider.Resolve().RegisterTemplate(); } } \ No newline at end of file diff --git a/src/OneWare.Vhdp/Templates/VhdpBlinkTemplate.cs b/src/OneWare.Vhdp/Templates/VhdpBlinkTemplate.cs new file mode 100644 index 0000000..54e1f1e --- /dev/null +++ b/src/OneWare.Vhdp/Templates/VhdpBlinkTemplate.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Text.Json.Nodes; +using OneWare.Essentials.Services; +using OneWare.UniversalFpgaProjectSystem.Helpers; +using OneWare.UniversalFpgaProjectSystem.Models; +using OneWare.UniversalFpgaProjectSystem.Services; + +namespace OneWare.Vhdp.Templates; + +public class VhdpBlinkTemplate(ILogger logger, IDockService dockService) : IFpgaProjectTemplate +{ + public string Name => "VHDP Blink"; + + public void FillTemplate(UniversalFpgaProjectRoot root) + { + var codeBase = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? throw new NullReferenceException(Assembly.GetExecutingAssembly().Location); + + var path = Path.Combine(codeBase, "Assets", "Templates", "VhdpBlink"); + + try + { + var name = root.Header.Replace(" ", ""); + TemplateHelper.CopyDirectoryAndReplaceString(path, root.FullPath, ("%PROJECTNAME%", name)); + var file = root.AddFile(name + ".vhdp"); + root.TopEntity = file; + + root.IncludePath("*.vhdp"); + + _ = dockService.OpenFileAsync(file); + } + catch (Exception e) + { + logger.Error(e.Message, e); + } + } +} \ No newline at end of file diff --git a/src/OneWare.Vhdp/oneware.json b/src/OneWare.Vhdp/oneware.json index b90bbee..3a3937d 100644 --- a/src/OneWare.Vhdp/oneware.json +++ b/src/OneWare.Vhdp/oneware.json @@ -2,8 +2,13 @@ "Dependencies": [ { "Name": "OneWare.Essentials", - "MinVersion": "0.1.0.0", - "MaxVersion": "0.1.0.0" + "MinVersion": "0.4.3.0", + "MaxVersion": "0.4.3.0" + }, + { + "Name": "OneWare.UniversalFpgaProjectSystem", + "MinVersion": "0.16.4.0", + "MaxVersion": "0.16.4.0" } ] } \ No newline at end of file