Skip Conan and JBB deps

This commit is contained in:
Ganesh Viswanathan 2020-07-16 15:33:41 -05:00
commit 74c9506529
5 changed files with 55 additions and 20 deletions

View file

@ -53,6 +53,8 @@ https://github.com/nimterop/nimterop/compare/v0.5.9...v0.6.5
- Added `renderPragma()` to create pragmas inline in case `cImport()` is not being used. (since v0.6.5)
- `xxxConan` and `xxxJBB` now allow skipping required dependencies by specifying `skip=pkg1,pkg2` to the `conanFlags` and `jbbFlags` params to `getHeader()`. (since v0.6.6)
### Other improvements
- Generated wrappers no longer depend on nimterop being present - no more `import nimterop/types`. Supporting code is directly included in the wrapper output and only when required. E.g. enum macro is only included if wrapper contains enums. [#125][i125] (since v0.6.1)

View file

@ -97,7 +97,7 @@ Flags can be specified to these tools via `getHeader()` or directly via the unde
If `-d:headerStatic` is specified, `getHeader()` will return the static library path in `headerLPath`. The wrapper writer can check for this and call `cImport()` accordingly as in the example above. If `-d:headerStatic` is omitted, the dynamic library is returned in `headerLPath`.
All dependency libraries (supported by Conan and JBB) will be returned in `headerLDeps`. Static libraries and dependencies are automatically linked using `cPassL()`. Conan shared libs include all dependencies whereas JBB shared libs expect the required dependencies to be in the same location or in `LD_LIBRARY_PATH`.
All dependency libraries (supported by Conan and JBB) will be returned in `headerLDeps`. Static libraries and dependencies are automatically linked using `cPassL()`. Conan shared libs typically include dependencies compiled in whereas JBB shared libs expect the required dependencies to be in the same location or in `LD_LIBRARY_PATH`. `conanFlags` and `jbbFlags` can be used to skip required dependencies from being downloaded in case another source is preferred. This can be done with `skip=pkg1,pkg2` to these flags.
`getHeader()` searches for libraries based on the header name by default:
- `libheader.so` or `libheader.a` on Linux

View file

@ -22,6 +22,8 @@ type
staticLibs*: seq[string]
requires*: seq[ConanPackage]
skipRequires*: seq[string]
ConanBuild* = ref object
## Build type that stores build specific info and revisions
bhash*: string
@ -245,7 +247,10 @@ proc getConanBuilds*(pkg: ConanPackage, filter = "") =
bld.options = newTable[string, string](8)
for key, value in options.getFields():
bld.options[key] = value.getStr()
bld.requires = requires.to(seq[string])
for req in requires.to(seq[string]):
# Filter skipped dependencies
if req.toLowerAscii() notin pkg.skipRequires:
bld.requires.add req
bld.recipe_hash = bdata.getOrDefault("recipe_hash").getStr()
if pkg.recipes.hasKey(bld.recipe_hash):
@ -422,6 +427,7 @@ proc dlConanRequires*(pkg: ConanPackage, bld: ConanBuild, outdir: string) =
else:
let
rpkg = newConanPackageFromUri(req, shared = false)
rpkg.skipRequires = pkg.skipRequires
downloadConan(rpkg, outdir, main = false)
pkg.requires.add rpkg

View file

@ -119,7 +119,7 @@ proc getDlPath(header, url, outdir, version: string): string =
result = findFile(header, outdir)
proc getConanPath(header, uri, outdir, version: string, shared: bool): string =
proc getConanPath(header, uri, flags, outdir, version: string, shared: bool): string =
var
uri = uri
@ -131,6 +131,15 @@ proc getConanPath(header, uri, outdir, version: string, shared: bool): string =
let
pkg = newConanPackageFromUri(uri, shared)
# Handle `conanFlags`
if flags.nBl:
for flag in flags.split(" "):
if flag.startsWith("skip="):
for req in flag["skip=".len .. ^1].split(","):
if req.nBl:
pkg.skipRequires.add req.toLowerAscii()
downloadConan(pkg, outdir)
result = findFile(header, outdir)
@ -165,16 +174,21 @@ proc getJBBPath(header, uri, flags, outdir, version: string): string =
# Handle `jbbFlags`
if flags.nBl:
if flags.startsWith("giturl="):
let
val = flags["giturl=".len .. ^1]
if val.contains("://"):
pkg.baseUrl = val
else:
pkg.baseUrl = "https://github.com/" & val
elif flags.startsWith("url="):
pkg.baseUrl = flags["url=".len .. ^1]
pkg.isGit = false
for flag in flags.split(" "):
if flag.startsWith("giturl="):
let
val = flag["giturl=".len .. ^1]
if val.contains("://"):
pkg.baseUrl = val
else:
pkg.baseUrl = "https://github.com/" & val
elif flag.startsWith("url="):
pkg.baseUrl = flag["url=".len .. ^1]
pkg.isGit = false
elif flag.startsWith("skip="):
for req in flag["skip=".len .. ^1].split(","):
if req.nBl:
pkg.skipRequires.add req.toLowerAscii()
downloadJBB(pkg, outdir)
@ -227,7 +241,7 @@ macro getHeader*(
conanuri: static[string] = "", jbburi: static[string] = "",
outdir: static[string] = "", libdir: static[string] = "",
conFlags: static[string] = "", cmakeFlags: static[string] = "", makeFlags: static[string] = "",
jbbFlags: static[string] = "", altNames: static[string] = "",
conanFlags: static[string] = "", jbbFlags: static[string] = "", altNames: static[string] = "",
buildTypes: static[openArray[BuildType]] = [btCmake, btAutoconf]): untyped =
## Get the path to a header file for wrapping with
## `cImport() <cimport.html#cImport.m%2C%2Cstring%2Cstring%2Cstring>`_ or
@ -300,7 +314,12 @@ macro getHeader*(
## `cmake` and `make` in case additional configuration is required as part of the build
## process.
##
## `jbbFlags` allows changing the BinaryBuilder.org defaults:
## `conanFlags` and `jbbFlags` allow changing the Conan.io and BinaryBuilder.org defaults:
## - `skip=pkg1,pkg2` skips the specified packages which are required dependencies of the
## package in question. This enables downloading those dependencies from other sources
## if required.
##
## `jbbFlags` allows two additional customizations:
## - `giturl=customUrl` changes the default `https://github.com/JuliaBinaryWrappers` to
## another Git URL. If no hostname is specified, `https://github.com` is assumed.
## - `url=customUrl` uses regular HTTP instead of Git and looks for `Artifacts.toml` and
@ -402,13 +421,14 @@ macro getHeader*(
`nameStatic`* = when defined(`nameStatic`): true else: `staticVal` == 1
# Search for header in outdir (after retrieving code) depending on -d:xxx mode
proc getPath(header, giturl, dlurl, conanuri, jbburi, jbbFlags, outdir, version: string, shared: bool): string =
proc getPath(header, giturl, dlurl, conanuri, conanFlags, jbburi, jbbFlags,
outdir, version: string, shared: bool): string =
when `nameGit`:
getGitPath(header, giturl, outdir, version)
elif `nameDL`:
getDlPath(header, dlurl, outdir, version)
elif `nameConan`:
getConanPath(header, conanuri, outdir, version, shared)
getConanPath(header, conanuri, conanFlags, outdir, version, shared)
elif `nameJBB`:
getJBBPath(header, jbburi, jbbFlags, outdir, version)
else:
@ -441,7 +461,7 @@ macro getHeader*(
when useStd:
stdPath
else:
getPath(`header`, `giturl`, `dlurl`, `conanuri`, `jbburi`, `jbbFlags`,
getPath(`header`, `giturl`, `dlurl`, `conanuri`, `conanFlags`, `jbburi`, `jbbFlags`,
`outdir`, `version`, not `nameStatic`)
# Run preBuild hook before building library if not Std, Conan or JBB
@ -477,7 +497,7 @@ macro getHeader*(
if prePath.len != 0:
prePath
else:
getPath(`header`, `giturl`, `dlurl`, `conanuri`, `jbburi`, `jbbFlags`,
getPath(`header`, `giturl`, `dlurl`, `conanuri`, `conanFlags`, `jbburi`, `jbbFlags`,
`outdir`, `version`, not `nameStatic`)
static:

View file

@ -21,6 +21,8 @@ type
staticLibs*: seq[string]
requires*: seq[JBBPackage]
skipRequires*: seq[string]
const
# JBB URLs
jbbBaseUrl = "https://github.com/JuliaBinaryWrappers"
@ -73,7 +75,12 @@ proc parseJBBProject(pkg: JBBPackage, outdir: string) =
let
name = line.split()[0]
if name.endsWith("_jll"):
pkg.requires.add newJBBPackage(name[0 .. ^5], "")
# Filter skipped dependencies
let
pname = name[0 .. ^5]
if pname.toLowerAscii() notin pkg.skipRequires:
pkg.requires.add newJBBPackage(pname, "")
pkg.requires[^1].skipRequires = pkg.skipRequires
proc parseJBBArtifacts(pkg: JBBPackage, outdir: string) =
# Get build information from Artifacts.toml