Skip to content

Commit

Permalink
[.NET] Update Cantera.csproj to simplify setting up dev environment
Browse files Browse the repository at this point in the history
We’re able to use the same basic native library name (“cantera_shared”) on all systems and copy that native library and example data files directly from the upstream SCons build output and data directory.
  • Loading branch information
burkenyo authored and speth committed Aug 17, 2022
1 parent fd29c09 commit 8859643
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 25 deletions.
3 changes: 0 additions & 3 deletions interfaces/dotnet/.gitignore
Expand Up @@ -35,6 +35,3 @@ msbuild.wrn

# Visual Studio 2015
.vs/

lib/
content/
29 changes: 14 additions & 15 deletions interfaces/dotnet/Cantera/Cantera.csproj
Expand Up @@ -11,26 +11,24 @@
<IsPackable>false</IsPackable>
<GenerateDocumentationFile>true</GenerateDocumentationFile>

<LibDir>$([MSBuild]::NormalizePath($(MSBuildProjectDirectory)/../lib))</LibDir>
<ContentDir>$([MSBuild]::NormalizePath($(MSBuildProjectDirectory)/../content))</ContentDir>
</PropertyGroup>

<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">
<DefineConstants>IS_WINDOWS</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">
<DefineConstants>IS_MACOS</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">
<DefineConstants>IS_LINUX</DefineConstants>
<LibDir>$([MSBuild]::NormalizePath($(MSBuildProjectDirectory)/../../../build/lib))</LibDir>
<DataDir>$([MSBuild]::NormalizePath($(MSBuildProjectDirectory)/../../../data))</DataDir>
</PropertyGroup>

<ItemGroup>
<InternalsVisibleTo Include="Cantera.Tests" />

<None Include="$(LibDir)/*" CopyToOutputDirectory="PreserveNewest"/>
<None Include="$(DataDir)/*" CopyToOutputDirectory="PreserveNewest" LinkBase="data/" />
</ItemGroup>

<None Include="$(ContentDir)/**" CopyToOutputDirectory="PreserveNewest"/>
<ItemGroup Condition="$([MSBuild]::IsOsPlatform(Windows))">
<None Include="$(LibDir)/cantera_shared.dll" CopyToOutputDirectory="PreserveNewest"/>
</ItemGroup>
<ItemGroup Condition="$([MSBuild]::IsOsPlatform(OSX))">
<None Include="$(LibDir)/libcantera_shared.dylib" CopyToOutputDirectory="PreserveNewest"/>
</ItemGroup>
<ItemGroup Condition="$([MSBuild]::IsOsPlatform(Linux))">
<None Include="$(LibDir)/libcantera_shared.so" CopyToOutputDirectory="PreserveNewest"/>
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
Expand All @@ -47,7 +45,8 @@
<GeneratedPath>$([MSBuild]::NormalizePath($(IntermediateOutputPath)/sourcegen/))</GeneratedPath>
</PropertyGroup>

<Exec Command="python3 $(Script) csharp $(GeneratedPath)" Condition="'$(GenerateInterop)' == 'true' Or !Exists('$(GeneratedPath)')"/>
<Exec Command="python3 $(Script) csharp $(GeneratedPath)"
Condition="'$(GenerateInterop)' == 'true' Or !Exists('$(GeneratedPath)')"/>

<ItemGroup>
<Compile Remove="$(GeneratedPath)*.cs" />
Expand Down
8 changes: 1 addition & 7 deletions interfaces/dotnet/Cantera/src/Interop/LibCantera.cs
Expand Up @@ -5,13 +5,7 @@ namespace Cantera.Interop;

static partial class LibCantera
{
#if IS_WINDOWS
const string LibFile = "cantera.3.0.0.dll";
#elif IS_MACOS
const string LibFile = "cantera.3.0.0.dylib";
#elif IS_LINUX
const string LibFile = "cantera.3.0.0.so";
#endif
const string LibFile = "cantera_shared";

public delegate void LogCallback(LogLevel logLevel, string category, string message);
}

0 comments on commit 8859643

Please sign in to comment.