Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build automation with VCPKG for windows and linux #27

Merged
merged 8 commits into from
Dec 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*.exp
*.lib
.libs/
shared/
!shared/
const/
gdal/
ogr/
Expand Down Expand Up @@ -352,3 +352,5 @@ ASALocalRun/

# MFractors (Xamarin productivity tool) working folder
.mfractor/

.ionide
12 changes: 7 additions & 5 deletions compile/GdalConfigureAll.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static class GdalBase
/// <summary>
/// Shows if gdal is already initialized.
/// </summary>
public static bool IsConfigured { get; set; }
public static bool IsConfigured { get; private set; }

/// <summary>
/// Setups gdalplugins and calls Gdal.AllRegister(), Ogr.RegisterAll(), Proj6.Configure().
Expand Down Expand Up @@ -68,9 +68,10 @@ public static void ConfigureAll()
// here hdf4 driver requires jpeg library to be loaded
// and I won't copy all libraries on each startup
var targetJpeg = Path.Combine(executingDir.FullName, "jpeg.dll");
if (!File.Exists(targetJpeg))
var sourceJpeg = Path.Combine(cdir.FullName, "jpeg.dll");
if (!File.Exists(targetJpeg) &&File.Exists(sourceJpeg))
{
File.Copy(Path.Combine(cdir.FullName, "jpeg.dll"), Path.Combine(executingDir.FullName, "jpeg.dll"));
File.Copy(sourceJpeg, Path.Combine(executingDir.FullName, "jpeg.dll"));
}

OSGeo.GDAL.Gdal.SetConfigOption("GDAL_DRIVER_PATH", targetDrivers);
Expand Down Expand Up @@ -98,15 +99,16 @@ public static void ConfigureAll()
OSGeo.GDAL.Gdal.AllRegister();
OSGeo.OGR.Ogr.RegisterAll();
Proj6.Configure();

// set flag only on success
IsConfigured = true;
}
catch (Exception ex)
{
Console.WriteLine("Error in " + thisName);
Console.WriteLine(ex);
throw;
}

