From 468e855458968a84af8450c560bb48adf417f9e9 Mon Sep 17 00:00:00 2001 From: DJGosnell Date: Mon, 15 Feb 2021 10:19:18 -0500 Subject: [PATCH] Added CppSharp submodule to reference required Marshal utilities. Updated for new netcoreapp3.1 version of CppSharp. Updated for new pdfium-darwin-x64 and pdfium-darwin-arm64 packages. --- .gitmodules | 3 +++ CreateBindingsPackage.bat | 7 ++++--- src/CppSharp | 1 + src/PDFiumCore/PDFiumCore.csproj | 9 +++++++++ src/PDFiumCoreBindingsGenerator/CreatePackage.bat | 2 +- .../PDFiumCoreBindingsGenerator.csproj | 6 +++--- .../PDFiumCoreLibrary.cs | 15 +++++++++------ src/PDFiumCoreBindingsGenerator/Program.cs | 10 +++++++--- 8 files changed, 37 insertions(+), 16 deletions(-) create mode 100644 .gitmodules create mode 160000 src/CppSharp diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..0c36a58 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "src/CppSharp"] + path = src/CppSharp + url = git@github.com:mono/CppSharp.git diff --git a/CreateBindingsPackage.bat b/CreateBindingsPackage.bat index a8738d5..a4c557e 100644 --- a/CreateBindingsPackage.bat +++ b/CreateBindingsPackage.bat @@ -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 \ No newline at end of file +dotnet build src\PDFiumCoreBindingsGenerator\PDFiumCoreBindingsGenerator.csproj -c Release +cd .\src\PDFiumCoreBindingsGenerator\bin\Release\netcoreapp3.1 +CreatePackage.bat +pause \ No newline at end of file diff --git a/src/CppSharp b/src/CppSharp new file mode 160000 index 0000000..5080881 --- /dev/null +++ b/src/CppSharp @@ -0,0 +1 @@ +Subproject commit 50808812afce308af78a1da112aa42a58196e11b diff --git a/src/PDFiumCore/PDFiumCore.csproj b/src/PDFiumCore/PDFiumCore.csproj index 40705c2..62863b6 100644 --- a/src/PDFiumCore/PDFiumCore.csproj +++ b/src/PDFiumCore/PDFiumCore.csproj @@ -14,4 +14,13 @@ + + + + + + + + + diff --git a/src/PDFiumCoreBindingsGenerator/CreatePackage.bat b/src/PDFiumCoreBindingsGenerator/CreatePackage.bat index 0c65ac9..49276a6 100644 --- a/src/PDFiumCoreBindingsGenerator/CreatePackage.bat +++ b/src/PDFiumCoreBindingsGenerator/CreatePackage.bat @@ -1 +1 @@ -PDFiumCoreBindingsGenerator.exe "https://api.github.com/repos/bblanchon/pdfium-binaries/releases/35761882" "0" true >build.log & type build.log \ No newline at end of file +PDFiumCoreBindingsGenerator.exe "https://api.github.com/repos/bblanchon/pdfium-binaries/releases/latest" "0" true >build.log & type build.log \ No newline at end of file diff --git a/src/PDFiumCoreBindingsGenerator/PDFiumCoreBindingsGenerator.csproj b/src/PDFiumCoreBindingsGenerator/PDFiumCoreBindingsGenerator.csproj index bb4e77e..ee54f5f 100644 --- a/src/PDFiumCoreBindingsGenerator/PDFiumCoreBindingsGenerator.csproj +++ b/src/PDFiumCoreBindingsGenerator/PDFiumCoreBindingsGenerator.csproj @@ -1,6 +1,6 @@  - net48 + netcoreapp3.1 Exe x64 @@ -10,10 +10,10 @@ - + all - + \ No newline at end of file diff --git a/src/PDFiumCoreBindingsGenerator/PDFiumCoreLibrary.cs b/src/PDFiumCoreBindingsGenerator/PDFiumCoreLibrary.cs index e2f9795..310d136 100644 --- a/src/PDFiumCoreBindingsGenerator/PDFiumCoreLibrary.cs +++ b/src/PDFiumCoreBindingsGenerator/PDFiumCoreLibrary.cs @@ -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); @@ -54,7 +57,7 @@ public void Setup(Driver driver) } } - public void SetupPasses(Driver driver) + public override void SetupPasses(Driver driver) { driver.AddTranslationUnitPass(new FixCommentsPass()); diff --git a/src/PDFiumCoreBindingsGenerator/Program.cs b/src/PDFiumCoreBindingsGenerator/Program.cs index 8e44cc8..d6fba7c 100644 --- a/src/PDFiumCoreBindingsGenerator/Program.cs +++ b/src/PDFiumCoreBindingsGenerator/Program.cs @@ -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 {