From 820fd44946de811955ac1fdccb6ec42541388c28 Mon Sep 17 00:00:00 2001 From: peri4 Date: Wed, 26 Apr 2023 14:08:30 +0300 Subject: [PATCH] toolchain support --- README.md | 14 +++++++++++++- src/org/SHS/Platforms.groovy | 21 +++++++++++---------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index bfcfdac..c17e684 100644 --- a/README.md +++ b/README.md @@ -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` * `root()` - returns root JSON object of `platforms.json` * `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` * `stageSuffix` - suffix string for `stage` * `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: ``` @Library('SHS.Platforms') _ diff --git a/src/org/SHS/Platforms.groovy b/src/org/SHS/Platforms.groovy index 98bdee4..342f6c9 100644 --- a/src/org/SHS/Platforms.groovy +++ b/src/org/SHS/Platforms.groovy @@ -22,9 +22,10 @@ class Platforms { def prefix = args.stagePrefix ?: "" def suffix = args.stageSuffix ?: "" 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}") { - functor(dist) + functor(dist, toolchain) } } } @@ -33,12 +34,12 @@ class Platforms { //@NonCPS private Boolean filterDist(name, dist, whiteList, blackList) { if (!dist.enabled) { - return false; + return false; } def in_white = true, in_black = false def dn = name.toLowerCase() if (whiteList.size() > 0) { - in_white = false + in_white = false whiteList.each { l -> if (dn.indexOf(l.toLowerCase()) >= 0) { in_white = true } } } blackList.each { l -> if (dn.indexOf(l.toLowerCase()) >= 0) { in_black = true } } @@ -46,12 +47,12 @@ class Platforms { } private def filterJSON(whiteList, blackList) { - def ret = [:] - _root.Platforms.each({name, dist -> - if (filterDist(name, dist, whiteList, blackList)) - ret[name] = dist - }) - return ret + def ret = [:] + _root.Platforms.each({name, dist -> + if (filterDist(name, dist, whiteList, blackList)) + ret[name] = dist + }) + return ret } }