IsConfigured = true;
}
}
}
35 changes: 25 additions & 10 deletions compile/Proj6Configure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,37 @@ public static void Configure()
{
try
{
var h = Assembly.GetAssembly(typeof(OSGeo.OSR.Osr)).Location;
var di = new FileInfo(h).Directory;
var sh = "maxrev.gdal.core.libshared";
string f = default;
if (di.GetDirectories().Any(x => x.Name == sh))
var projectLocation = Assembly.GetAssembly(typeof(OSGeo.OSR.Osr)).Location;
var projectRoot = new FileInfo(projectLocation).Directory;
var libshared = "maxrev.gdal.core.libshared";

// Possible locations of package contents
// [projectRoot]/runtimes/win-x64/native/[libshared]
// [projectRoot]/bin/[cfg]/[libshared]

string finalFolder;
if (projectRoot!.GetDirectories().Any(x =>
string.Equals(x.Name, libshared,
StringComparison.InvariantCultureIgnoreCase)))
{
f = Path.Combine(di.FullName, sh);
finalFolder = Path.Combine(projectRoot.FullName, libshared);
}
else
{
var root = di.Parent.Parent;
f = Path.Combine(root.FullName, sh);
var root = projectRoot.Parent!.Parent;
finalFolder = Path.Combine(root!.FullName, libshared);
}

var e = Path.Combine(new FileInfo(Assembly.GetEntryAssembly().Location).Directory.FullName, sh);
OSGeo.OSR.Osr.SetPROJSearchPaths(new[] { f, e });
// some environments may have flat structure
// try search in root directory
var outputRoot =
new FileInfo(Assembly.GetEntryAssembly()!.Location)
.Directory!.FullName;

var inProjectFolder = Path.Combine(outputRoot, libshared);

OSGeo.OSR.Osr.SetPROJSearchPaths(
new[] { finalFolder, outputRoot, inProjectFolder });
}
catch (Exception ex)
{
Expand Down
16 changes: 9 additions & 7 deletions gdalcore.linuxruntime.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<Platform>x64</Platform>
<DebugType>portable</DebugType>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp2.1;netcoreapp2.2;netcoreapp3.0;netcoreapp3.1</TargetFrameworks>
<Copyright>MaxRev © 2020</Copyright>
<Authors>MaxRev</Authors>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand All @@ -12,15 +12,17 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/MaxRev-Dev/gdal.netcore</RepositoryUrl>
<Version>3.1.0.100</Version>
<Description>GDAL (3.1.0) minimal libraries package.
Drivers included PROJ (6.1.1), GEOS (3.8), SQLITE3, CURL, JPEG, PNG, HDF4, HDF5
Targets linux-x64 runtime and netstandard2.1.
<Version>3.1.2.110</Version>
<Description>GDAL (3.1.2) minimal libraries package.
Drivers included PROJ (7.1.1), GEOS (3.8.0beta2), SQLITE3, CURL, JPEG, PNG, HDF4, HDF5
Targets linux-x64 runtime. Target Frameworks: netstandard[2.1|2.0], netcoreapp[3.1,3.0,2.2,2.1].
</Description>
<AssemblyName>MaxRev.Gdal.LinuxRuntime.Minimal</AssemblyName>
<RootNamespace />
<PackageReleaseNotes>- built on CentOS 7 (glibc - 2.17)
- GDAL 3.1.0</PackageReleaseNotes>
<PackageReleaseNotes>
- built on CentOS 7 (glibc - 2.17)
- GDAL 3.1.2
- built with vcpkg</PackageReleaseNotes>
</PropertyGroup>

<ItemGroup>
Expand Down
15 changes: 9 additions & 6 deletions gdalcore.loader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<Platform>x64</Platform>
<DebugType>portable</DebugType>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp2.1;netcoreapp2.2;netcoreapp3.0;netcoreapp3.1</TargetFrameworks>
<Copyright>MaxRev © 2020</Copyright>
<Authors>MaxRev</Authors>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand All @@ -13,16 +13,20 @@
<RepositoryType>git</RepositoryType>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<RepositoryUrl>https://github.com/MaxRev-Dev/gdal.netcore</RepositoryUrl>
<Version>3.1.0.100</Version>
<Description>GDAL (3.1.0) bindings for dotnet core (now linux-x64 and win-x64).
<Version>3.1.2.110</Version>
<Description>GDAL (3.1.2) bindings for dotnet core (now linux-x64 and win-x64).
Bridge between gdal and netcore.
Use dependency package for target runtime to get drivers.
Works in docker containers without pkg installations!!
Just call - GdalBase.ConfigureAll()
</Description>
<RootNamespace></RootNamespace>
<AssemblyName>MaxRev.Gdal.Core</AssemblyName>
<PackageReleaseNotes>GDAL Version 3.1.0</PackageReleaseNotes>
<PackageReleaseNotes>
- built on CentOS 7 (glibc - 2.17)
- GDAL Version 3.1.2
- built with vcpkg</PackageReleaseNotes>
<LangVersion>8.0</LangVersion>
</PropertyGroup>

<PropertyGroup Condition="$(Configuration) == 'Debug'">
Expand Down Expand Up @@ -58,11 +62,10 @@ Just call - GdalBase.ConfigureAll()
<PackageCopyToOutput>true</PackageCopyToOutput>
</Content>
</ItemGroup>

<ItemGroup>
<PackageReference Include="MSBump" Version="2.3.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</ItemGroup>
</Project>
14 changes: 7 additions & 7 deletions gdalcore.windowsruntime.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/MaxRev-Dev/gdal.netcore</RepositoryUrl>
<Version>3.1.0.100</Version>
<Description>GDAL (3.1.0) minimal libraries package.
Drivers included PROJ (6.1.1), GEOS (3.8), SQLITE3, CURL, JPEG, PNG, HDF4, HDF5
Targets win-x64 runtime. Target Frameworks: netstandard2.0 (2.1), netcoreapp3.1 (2.2,3.0).
<Version>3.1.2.110</Version>
<Description>GDAL (3.1.2) minimal libraries package.
Drivers included PROJ (7.1.1), GEOS (3.8.0beta2), SQLITE3, CURL, JPEG, PNG, HDF4, HDF5
Targets win-x64 runtime. Target Frameworks: netstandard[2.1|2.0], netcoreapp[3.1,3.0,2.2,2.1].
</Description>
<AssemblyName>MaxRev.Gdal.WindowsRuntime.Minimal</AssemblyName>
<RootNamespace />
<PackageReleaseNotes>
- GDAL 3.1.0
- Sync build with linux runtime</PackageReleaseNotes>
- GDAL 3.1.2
- Sync build with linux runtime
- Built with vcpkg</PackageReleaseNotes>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>

Expand Down Expand Up @@ -53,7 +54,6 @@ Targets win-x64 runtime. Target Frameworks: netstandard2.0 (2.1), netcoreapp3.1
<BumpRevision>True</BumpRevision>
<BumpResetLabel>dev</BumpResetLabel>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MSBump" Version="2.3.2">
<PrivateAssets>all</PrivateAssets>
Expand Down
Binary file modified maxrev.gdal.core.libshared/proj.db
Binary file not shown.
8 changes: 8 additions & 0 deletions nuget.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="local" value="nuget" />
</packageSources>
</configuration>
85 changes: 85 additions & 0 deletions shared/GdalCore.opt
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@

##### ----------- gdal.netcore ----------- #####
##### ------- SHARED CONFIGURATION ------- #####

##### repo root
ROOTDIR_=$(BASE)/..
### build (drivers) root
BUILD_ROOT=$(ROOTDIR_)/build-$(BASE_RUNTIME_RID)

GDAL_ROOT=$(BUILD_ROOT)/gdal-source
GDAL_REPO=https://github.com/OSGeo/gdal.git
GDAL_COMMIT_VER=v3.1.2

PROJ_ROOT=$(BUILD_ROOT)/proj-source
PROJ_REPO=https://github.com/OSGeo/PROJ.git
PROJ_COMMIT_VER=dd91c93ca44cbe3cf4f6f7c94a8f225aefa4b408

GEOS_ROOT=$(BUILD_ROOT)/geos-source
GEOS_REPO=https://github.com/libgeos/geos.git
GEOS_COMMIT_VER=ff05d9755d189771147acb3105bd9c9cfff730ff

# ---------------------- VCPKG ----------------------

VCPKG_ROOT = $(BUILD_ROOT)/vcpkg
VCPKG_REPO=https://github.com/microsoft/vcpkg.git
VCPKG_COMMIT_VER=5dc53211caedebf4387d590155ed53ee44161f10

# we won't use these for now (too many boost deps):
# -----: libgeotiff libhdfs3 libkml netcdf-c
VCPKG_REQUIRE=tiff expat xerces-c libpng libiconv zlib

# windows runtime requires more packages and tools
# because they are not preinstalled like on linux
VCPKG_REQUIRE_WIN=$(VCPKG_REQUIRE) sqlite3[tool] curl
VCPKG_REQUIRE_WIN_STATIC=hdf5

# the default configuration is static
# no collisions with sibling libraries in projects
VCPKG_REQUIRE_UNIX=$(VCPKG_REQUIRE) sqlite3
VCPKG_REQUIRE_UNIX_DYNAMIC=hdf5 curl

VCPKG_CLEANUP=buildtrees downloads packages installed

VCPKG_INSTALLED = $(VCPKG_ROOT)/installed/$(VCPKG_RID)
VCPKG_INSTALLED_STATIC = $(VCPKG_ROOT)/installed/$(VCPKG_RID)-static
VCPKG_INSTALLED_DYNAMIC = $(VCPKG_ROOT)/installed/$(VCPKG_RID)-dynamic
# triplets
VPCKG_CUSTOM_TRIPLETS = $(VCPKG_ROOT)/custom-triplets
VCPKG_TRIPLETS_OVERLAY = --overlay-triplets=$(VCPKG_ROOT)/custom-triplets
VCPKG_PARAMS_INSTALL = $(VCPKG_TRIPLETS_OVERLAY) --recurse --clean-after-build
VCPKG_PARAMS_REMOVE = $(VCPKG_TRIPLETS_OVERLAY) --recurse

# --------------------- !VCPKG! --------------------


# ---------------------- CONFIG ---------------------

PRE=[gdal.netcore]

##### GDAL source extended location
GDAL_ROOT=$(BUILD_ROOT)/gdal-source/gdal
BASE_GDAL_=$(GDAL_ROOT)

##### SWIG executable and interface
BASE_SWIG_=$(BASE_GDAL_)/swig
BASE_CSHARP_=$(BASE_SWIG_)/csharp
SWIG_INCLUDE_=$(BASE_SWIG_)/include

##### GDAL build location
GDAL_BUILD_=$(BUILD_ROOT)/gdal-build

##### PROJ6 libraries path required by gdal
BASE_PROJ=$(BUILD_ROOT)/proj-build

#### enabling wildcards expand for gdal
GDAL_SETARGV="C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\lib\x64\wsetargv.obj"

##### NUGET output folder
NUGET_=$(ROOTDIR_)/nuget

### Shared .NET Core Tests
TEST_DIR=$(ROOTDIR_)/test/GdalCore-XUnit

GIT_CLEAN=git clean -fqdx
# --------------------- !CONFIG! --------------------
1 change: 1 addition & 0 deletions test/GdalCore-XUnit/CommonTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public void AllDriversAvailable()
var driverByName = Gdal.GetDriverByName(driver);
_outputHelper.WriteLine(
driverByName != default ? $"{driver} loaded successfully" : $"Failed to load {driver}");
Assert.NotNull(driverByName);
}

}
Expand Down
3 changes: 3 additions & 0 deletions test/GdalCore-XUnit/GdalCore-XUnit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MaxRev.Gdal.Core" Version="3.1.2.110" />
<PackageReference Include="MaxRev.Gdal.LinuxRuntime.Minimal" Version="3.1.2.110" />
<PackageReference Include="MaxRev.Gdal.WindowsRuntime.Minimal" Version="3.1.2.110" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.2">
Expand Down
6 changes: 3 additions & 3 deletions test/GdalCoreTest/GdalCoreTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MaxRev.Gdal.Core" Version=" 3.1.0.100" />
<PackageReference Include="MaxRev.Gdal.LinuxRuntime.Minimal" Version="3.1.0.100" />
<PackageReference Include="MaxRev.Gdal.WindowsRuntime.Minimal" Version="3.1.0.100" />
<PackageReference Include="MaxRev.Gdal.Core" Version="3.1.2.110" />
<PackageReference Include="MaxRev.Gdal.LinuxRuntime.Minimal" Version="3.1.2.110" />
<PackageReference Include="MaxRev.Gdal.WindowsRuntime.Minimal" Version="3.1.2.110" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.9.5" />
</ItemGroup>

Expand Down
Loading