build/conan

Types

ConanPackage = ref object
  name*: string
  version*: string
  user*: string
  channel*: string
  recipes*: OrderedTableRef[string, seq[ConanBuild]]
  bhash*: string
  shared*: bool
  sharedLibs*: seq[string]
  staticLibs*: seq[string]
  requires*: seq[ConanPackage]
  skipRequires*: seq[string]
ConanPackage type that stores conan uri and recipes/builds/revisions
ConanBuild = ref object
  bhash*: string
  settings*: TableRef[string, string]
  options*: TableRef[string, string]
  requires*: seq[string]
  recipe_hash*: string
  revisions*: seq[string]
Build type that stores build specific info and revisions

Procs

proc addAltConanBaseUrl(name, url: string) {...}{.raises: [], tags: [].}
proc `==`(pkg1, pkg2: ConanPackage): bool {...}{.raises: [], tags: [].}
Check if two ConanPackage objects are equal
proc newConanPackage(name, version, user = "_"; channel = "_"; bhash = ""; shared = true): ConanPackage {...}{.
    raises: [], tags: [].}
Create a new ConanPackage with specified name and version
proc newConanPackageFromUri(uri: string; shared = true): ConanPackage {...}{.raises: [],
    tags: [].}
Create a new ConanPackage from a conan uri typically formatted as name/version[@user/channel][:bhash]
proc getUriFromConanPackage(pkg: ConanPackage): string {...}{.raises: [], tags: [].}
Convert a ConanPackage to a conan uri
proc searchConan(name: string; version = ""; user = ""; channel = ""): ConanPackage {...}{.
    raises: [ValueError, OSError, Exception, IOError, KeyError], tags: [ReadEnvEffect,
    ReadIOEffect, ReadDirEffect, ExecIOEffect, RootEffect, WriteIOEffect].}

Search for package by name and optional version, user and channel

Search is quite slow so it is preferable to specify a version and use getConanBuilds()

proc searchConan(pkg: ConanPackage): ConanPackage {...}{.
    raises: [ValueError, OSError, Exception, IOError, KeyError], tags: [ReadEnvEffect,
    ReadIOEffect, ReadDirEffect, ExecIOEffect, RootEffect, WriteIOEffect].}
Search for latest package based on incomplete package info
proc getConanBuilds(pkg: ConanPackage; filter = "") {...}{.
    raises: [ValueError, OSError, Exception, IOError, KeyError, JsonKindError], tags: [
    ExecIOEffect, ReadIOEffect, RootEffect, WriteIOEffect, ReadEnvEffect,
    ReadDirEffect].}
Get all builds for a package based on the C compiler's target OS/arch info
filter can be used to tweak search terms
e.g. build_type=Debug&compiler=clang
proc getConanRevisions(pkg: ConanPackage; bld: ConanBuild) {...}{.
    raises: [ValueError, OSError, Exception, IOError, KeyError], tags: [ReadEnvEffect,
    ReadIOEffect, ReadDirEffect, ExecIOEffect, RootEffect, WriteIOEffect].}
Get all revisions of a build
proc loadConanInfo(outdir: string): ConanPackage {...}{.raises: [],
    tags: [ReadDirEffect, ReadIOEffect, WriteIOEffect].}
Load cached package info from outdir/conaninfo.json
proc saveConanInfo(pkg: ConanPackage; outdir: string) {...}{.raises: [IOError],
    tags: [WriteIOEffect].}
Save downloaded package info to outdir/conaninfo.json
proc dlConanBuild(pkg: ConanPackage; bld: ConanBuild; outdir: string; revision = "") {...}{.
    raises: [ValueError, KeyError, OSError, Exception, IOError], tags: [ReadDirEffect,
    ExecIOEffect, ReadIOEffect, RootEffect, WriteIOEffect, ReadEnvEffect].}

Download specific revision of bld to outdir

If omitted, the latest revision (first) is downloaded

proc downloadConan(pkg: ConanPackage; outdir: string; main = true) {...}{.
    raises: [ValueError, OSError, Exception, IOError, KeyError, JsonKindError], tags: [
    ReadEnvEffect, ReadIOEffect, ReadDirEffect, ExecIOEffect, RootEffect,
    WriteIOEffect].}

Download latest recipe/build/revision of pkg to outdir

High-level API that handles the end to end Conan process flow to find latest package binary and downloads and extracts it to outdir.

proc dlConanRequires(pkg: ConanPackage; bld: ConanBuild; outdir: string) {...}{.
    raises: [KeyError, ValueError, OSError, Exception, IOError, JsonKindError], tags: [
    ReadEnvEffect, ReadIOEffect, ReadDirEffect, ExecIOEffect, RootEffect,
    WriteIOEffect].}

Download all required dependencies of this bld

This is not required for shared libs since conan builds them with all dependencies statically linked in

proc getConanLDeps(pkg: ConanPackage; outdir: string; main = true): seq[string] {...}{.
    raises: [ValueError], tags: [].}

Get all Conan libs - shared (.so|.dll) or static (.a|.lib) in pkg, including deps in descending order

outdir is prefixed to each entry