Skip to content

PostgresTargetInfo

Namespace: Ankus.PgConfig

Assembly: Ankus.PgConfig.dll

Describes a PostgreSQL installation captured on the machine an extension will run on: its pg_config values, headers and the native bindings measured there. A machine with the same operating system and another architecture can then build the extension for that runtime identifier, as a pgrx target bundle from cargo pgrx cross pgrx-target allows.

public sealed class PostgresTargetInfo

Native bindings come from compiling and running probe programs against the installation’s headers, which a build machine cannot do for another architecture. The target machine runs them once when the information is exported. Files keep their absolute target paths beneath the files directory, so header search paths and relative includes resolve as they did on the target.

Inheritance: object

Gets the version of Ankus that exported the information; only the same version can consume its bindings.

public string AnkusVersion { get; }

Value: string

Gets the manifest path, which build settings accept in place of a pg_config path.

public string ManifestPath { get; }

Value: string

Gets the directory that contains the manifest, the target’s files and its bindings.

public string RootDirectory { get; }

Value: string

Gets the .NET runtime identifier of the target machine, such as osx-x64.

public string RuntimeIdentifier { get; }

Value: string

Gets the native compiler target triple used for the target’s bindings, or an empty string for the compiler default.

public string TargetTriple { get; }

Value: string

Gets the target installation’s PostgreSQL version.

public PostgresVersion Version { get; }

Value: PostgresVersion

CreateArchiveAsync(PostgresInstallation, string, string, string, IReadOnlyDictionary<string, string>, IEnumerable<string>, string, CancellationToken)

Section titled “CreateArchiveAsync(PostgresInstallation, string, string, string, IReadOnlyDictionary<string, string>, IEnumerable<string>, string, CancellationToken)”

Writes an archive of an installation’s headers, its build values and the native bindings measured for it.

public static Task CreateArchiveAsync(PostgresInstallation installation, string runtimeIdentifier, string targetTriple, string ankusVersion, IReadOnlyDictionary<string, string> bindings, IEnumerable<string> headers, string archive, CancellationToken cancellationToken = default)

Parameters:

installation — PostgresInstallation

The target installation, queried on the target machine.

runtimeIdentifier — string

The target runtime identifier.

targetTriple — string

The native compiler target triple, or an empty string.

ankusVersion — string

The exporting Ankus version.

bindings — IReadOnlyDictionary<string, string>

Binding artifacts by file name and local path.

headers — IEnumerable<string>

Absolute paths of the headers compilation reads. Those beneath the public header directory or a search directory in the installation’s preprocessor flags are captured; the build machine’s toolchain supplies system headers.

archive — string

The archive to create or replace.

cancellationToken — CancellationToken

Cancels copying and compression.

Returns: Task

The export operation.

ExtractAsync(string, string, CancellationToken)

Section titled “ExtractAsync(string, string, CancellationToken)”

Extracts an archive into a directory named by its content hash and verifies it, reusing an earlier extraction.

public static Task<PostgresTargetInfo> ExtractAsync(string archive, string cacheDirectory, CancellationToken cancellationToken = default)

Parameters:

archive — string

The exported archive.

cacheDirectory — string

The directory that holds extracted targets.

cancellationToken — CancellationToken

Cancels hashing and extraction.

Returns: Task<PostgresTargetInfo>

The verified target.

Builds that set AnkusTargetInfo to an archive extract it to the same location.

Gets the conventional archive name for a target, such as ankus-target.pg18.osx-x64.zip.

public static string GetArchiveFileName(int postgresMajor, string runtimeIdentifier)

Parameters:

postgresMajor — int

The target’s PostgreSQL major.

runtimeIdentifier — string

The target’s runtime identifier.

Returns: string

The archive file name.

Gets the local path of one native binding artifact measured on the target.

public string GetBindingPath(string name)

Parameters:

name — string

The artifact file name.

Returns: string

The artifact path.

Maps an absolute path on the target machine to its copy in this information.

public string MapPath(string targetPath)

Parameters:

targetPath — string

An absolute path as the target reported it.

Returns: string

The local path, which exists only for files and directories the export captured.

Reads extracted target information without checking its file contents.

public static PostgresTargetInfo Open(string path)

Parameters:

path — string

The manifest or the directory that contains it.

Returns: PostgresTargetInfo

The described target.

Exceptions:

Checks that every captured file is present and unchanged.

public Task VerifyAsync(CancellationToken cancellationToken = default)

Parameters:

cancellationToken — CancellationToken

Cancels hashing.

Returns: Task

The verification operation.

Exceptions:

Gets the manifest’s file name at the root of an archive or extracted directory.

public const string ManifestFileName = "ankus-target.json"