Skip to content

Commit

Permalink
fix and cleanup
Browse files Browse the repository at this point in the history
k-ujihara committed Jan 26, 2021
1 parent 71be5db commit 7d1e734
Showing 12 changed files with 500 additions and 299 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -17,18 +17,18 @@
- [CMAKE 3.12.18081601-MSVC_2](https://cmake.org/)
- [SWIG 4.0.2](http://www.swig.org/)
- [NuGet 5.3.1](https://nuget.org)
- Ubuntu 18.4 on WSL2
- Ubuntu 20.04.1 LTS on WSL2
- Visual Studio 2019

## How to Build

### Preparation

- Use Windows 10 (x64).
- Install Ubuntu 18.4 on WSL2 and install dotnet, boost, cairo, cmake, and swig.
- Install Ubuntu 18.4 on WSL2 and install `dotnet`, `boost`, `cairo`, `cmake`, and `swig`.
- Install Visual Studio 2019 enabling C++, C# and CMAKE.
- Install Python.
- Clone this repository to some directory. A name of the directory including path should be short. It is highly recommended to place it under 'C:\' folder.
- Clone this repository to some directory. A name of the directory including path should be short. It is highly recommended to place it under 'C:\'.
- Download the following source archives and extract them here.
- [RDKit](hhttps://github.com/rdkit/rdkit/) to `rdkit-Release_####_##_#`.
- [Eigen3](http://eigen.tuxfamily.org/) to `eigen-#.#.#`.
@@ -63,7 +63,7 @@
- Execute `python .\build_rdkit_csharp.py --build_libpng --build_platform all` to make libpng.
- Execute `python .\build_rdkit_csharp.py --build_pixman --build_platform all` to make pixman.
- Execute `python .\build_rdkit_csharp.py --build_cairo --build_platform all` to make cairo.
- Execute `python .\build_rdkit_csharp.py --build_rdkit --build_platform all` to patch RDKit and make it.
- Execute `python .\build_rdkit_csharp.py --build_wrapper` to make rdkit .NET wrapper and patch it.
- C# project file is created in `rdkit-Release_####_##_#/Code/JavaWrappers/csharp_wrapper/RDKit2DotNet.csproj`.
- Execute `python .\build_rdkit_csharp.py --build_nuget` to make NuGet package.
- Execute `python .\build_rdkit_csharp.py --build_rdkit --build_platform all` to make RDKit for Windows.
- Execute `wsl bash build_rdkit.sh` to make RDKit for Linux.
- Execute `python .\build_rdkit_csharp.py --build_wrapper` to make RDKit .NET wrapper.
- Execute `python .\build_rdkit_csharp.py --build_nuget` to make NuGet package, which includes both Windows and Linux versions.
4 changes: 2 additions & 2 deletions build_all.bat
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ python .\build_rdkit_csharp.py --build_freetype --build_zlib --build_libpng --bu
wsl bash build_rdkit.sh
@if errorlevel 1 goto :ERROREND

python .\build_rdkit_csharp.py --build_wrapper --build_nuget --build_platform all
python .\build_rdkit_csharp.py --build_wrapper --build_nuget
@if errorlevel 1 goto :ERROREND

@goto :END
@@ -19,7 +19,7 @@ python .\build_rdkit_csharp.py --build_wrapper --build_nuget --build_platform a
exit /b 1

:CL_NOT_FOUND
@echo cl is not found. Execute 'Developer Command Prompt for VS 2017' first.
@echo cl is not found. Execute 'Developer Command Prompt for VS 2019' first.
exit /b 1

:END
529 changes: 286 additions & 243 deletions build_rdkit_csharp.py

Large diffs are not rendered by default.

51 changes: 51 additions & 0 deletions files/rdkit/NuGetExample.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30907.101
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NuGetExample", "NuGetExample\NuGetExample.csproj", "{A10F2BB4-92DE-428A-9E26-8B65D2F589B2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NuGetExample2", "NuGetExample2\NuGetExample2.csproj", "{E727FFA2-B4B7-467A-9F36-0669D1688A12}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A10F2BB4-92DE-428A-9E26-8B65D2F589B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A10F2BB4-92DE-428A-9E26-8B65D2F589B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A10F2BB4-92DE-428A-9E26-8B65D2F589B2}.Debug|x64.ActiveCfg = Debug|x64
{A10F2BB4-92DE-428A-9E26-8B65D2F589B2}.Debug|x64.Build.0 = Debug|x64
{A10F2BB4-92DE-428A-9E26-8B65D2F589B2}.Debug|x86.ActiveCfg = Debug|x86
{A10F2BB4-92DE-428A-9E26-8B65D2F589B2}.Debug|x86.Build.0 = Debug|x86
{A10F2BB4-92DE-428A-9E26-8B65D2F589B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A10F2BB4-92DE-428A-9E26-8B65D2F589B2}.Release|Any CPU.Build.0 = Release|Any CPU
{A10F2BB4-92DE-428A-9E26-8B65D2F589B2}.Release|x64.ActiveCfg = Release|x64
{A10F2BB4-92DE-428A-9E26-8B65D2F589B2}.Release|x64.Build.0 = Release|x64
{A10F2BB4-92DE-428A-9E26-8B65D2F589B2}.Release|x86.ActiveCfg = Release|x86
{A10F2BB4-92DE-428A-9E26-8B65D2F589B2}.Release|x86.Build.0 = Release|x86
{E727FFA2-B4B7-467A-9F36-0669D1688A12}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E727FFA2-B4B7-467A-9F36-0669D1688A12}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E727FFA2-B4B7-467A-9F36-0669D1688A12}.Debug|x64.ActiveCfg = Debug|x64
{E727FFA2-B4B7-467A-9F36-0669D1688A12}.Debug|x64.Build.0 = Debug|x64
{E727FFA2-B4B7-467A-9F36-0669D1688A12}.Debug|x86.ActiveCfg = Debug|x86
{E727FFA2-B4B7-467A-9F36-0669D1688A12}.Debug|x86.Build.0 = Debug|x86
{E727FFA2-B4B7-467A-9F36-0669D1688A12}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E727FFA2-B4B7-467A-9F36-0669D1688A12}.Release|Any CPU.Build.0 = Release|Any CPU
{E727FFA2-B4B7-467A-9F36-0669D1688A12}.Release|x64.ActiveCfg = Release|x64
{E727FFA2-B4B7-467A-9F36-0669D1688A12}.Release|x64.Build.0 = Release|x64
{E727FFA2-B4B7-467A-9F36-0669D1688A12}.Release|x86.ActiveCfg = Release|x86
{E727FFA2-B4B7-467A-9F36-0669D1688A12}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E87277B8-C35A-44F9-80BF-F0DAB348D76D}
EndGlobalSection
EndGlobal
39 changes: 39 additions & 0 deletions files/rdkit/NuGetExample/NuGetExample.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<Platforms>AnyCPU;x64;x86</Platforms>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\RDKit2DotNetTest\Program.cs" Link="Program.cs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="RDKit.DotNetWrap" Version="0.2020093.4" />
</ItemGroup>

<ItemGroup>
<Folder Include="Data\" />
</ItemGroup>

<ItemGroup>
<None Include="..\RDKit2DotNetTest\Data\5ht3ligs.sdf" Link="Data\5ht3ligs.sdf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\RDKit2DotNetTest\Data\5ht3ligs.sdf_cdk.index" Link="Data\5ht3ligs.sdf_cdk.index">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\RDKit2DotNetTest\Data\actives_5ht3.sdf" Link="Data\actives_5ht3.sdf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\RDKit2DotNetTest\Data\actives_5ht3.sdf.gz" Link="Data\actives_5ht3.sdf.gz">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\RDKit2DotNetTest\Data\input.mol" Link="Data\input.mol">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
51 changes: 51 additions & 0 deletions files/rdkit/NuGetExample2/NuGetExample2.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net40</TargetFramework>
<Platforms>AnyCPU;x64;x86</Platforms>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\RDKit2DotNetTest\Program.cs" Link="Program.cs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="RDKit.DotNetWrap" Version="0.2020093.4" />
</ItemGroup>

<ItemGroup>
<Folder Include="Data\" />
</ItemGroup>

<ItemGroup>
<None Include="..\RDKit2DotNetTest\Data\5ht3ligs.sdf" Link="Data\5ht3ligs.sdf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\RDKit2DotNetTest\Data\5ht3ligs.sdf_cdk.index" Link="Data\5ht3ligs.sdf_cdk.index">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\RDKit2DotNetTest\Data\actives_5ht3.sdf" Link="Data\actives_5ht3.sdf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\RDKit2DotNetTest\Data\actives_5ht3.sdf.gz" Link="Data\actives_5ht3.sdf.gz">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\RDKit2DotNetTest\Data\input.mol" Link="Data\input.mol">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
45 changes: 21 additions & 24 deletions files/rdkit/RDKFuncsPINVOKE_Loader.cs
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ namespace GraphMolWrap
{
partial class RDKFuncsPINVOKE
{
#if NETFRAMEWORK
private const string ModuleName = "RDKFuncs";

[System.Security.SuppressUnmanagedCodeSecurity]
@@ -14,43 +15,41 @@ internal static class UnsafeNativeMethods
[DllImport("kernel32", CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern bool SetDllDirectory(string lpPathName);
}
#endif

internal static void LoadDll()
{
#if NETFRAMEWORK
var os = Environment.OSVersion;
switch (os.Platform)
{
case PlatformID.Win32NT:
const string DllFileName = ModuleName + ".dll";
var _subdir = Environment.Is64BitProcess ? "x64" : "x86";
var cpu = Environment.Is64BitProcess ? "x64" : "x86";
var executingAsm = System.Reflection.Assembly.GetExecutingAssembly();
foreach (var ss in new[] { null, "nt"})
foreach (var subdir in new[] {
cpu,
Path.Combine("runtimes", $"win-{cpu}", "native"),
})
{
var subdir = ss == null ? _subdir : Path.Combine("nt", _subdir);
if (SetDllDirectoryIfFileExist(Path.GetDirectoryName(executingAsm.Location), subdir, DllFileName))
break;
// for ASP.NET
var uri = new Uri(executingAsm.CodeBase);
if (uri.Scheme == "file")
{
var currPath = Path.GetDirectoryName(executingAsm.Location);
if (SetDllDirectoryIfFileExist(currPath, subdir, DllFileName))
goto L_Found;
}
{
// for ASP.NET
var uri = new Uri(executingAsm.CodeBase);
if (uri.Scheme == "file")
{
var currPath = Path.GetDirectoryName(uri.AbsolutePath);
if (SetDllDirectoryIfFileExist(currPath, subdir, DllFileName))
goto L_Found;
}
if (SetDllDirectoryIfFileExist(Path.GetDirectoryName(uri.AbsolutePath), subdir, DllFileName))
break;
}
}

L_Found:
break;
default:
break;
}
#endif
}

#if NETFRAMEWORK
/// <summary>
/// SetDllDirectory if <paramref name="directoryName"/>/<paramref name="subdir"/>/<paramref name="dllName"/> or <paramref name="directoryName"/>/<paramref name="dllName"/>exists.
/// </summary>
@@ -60,11 +59,8 @@ internal static void LoadDll()
/// <returns><see langword="true"/> if file exists and set it.</returns>
private static bool SetDllDirectoryIfFileExist(string directoryName, string subdir, string dllName)
{
if (subdir != null)
{
if (SetDllDirectoryIfFileExist(Path.Combine(directoryName, subdir), dllName))
return true;
}
if (SetDllDirectoryIfFileExist(Path.Combine(directoryName, subdir), dllName))
return true;

if (SetDllDirectoryIfFileExist(directoryName, dllName))
return true;
@@ -88,6 +84,7 @@ private static bool SetDllDirectoryIfFileExist(string directoryName, string dllN
return true;
}
return false;
}
}
#endif
}
}
28 changes: 7 additions & 21 deletions files/rdkit/RDKit2DotNet.sln
Original file line number Diff line number Diff line change
@@ -5,42 +5,28 @@ VisualStudioVersion = 16.0.30907.101
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RDKit2DotNet", "RDKit2DotNet\RDKit2DotNet.csproj", "{D6166F1C-DCD1-4E57-B002-4B6869130E43}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RDKit2DotNetTest", "RDKit2DotNetTest\RDKit2DotNetTest.csproj", "{E7DF7657-90D6-4C7F-A430-A48737C049B2}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RDKit2DotNetTest", "RDKit2DotNetTest\RDKit2DotNetTest.csproj", "{E7DF7657-90D6-4C7F-A430-A48737C049B2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RDKit2DotNetTest2", "RDKit2DotNetTest2\RDKit2DotNetTest2.csproj", "{4FF1CAED-C58F-43D0-A5CA-24959A52B9CB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D6166F1C-DCD1-4E57-B002-4B6869130E43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D6166F1C-DCD1-4E57-B002-4B6869130E43}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D6166F1C-DCD1-4E57-B002-4B6869130E43}.Debug|x64.ActiveCfg = Debug|Any CPU
{D6166F1C-DCD1-4E57-B002-4B6869130E43}.Debug|x64.Build.0 = Debug|Any CPU
{D6166F1C-DCD1-4E57-B002-4B6869130E43}.Debug|x86.ActiveCfg = Debug|Any CPU
{D6166F1C-DCD1-4E57-B002-4B6869130E43}.Debug|x86.Build.0 = Debug|Any CPU
{D6166F1C-DCD1-4E57-B002-4B6869130E43}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D6166F1C-DCD1-4E57-B002-4B6869130E43}.Release|Any CPU.Build.0 = Release|Any CPU
{D6166F1C-DCD1-4E57-B002-4B6869130E43}.Release|x64.ActiveCfg = Release|Any CPU
{D6166F1C-DCD1-4E57-B002-4B6869130E43}.Release|x64.Build.0 = Release|Any CPU
{D6166F1C-DCD1-4E57-B002-4B6869130E43}.Release|x86.ActiveCfg = Release|Any CPU
{D6166F1C-DCD1-4E57-B002-4B6869130E43}.Release|x86.Build.0 = Release|Any CPU
{E7DF7657-90D6-4C7F-A430-A48737C049B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E7DF7657-90D6-4C7F-A430-A48737C049B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E7DF7657-90D6-4C7F-A430-A48737C049B2}.Debug|x64.ActiveCfg = Debug|Any CPU
{E7DF7657-90D6-4C7F-A430-A48737C049B2}.Debug|x64.Build.0 = Debug|Any CPU
{E7DF7657-90D6-4C7F-A430-A48737C049B2}.Debug|x86.ActiveCfg = Debug|Any CPU
{E7DF7657-90D6-4C7F-A430-A48737C049B2}.Debug|x86.Build.0 = Debug|Any CPU
{E7DF7657-90D6-4C7F-A430-A48737C049B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E7DF7657-90D6-4C7F-A430-A48737C049B2}.Release|Any CPU.Build.0 = Release|Any CPU
{E7DF7657-90D6-4C7F-A430-A48737C049B2}.Release|x64.ActiveCfg = Release|Any CPU
{E7DF7657-90D6-4C7F-A430-A48737C049B2}.Release|x64.Build.0 = Release|Any CPU
{E7DF7657-90D6-4C7F-A430-A48737C049B2}.Release|x86.ActiveCfg = Release|Any CPU
{E7DF7657-90D6-4C7F-A430-A48737C049B2}.Release|x86.Build.0 = Release|Any CPU
{4FF1CAED-C58F-43D0-A5CA-24959A52B9CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4FF1CAED-C58F-43D0-A5CA-24959A52B9CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4FF1CAED-C58F-43D0-A5CA-24959A52B9CB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4FF1CAED-C58F-43D0-A5CA-24959A52B9CB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions files/rdkit/RDKit2DotNetTest/RDKit2DotNetTest.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
34 changes: 34 additions & 0 deletions files/rdkit/RDKit2DotNetTest2/RDKit2DotNetTest2.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net40</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\RDKit2DotNet\RDKit2DotNet.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\RDKit2DotNetTest\Program.cs" Link="Program.cs" />
</ItemGroup>

<ItemGroup>
<None Update="Data\5ht3ligs.sdf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Data\5ht3ligs.sdf_cdk.index">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Data\actives_5ht3.sdf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Data\actives_5ht3.sdf.gz">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Data\input.mol">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>

0 comments on commit 7d1e734

Please sign in to comment.