mirror of
https://github.com/FabInfra/capnproto-dotnetcore_Runtime.git
synced 2025-03-12 14:51:41 +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);
|
||||
}
|
||||
|
||||
internal static bool IsCapnpExeInstalled()
|
||||
internal static bool IsCapnpInstalled()
|
||||
{
|
||||
using (var process = Process.Start("where", "capnp.exe"))
|
||||
try
|
||||
{
|
||||
if (process == null)
|
||||
Assert.Fail("Unable to start 'where'");
|
||||
var startInfo = new ProcessStartInfo(CapnpCompilation.CapnpCompilerFilename, "--version");
|
||||
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();
|
||||
|
||||
return process.ExitCode == 0;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[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")]
|
||||
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")]
|
||||
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(
|
||||
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);
|
||||
|
||||
|
@ -4,6 +4,7 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
[assembly: InternalsVisibleTo("CapnpC.CSharp.Generator.Tests")]
|
||||
@ -15,6 +16,14 @@ namespace CapnpC.CSharp.Generator
|
||||
/// </summary>
|
||||
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>
|
||||
/// Generates C# code from given input stream
|
||||
/// </summary>
|
||||
@ -60,7 +69,7 @@ namespace CapnpC.CSharp.Generator
|
||||
argList.Add($"-o-");
|
||||
argList.AddRange(arguments);
|
||||
|
||||
compiler.StartInfo.FileName = "capnp.exe";
|
||||
compiler.StartInfo.FileName = CapnpCompilerFilename;
|
||||
compiler.StartInfo.Arguments = string.Join(" ", argList);
|
||||
compiler.StartInfo.UseShellExecute = false;
|
||||
compiler.StartInfo.RedirectStandardOutput = true;
|
||||
|
@ -210,7 +210,7 @@
|
||||
|
||||
cu = cu.AddMembers(ns);
|
||||
|
||||
return cu.NormalizeWhitespace().ToFullString();
|
||||
return cu.NormalizeWhitespace(" ", Environment.NewLine).ToFullString();
|
||||
}
|
||||
|
||||
public IReadOnlyList<FileGenerationResult> Generate()
|
||||
|
@ -107,7 +107,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="rmdir /s /q $(SolutionDir)MsBuildGenerationTest\obj" />
|
||||
<RemoveDir Directories="$(SolutionDir)\MsBuildGenerationTest\obj" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
Loading…
x
Reference in New Issue
Block a user