Add jbbFlags to customize xxxJBB
This commit is contained in:
parent
90c5f54dc3
commit
37cdc5b94e
3 changed files with 66 additions and 28 deletions
|
|
@ -15,7 +15,7 @@ Refer to the documentation for `getHeader()` for details on how to use this new
|
||||||
|
|
||||||
See the full list of changes here:
|
See the full list of changes here:
|
||||||
|
|
||||||
https://github.com/nimterop/nimterop/compare/v0.5.9...v0.6.1
|
https://github.com/nimterop/nimterop/compare/v0.5.9...v0.6.3
|
||||||
|
|
||||||
### Breaking changes
|
### Breaking changes
|
||||||
|
|
||||||
|
|
@ -39,6 +39,8 @@ https://github.com/nimterop/nimterop/compare/v0.5.9...v0.6.1
|
||||||
|
|
||||||
- Nimterop now supports anonymous nested structs/unions but it only works correctly for unions when `noHeader` is turned off (the default). This is because Nim does not support nested structs/unions and is unaware of the underlying memory structure. [#237][i237] (since v0.6.1)
|
- Nimterop now supports anonymous nested structs/unions but it only works correctly for unions when `noHeader` is turned off (the default). This is because Nim does not support nested structs/unions and is unaware of the underlying memory structure. [#237][i237] (since v0.6.1)
|
||||||
|
|
||||||
|
- `xxxJBB` now allows for customizing the base location to search packages with the `jbbFlags` param to `getHeader()`. Specifying `giturl=xxx` where `xxx` could be a full Git URL or just the username for Github.com allows changing the default Git repo. In addition, `url=xxx` is also supported to download project info and binaries compiled with BinaryBuilder.org but hosted at another non-Git location. (since v0.6.3)
|
||||||
|
|
||||||
### Other improvements
|
### 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)
|
- 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)
|
||||||
|
|
|
||||||
|
|
@ -141,18 +141,14 @@ proc getConanLDeps(outdir: string): seq[string] =
|
||||||
|
|
||||||
result = pkg.getConanLDeps(outdir)
|
result = pkg.getConanLDeps(outdir)
|
||||||
|
|
||||||
proc getJBBPath(header, uri, outdir, version: string): string =
|
proc getJBBPath(header, uri, flags, outdir, version: string): string =
|
||||||
let
|
let
|
||||||
spl = uri.split('/', 1)
|
spl = uri.split('/', 1)
|
||||||
name = spl[0]
|
name = spl[0]
|
||||||
hasVersion = version.len != 0
|
hasVersion = version.len != 0
|
||||||
|
|
||||||
var
|
var
|
||||||
ver =
|
ver = if spl.len == 2: spl[1] else: ""
|
||||||
if spl.len == 2:
|
|
||||||
spl[1]
|
|
||||||
else:
|
|
||||||
""
|
|
||||||
|
|
||||||
if ver.len != 0:
|
if ver.len != 0:
|
||||||
if "$#" in ver or "$1" in ver:
|
if "$#" in ver or "$1" in ver:
|
||||||
|
|
@ -166,6 +162,20 @@ proc getJBBPath(header, uri, outdir, version: string): string =
|
||||||
|
|
||||||
let
|
let
|
||||||
pkg = newJBBPackage(name, ver)
|
pkg = newJBBPackage(name, ver)
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
downloadJBB(pkg, outdir)
|
downloadJBB(pkg, outdir)
|
||||||
|
|
||||||
result = findFile(header, outdir)
|
result = findFile(header, outdir)
|
||||||
|
|
@ -217,7 +227,8 @@ macro getHeader*(
|
||||||
conanuri: static[string] = "", jbburi: static[string] = "",
|
conanuri: static[string] = "", jbburi: static[string] = "",
|
||||||
outdir: static[string] = "", libdir: static[string] = "",
|
outdir: static[string] = "", libdir: static[string] = "",
|
||||||
conFlags: static[string] = "", cmakeFlags: static[string] = "", makeFlags: static[string] = "",
|
conFlags: static[string] = "", cmakeFlags: static[string] = "", makeFlags: static[string] = "",
|
||||||
altNames: static[string] = "", buildTypes: static[openArray[BuildType]] = [btCmake, btAutoconf]): untyped =
|
jbbFlags: static[string] = "", altNames: static[string] = "",
|
||||||
|
buildTypes: static[openArray[BuildType]] = [btCmake, btAutoconf]): untyped =
|
||||||
## Get the path to a header file for wrapping with
|
## Get the path to a header file for wrapping with
|
||||||
## `cImport() <cimport.html#cImport.m%2C%2Cstring%2Cstring%2Cstring>`_ or
|
## `cImport() <cimport.html#cImport.m%2C%2Cstring%2Cstring%2Cstring>`_ or
|
||||||
## `c2nImport() <cimport.html#c2nImport.m%2C%2Cstring%2Cstring%2Cstring>`_.
|
## `c2nImport() <cimport.html#c2nImport.m%2C%2Cstring%2Cstring%2Cstring>`_.
|
||||||
|
|
@ -289,6 +300,13 @@ macro getHeader*(
|
||||||
## `cmake` and `make` in case additional configuration is required as part of the build
|
## `cmake` and `make` in case additional configuration is required as part of the build
|
||||||
## process.
|
## process.
|
||||||
##
|
##
|
||||||
|
## `jbbFlags` allows changing the BinaryBuilder.org defaults:
|
||||||
|
## - `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
|
||||||
|
## `Project.toml` files at that location. `$1` or `$#` are replaced with the version
|
||||||
|
## if specified.
|
||||||
|
##
|
||||||
## `altNames` is a list of alternate names for the library - e.g. zlib uses `zlib.h` for
|
## `altNames` is a list of alternate names for the library - e.g. zlib uses `zlib.h` for
|
||||||
## the header but the typical lib name is `libz.so` and not `libzlib.so`. However, it is
|
## the header but the typical lib name is `libz.so` and not `libzlib.so`. However, it is
|
||||||
## libzlib.dll on Windows if built with cmake. In this case, `altNames = "z,zlib"`. Comma
|
## libzlib.dll on Windows if built with cmake. In this case, `altNames = "z,zlib"`. Comma
|
||||||
|
|
@ -384,7 +402,7 @@ macro getHeader*(
|
||||||
`nameStatic`* = when defined(`nameStatic`): true else: `staticVal` == 1
|
`nameStatic`* = when defined(`nameStatic`): true else: `staticVal` == 1
|
||||||
|
|
||||||
# Search for header in outdir (after retrieving code) depending on -d:xxx mode
|
# Search for header in outdir (after retrieving code) depending on -d:xxx mode
|
||||||
proc getPath(header, giturl, dlurl, conanuri, jbburi, outdir, version: string, shared: bool): string =
|
proc getPath(header, giturl, dlurl, conanuri, jbburi, jbbFlags, outdir, version: string, shared: bool): string =
|
||||||
when `nameGit`:
|
when `nameGit`:
|
||||||
getGitPath(header, giturl, outdir, version)
|
getGitPath(header, giturl, outdir, version)
|
||||||
elif `nameDL`:
|
elif `nameDL`:
|
||||||
|
|
@ -392,7 +410,7 @@ macro getHeader*(
|
||||||
elif `nameConan`:
|
elif `nameConan`:
|
||||||
getConanPath(header, conanuri, outdir, version, shared)
|
getConanPath(header, conanuri, outdir, version, shared)
|
||||||
elif `nameJBB`:
|
elif `nameJBB`:
|
||||||
getJBBPath(header, jbburi, outdir, version)
|
getJBBPath(header, jbburi, jbbFlags, outdir, version)
|
||||||
else:
|
else:
|
||||||
getLocalPath(header, outdir)
|
getLocalPath(header, outdir)
|
||||||
|
|
||||||
|
|
@ -423,7 +441,8 @@ macro getHeader*(
|
||||||
when useStd:
|
when useStd:
|
||||||
stdPath
|
stdPath
|
||||||
else:
|
else:
|
||||||
getPath(`header`, `giturl`, `dlurl`, `conanuri`, `jbburi`, `outdir`, `version`, not `nameStatic`)
|
getPath(`header`, `giturl`, `dlurl`, `conanuri`, `jbburi`, `jbbFlags`,
|
||||||
|
`outdir`, `version`, not `nameStatic`)
|
||||||
|
|
||||||
# Run preBuild hook before building library if not Std, Conan or JBB
|
# Run preBuild hook before building library if not Std, Conan or JBB
|
||||||
when not (useStd or `nameConan` or `nameJBB`) and declared(`preBuild`):
|
when not (useStd or `nameConan` or `nameJBB`) and declared(`preBuild`):
|
||||||
|
|
@ -458,7 +477,8 @@ macro getHeader*(
|
||||||
if prePath.len != 0:
|
if prePath.len != 0:
|
||||||
prePath
|
prePath
|
||||||
else:
|
else:
|
||||||
getPath(`header`, `giturl`, `dlurl`, `conanuri`, `jbburi`, `outdir`, `version`, not `nameStatic`)
|
getPath(`header`, `giturl`, `dlurl`, `conanuri`, `jbburi`, `jbbFlags`,
|
||||||
|
`outdir`, `version`, not `nameStatic`)
|
||||||
|
|
||||||
static:
|
static:
|
||||||
doAssert `path`.len != 0, "\nHeader " & `header` & " not found - " &
|
doAssert `path`.len != 0, "\nHeader " & `header` & " not found - " &
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,10 @@ type
|
||||||
name*: string
|
name*: string
|
||||||
version*: string
|
version*: string
|
||||||
|
|
||||||
url*: string
|
baseUrl*: string # Location to find package
|
||||||
|
isGit*: bool # Git or HTTP
|
||||||
|
|
||||||
|
url*: string # Download URL
|
||||||
|
|
||||||
sharedLibs*: seq[string]
|
sharedLibs*: seq[string]
|
||||||
staticLibs*: seq[string]
|
staticLibs*: seq[string]
|
||||||
|
|
@ -20,7 +23,7 @@ type
|
||||||
|
|
||||||
const
|
const
|
||||||
# JBB URLs
|
# JBB URLs
|
||||||
jbbBaseUrl = "https://github.com/JuliaBinaryWrappers/$1_jll.jl"
|
jbbBaseUrl = "https://github.com/JuliaBinaryWrappers"
|
||||||
|
|
||||||
jbbInfo = "jbbinfo.json"
|
jbbInfo = "jbbinfo.json"
|
||||||
jbbProject = "Project.toml"
|
jbbProject = "Project.toml"
|
||||||
|
|
@ -45,6 +48,8 @@ proc newJBBPackage*(name, version: string): JBBPackage =
|
||||||
result = new(JBBPackage)
|
result = new(JBBPackage)
|
||||||
result.name = name
|
result.name = name
|
||||||
result.version = version
|
result.version = version
|
||||||
|
result.baseUrl = jbbBaseUrl
|
||||||
|
result.isGit = true
|
||||||
|
|
||||||
proc parseJBBProject(pkg: JBBPackage, outdir: string) =
|
proc parseJBBProject(pkg: JBBPackage, outdir: string) =
|
||||||
# Get all dependencies from Project.toml
|
# Get all dependencies from Project.toml
|
||||||
|
|
@ -127,21 +132,32 @@ proc getJBBRepo*(pkg: JBBPackage, outdir: string) =
|
||||||
let
|
let
|
||||||
path = outdir / "repos" / pkg.name
|
path = outdir / "repos" / pkg.name
|
||||||
|
|
||||||
gitPull(
|
if pkg.isGit:
|
||||||
jbbBaseUrl % pkg.name,
|
# Get package info using Git
|
||||||
outdir = path,
|
gitPull(
|
||||||
plist = "*.toml",
|
pkg.baseUrl & ("/$1_jll.jl" % pkg.name),
|
||||||
"master",
|
outdir = path,
|
||||||
quiet = true
|
plist = "*.toml",
|
||||||
)
|
"master",
|
||||||
|
quiet = true
|
||||||
|
)
|
||||||
|
|
||||||
if pkg.version.len != 0:
|
if pkg.version.len != 0:
|
||||||
# Checkout correct tag
|
# Checkout correct tag
|
||||||
let
|
let
|
||||||
tags = gitTags(path)
|
tags = gitTags(path)
|
||||||
for i in tags.len - 1 .. 0:
|
for i in tags.len - 1 .. 0:
|
||||||
if pkg.version in tags[i] and i != tags.len - 1:
|
if pkg.version in tags[i] and i != tags.len - 1:
|
||||||
gitCheckout(path, tags[i-1])
|
gitCheckout(path, tags[i-1])
|
||||||
|
else:
|
||||||
|
# Download package info from HTTP
|
||||||
|
var
|
||||||
|
url = pkg.baseUrl
|
||||||
|
if "$#" in url or "$1" in url:
|
||||||
|
doAssert pkg.version.len != 0, "Need version for custom BinaryBuilder.org url: " & url
|
||||||
|
url = url % pkg.version
|
||||||
|
downloadUrl(url & "Artifacts.toml", path, quiet = true)
|
||||||
|
downloadUrl(url & "Project.toml", path, quiet = true)
|
||||||
|
|
||||||
pkg.parseJBBProject(path)
|
pkg.parseJBBProject(path)
|
||||||
pkg.parseJBBArtifacts(path)
|
pkg.parseJBBArtifacts(path)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue