mirror of
https://github.com/FabInfra/capnproto-dotnetcore_Runtime.git
synced 2025-03-13 07:11:44 +01:00
capnp fixes for Linux
This commit is contained in:
parent
233d9b5e84
commit
bba92d589e
@ -27,18 +27,29 @@ namespace CapnpC.CSharp.Generator.Tests
|
|||||||
return assembly.GetManifestResourceStream(urn);
|
return assembly.GetManifestResourceStream(urn);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static bool IsCapnpExeInstalled()
|
internal static bool IsCapnpInstalled()
|
||||||
{
|
{
|
||||||
using (var process = Process.Start("where", "capnp.exe"))
|
try
|
||||||
{
|
{
|
||||||
if (process == null)
|
var startInfo = new ProcessStartInfo(CapnpCompilation.CapnpCompilerFilename, "--version");
|
||||||
Assert.Fail("Unable to start 'where'");
|
startInfo.UseShellExecute = false;
|
||||||
|
startInfo.RedirectStandardOutput = true;
|
||||||
|
startInfo.RedirectStandardError = true;
|
||||||
|
|
||||||
|
using (var process = Process.Start(startInfo))
|
||||||
|
{
|
||||||
|
Assert.IsNotNull(process, $"Unable to start '{CapnpCompilation.CapnpCompilerFilename}'");
|
||||||
|
|
||||||
process.WaitForExit();
|
process.WaitForExit();
|
||||||
|
|
||||||
return process.ExitCode == 0;
|
return process.ExitCode == 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Given(@"I have a binary code generator request ""(.*)""")]
|
[Given(@"I have a binary code generator request ""(.*)""")]
|
||||||
[Given(@"I have a binary code generator request (.*)")]
|
[Given(@"I have a binary code generator request (.*)")]
|
||||||
@ -112,9 +123,9 @@ namespace CapnpC.CSharp.Generator.Tests
|
|||||||
[Given(@"capnp\.exe is installed on my system")]
|
[Given(@"capnp\.exe is installed on my system")]
|
||||||
public void GivenCapnp_ExeIsInstalledOnMySystem()
|
public void GivenCapnp_ExeIsInstalledOnMySystem()
|
||||||
{
|
{
|
||||||
if (!IsCapnpExeInstalled())
|
if (!IsCapnpInstalled())
|
||||||
{
|
{
|
||||||
Assert.Inconclusive("capnp.exe not found. Precondition of this test is not met.");
|
Assert.Inconclusive("Capnp compiler not found. Precondition of this test is not met.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,9 +162,9 @@ namespace CapnpC.CSharp.Generator.Tests
|
|||||||
[Given(@"capnp\.exe is not installed on my system")]
|
[Given(@"capnp\.exe is not installed on my system")]
|
||||||
public void GivenCapnp_ExeIsNotInstalledOnMySystem()
|
public void GivenCapnp_ExeIsNotInstalledOnMySystem()
|
||||||
{
|
{
|
||||||
if (IsCapnpExeInstalled())
|
if (IsCapnpInstalled())
|
||||||
{
|
{
|
||||||
Assert.Inconclusive("capnp.exe found. Precondition of this test is not met.");
|
Assert.Inconclusive("Capnp compiler found. Precondition of this test is not met.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,12 @@ namespace CapnpC.CSharp.Generator.Tests.Util
|
|||||||
|
|
||||||
string capnpRuntimePath = Path.GetFullPath(Path.Combine(
|
string capnpRuntimePath = Path.GetFullPath(Path.Combine(
|
||||||
Assembly.GetExecutingAssembly().Location,
|
Assembly.GetExecutingAssembly().Location,
|
||||||
@"..\..\..\..\..\Capnp.Net.Runtime\bin\Debug\netcoreapp2.1\Capnp.Net.Runtime.dll"));
|
"..", "..", "..", "..", "..",
|
||||||
|
"Capnp.Net.Runtime",
|
||||||
|
"bin",
|
||||||
|
"Debug",
|
||||||
|
"netcoreapp2.1",
|
||||||
|
"Capnp.Net.Runtime.dll"));
|
||||||
|
|
||||||
var capnpRuntimeMetadataRef = MetadataReference.CreateFromFile(capnpRuntimePath);
|
var capnpRuntimeMetadataRef = MetadataReference.CreateFromFile(capnpRuntimePath);
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ using System.Collections.Generic;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
[assembly: InternalsVisibleTo("CapnpC.CSharp.Generator.Tests")]
|
[assembly: InternalsVisibleTo("CapnpC.CSharp.Generator.Tests")]
|
||||||
@ -15,6 +16,14 @@ namespace CapnpC.CSharp.Generator
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static class CapnpCompilation
|
public static class CapnpCompilation
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the basename of the capnp executable
|
||||||
|
/// </summary>
|
||||||
|
public static string CapnpCompilerFilename
|
||||||
|
{
|
||||||
|
get => RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "capnp.exe" : "capnp";
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generates C# code from given input stream
|
/// Generates C# code from given input stream
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -60,7 +69,7 @@ namespace CapnpC.CSharp.Generator
|
|||||||
argList.Add($"-o-");
|
argList.Add($"-o-");
|
||||||
argList.AddRange(arguments);
|
argList.AddRange(arguments);
|
||||||
|
|
||||||
compiler.StartInfo.FileName = "capnp.exe";
|
compiler.StartInfo.FileName = CapnpCompilerFilename;
|
||||||
compiler.StartInfo.Arguments = string.Join(" ", argList);
|
compiler.StartInfo.Arguments = string.Join(" ", argList);
|
||||||
compiler.StartInfo.UseShellExecute = false;
|
compiler.StartInfo.UseShellExecute = false;
|
||||||
compiler.StartInfo.RedirectStandardOutput = true;
|
compiler.StartInfo.RedirectStandardOutput = true;
|
||||||
|
@ -210,7 +210,7 @@
|
|||||||
|
|
||||||
cu = cu.AddMembers(ns);
|
cu = cu.AddMembers(ns);
|
||||||
|
|
||||||
return cu.NormalizeWhitespace().ToFullString();
|
return cu.NormalizeWhitespace(" ", Environment.NewLine).ToFullString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IReadOnlyList<FileGenerationResult> Generate()
|
public IReadOnlyList<FileGenerationResult> Generate()
|
||||||
|
@ -107,7 +107,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
<Exec Command="rmdir /s /q $(SolutionDir)MsBuildGenerationTest\obj" />
|
<RemoveDir Directories="$(SolutionDir)\MsBuildGenerationTest\obj" />
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
Loading…
x
Reference in New Issue
Block a user