Skip to content

Commit

Permalink
Added CppSharp submodule to reference required Marshal utilities.
Browse files Browse the repository at this point in the history
Updated for new netcoreapp3.1 version of CppSharp.
Updated for new pdfium-darwin-x64 and pdfium-darwin-arm64 packages.
  • Loading branch information
DJGosnell committed Feb 15, 2021
1 parent 3d311b1 commit 468e855
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 16 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "src/CppSharp"]
path = src/CppSharp
url = [email protected]:mono/CppSharp.git
7 changes: 4 additions & 3 deletions CreateBindingsPackage.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
git clean -fxd
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe" src\PDFiumCoreBindingsGenerator\PDFiumCoreBindingsGenerator.csproj -r
cd src\PDFiumCoreBindingsGenerator\bin\Debug\net48
CreatePackage.bat
dotnet build src\PDFiumCoreBindingsGenerator\PDFiumCoreBindingsGenerator.csproj -c Release
cd .\src\PDFiumCoreBindingsGenerator\bin\Release\netcoreapp3.1
CreatePackage.bat
pause
1 change: 1 addition & 0 deletions src/CppSharp
Submodule CppSharp added at 508088
9 changes: 9 additions & 0 deletions src/PDFiumCore/PDFiumCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,13 @@
<ItemGroup>
<Content Include="runtimes/**" PackagePath="runtimes" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\CppSharp\src\Runtime\MarshalUtil.cs" Link="CppSharp\MarshalUtil.cs" />
<Compile Include="..\CppSharp\src\Runtime\Pointer.cs" Link="CppSharp\Pointer.cs" />
<Compile Include="..\CppSharp\src\Runtime\SafeUnmanagedMemoryHandle.cs" Link="CppSharp\SafeUnmanagedMemoryHandle.cs" />
<Compile Include="..\CppSharp\src\Runtime\SymbolResolver.cs" Link="CppSharp\SymbolResolver.cs" />
<Compile Include="..\CppSharp\src\Runtime\UTF32Marshaller.cs" Link="CppSharp\UTF32Marshaller.cs" />
<Compile Include="..\CppSharp\src\Runtime\UTF8Marshaller.cs" Link="CppSharp\UTF8Marshaller.cs" />
<Compile Include="..\CppSharp\src\Runtime\VTables.cs" Link="CppSharp\VTables.cs" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/PDFiumCoreBindingsGenerator/CreatePackage.bat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
PDFiumCoreBindingsGenerator.exe "https://api.github.com/repos/bblanchon/pdfium-binaries/releases/35761882" "0" true >build.log & type build.log
PDFiumCoreBindingsGenerator.exe "https://api.github.com/repos/bblanchon/pdfium-binaries/releases/latest" "0" true >build.log & type build.log
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<OutputType>Exe</OutputType>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
Expand All @@ -10,10 +10,10 @@
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="CppSharp" Version="0.10.5">
<PackageReference Include="CppSharp" Version="0.11.2">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json" version="12.0.3" />
<PackageReference Include="SharpZipLib" Version="1.2.0" />
<PackageReference Include="SharpZipLib" Version="1.3.1" />
</ItemGroup>
</Project>
15 changes: 9 additions & 6 deletions src/PDFiumCoreBindingsGenerator/PDFiumCoreLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,21 @@ public PDFiumCoreLibrary(string directoryName)
{
_directoryName = directoryName;
}
public void Postprocess(Driver driver, ASTContext ctx)

public override void Preprocess(Driver driver, ASTContext ctx)
{

}

public override void Postprocess(Driver driver, ASTContext ctx)
{
// Fix for generating code which will not compile.
var fpdfLibraryConfig = ctx.FindClass("FPDF_LIBRARY_CONFIG_");
fpdfLibraryConfig.First().Properties.First(f => f.OriginalName == "m_pUserFontPaths").Ignore = true;
}

public void Preprocess(Driver driver, ASTContext ctx)
{
}

public void Setup(Driver driver)
public override void Setup(Driver driver)
{
var includeDirectory = Path.Combine(_directoryName, "include");
driver.ParserOptions.SetupMSVC(VisualStudioVersion.Latest);
Expand Down Expand Up @@ -54,7 +57,7 @@ public void Setup(Driver driver)
}
}

public void SetupPasses(Driver driver)
public override void SetupPasses(Driver driver)
{
driver.AddTranslationUnitPass(new FixCommentsPass());

Expand Down
10 changes: 7 additions & 3 deletions src/PDFiumCoreBindingsGenerator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,13 @@ static void Main(string[] args)
File.Copy("pdfium-linux/lib/libpdfium.so", "../../../../PDFiumCore/runtimes/linux/native/pdfium.so");
File.Copy("pdfium-linux/LICENSE", "../../../../PDFiumCore/runtimes/linux/native/PDFium-LICENSE");

Directory.CreateDirectory("../../../../PDFiumCore/runtimes/osx/native/");
File.Copy("pdfium-darwin/lib/libpdfium.dylib", "../../../../PDFiumCore/runtimes/osx/native/pdfium.dylib");
File.Copy("pdfium-darwin/LICENSE", "../../../../PDFiumCore/runtimes/osx/native/PDFium-LICENSE");
Directory.CreateDirectory("../../../../PDFiumCore/runtimes/osx-x64/native/");
File.Copy("pdfium-darwin-x64/lib/libpdfium.dylib", "../../../../PDFiumCore/runtimes/osx-x64/native/pdfium.dylib");
File.Copy("pdfium-darwin-x64/LICENSE", "../../../../PDFiumCore/runtimes/osx-x64/native/PDFium-LICENSE");

Directory.CreateDirectory("../../../../PDFiumCore/runtimes/osx-arm64/native/");
File.Copy("pdfium-darwin-arm64/lib/GNUSparseFile.0/libpdfium.dylib", "../../../../PDFiumCore/runtimes/osx-arm64/native/pdfium.dylib");
File.Copy("pdfium-darwin-arm64/LICENSE", "../../../../PDFiumCore/runtimes/osx-arm64/native/PDFium-LICENSE");

Process cmd = new Process
{
Expand Down

0 comments on commit 468e855

Please sign in to comment.