toolchain support

This commit is contained in:
2023-04-26 14:08:30 +03:00
parent 7978ea6161
commit 820fd44946
2 changed files with 24 additions and 11 deletions

View File

@@ -18,7 +18,7 @@ Next you should register this library in Jenkins -> System settings -> Global Pi
* `get()` - download and parse `platforms.json` file from `PLATFORMS_GIT` * `get()` - download and parse `platforms.json` file from `PLATFORMS_GIT`
* `root()` - returns root JSON object of `platforms.json` * `root()` - returns root JSON object of `platforms.json`
* `forEach(func, ...)` - iterate over platforms, `func` is only mandatory parameter: * `forEach(func, ...)` - iterate over platforms, `func` is only mandatory parameter:
* `func` - method to execute for each enabled platform, pass JSON element of current platform * `func` - method to execute for each enabled platform, pass JSON element of current platform and optional CMake toolchain argument
* `stagePrefix` - prefix string for `stage` * `stagePrefix` - prefix string for `stage`
* `stageSuffix` - suffix string for `stage` * `stageSuffix` - suffix string for `stage`
* `whiteList` - array of permitted names, ignored if empty * `whiteList` - array of permitted names, ignored if empty
@@ -40,6 +40,18 @@ node {
} }
``` ```
With toolchain:
```
@Library('SHS.Platforms') _
node {
def pl = new org.SHS.Platforms(this)
pl.get()
pl.forEach ({ dist, cmake_toolchain ->
print("compile in ${dist.docker_image} with arg ${cmake_toolchain}")
})
}
```
With filter: With filter:
``` ```
@Library('SHS.Platforms') _ @Library('SHS.Platforms') _

View File

@@ -22,9 +22,10 @@ class Platforms {
def prefix = args.stagePrefix ?: "" def prefix = args.stagePrefix ?: ""
def suffix = args.stageSuffix ?: "" def suffix = args.stageSuffix ?: ""
filterJSON(args.whiteList ?: [], args.blackList ?: []).each { key, dist -> filterJSON(args.whiteList ?: [], args.blackList ?: []).each { key, dist ->
//steps.print("final ${key}${suffix}") def toolchain = dist.cmake_toolchain ?: ""
if (toolchain != "") toolchain = "-DCMAKE_TOOLCHAIN_FILE=${toolchain}"
steps.stage ("${prefix}${key}${suffix}") { steps.stage ("${prefix}${key}${suffix}") {
functor(dist) functor(dist, toolchain)
} }
} }
} }
@@ -33,12 +34,12 @@ class Platforms {
//@NonCPS //@NonCPS
private Boolean filterDist(name, dist, whiteList, blackList) { private Boolean filterDist(name, dist, whiteList, blackList) {
if (!dist.enabled) { if (!dist.enabled) {
return false; return false;
} }
def in_white = true, in_black = false def in_white = true, in_black = false
def dn = name.toLowerCase() def dn = name.toLowerCase()
if (whiteList.size() > 0) { if (whiteList.size() > 0) {
in_white = false in_white = false
whiteList.each { l -> if (dn.indexOf(l.toLowerCase()) >= 0) { in_white = true } } whiteList.each { l -> if (dn.indexOf(l.toLowerCase()) >= 0) { in_white = true } }
} }
blackList.each { l -> if (dn.indexOf(l.toLowerCase()) >= 0) { in_black = true } } blackList.each { l -> if (dn.indexOf(l.toLowerCase()) >= 0) { in_black = true } }
@@ -46,12 +47,12 @@ class Platforms {
} }
private def filterJSON(whiteList, blackList) { private def filterJSON(whiteList, blackList) {
def ret = [:] def ret = [:]
_root.Platforms.each({name, dist -> _root.Platforms.each({name, dist ->
if (filterDist(name, dist, whiteList, blackList)) if (filterDist(name, dist, whiteList, blackList))
ret[name] = dist ret[name] = dist
}) })
return ret return ret
} }
} }