:)
Dependencies: Servo Cayenne-LPP
Diff: Jenkinsfile
- Revision:
- 20:2055271192d6
- Parent:
- 14:b25fefabb634
- Child:
- 35:462743fb571e
diff -r 6accf37de3ce -r 2055271192d6 Jenkinsfile --- a/Jenkinsfile Tue May 22 07:00:16 2018 +0100 +++ b/Jenkinsfile Tue May 22 15:45:15 2018 +0100 @@ -1,5 +1,6 @@ properties ([[$class: 'ParametersDefinitionProperty', parameterDefinitions: [ - [$class: 'StringParameterDefinition', name: 'mbed_os_revision', defaultValue: '', description: 'Revision of mbed-os to build. To access mbed-os PR use format "pull/PR number/head"'] + [$class: 'StringParameterDefinition', name: 'mbed_os_revision', defaultValue: '', description: 'Revision of mbed-os to build. To access mbed-os PR use format "pull/PR number/head"'], + [$class: 'BooleanParameterDefinition', name: 'regions_build_test', defaultValue: true, description: 'Test build all available regions'] ]]]) if (env.MBED_OS_REVISION == null) { @@ -15,6 +16,13 @@ } } +// All available regions +def regions = [ + "\"0\"", "\"1\"", "\"2\"", "\"3\"", "\"4\"", "\"5\"", "\"6\"", "\"7\"", "\"8\"", "\"9\"", + "\"EU868\"", "\"AS923\"", "\"AU915\"", "\"CN470\"", "\"CN779\"", "\"EU433\"", + "\"IN865\"", "\"KR920\"", "\"US915\"", "\"US915_HYBRID\"" +] + // Supported targets def targets = [ "K64F", @@ -35,6 +43,15 @@ def stepsForParallel = [:] +// Run correct command based on OS used +def execute(cmd) { + if(isUnix()) { + sh "${cmd}" + } else { + bat "${cmd}" + } +} + // Jenkins pipeline does not support map.each, we need to use oldschool for loop for (int i = 0; i < targets.size(); i++) { for(int j = 0; j < toolchains.size(); j++) { @@ -56,8 +73,15 @@ } } +def stepsForRegional = [:] + +if (params.regions_build_test == true) { + stepsForRegional["REGION BUILDER"] = build_regions(regions) +} + timestamps { parallel stepsForParallel + parallel stepsForRegional } def buildStep(target, compilerLabel, toolchain) { @@ -67,75 +91,39 @@ deleteDir() dir("mbed-os-example-lorawan") { checkout scm + execute("mbed deploy --protocol ssh") - if (isUnix()) { - sh "mbed deploy --protocol ssh" - } else { - bat "mbed deploy --protocol ssh" - } // Set mbed-os to revision received as parameter if (env.MBED_OS_REVISION != '') { dir("mbed-os") { if (env.MBED_OS_REVISION.matches('pull/\\d+/head')) { // Use mbed-os PR and switch to branch created - if (isUnix()) { - sh "git fetch origin ${env.MBED_OS_REVISION}:_PR_" - sh "git checkout _PR_" - } else { - bat "git fetch origin ${env.MBED_OS_REVISION}:_PR_" - bat "git checkout _PR_" - } - + execute("git fetch origin ${env.MBED_OS_REVISION}:_PR_") + execute("git checkout _PR_") } else { - if (isUnix()) { - sh "git checkout ${env.MBED_OS_REVISION}" - } else { - bat "git checkout ${env.MBED_OS_REVISION}" - } + execute("git checkout ${env.MBED_OS_REVISION}") } } } // Adjust stack size and crystal values if ("${target}" == "DISCO_L072CZ_LRWAN1") { - if (isUnix()) { - sh "sed -i 's/#define RCC_HSICALIBRATION_DEFAULT ((uint32_t)0x10)/#define RCC_HSICALIBRATION_DEFAULT ((uint32_t)0x13)/' \ - mbed-os/targets/TARGET_STM/TARGET_STM32L0/device/stm32l0xx_hal_rcc.h" - } else { - bat "sed -i 's/#define RCC_HSICALIBRATION_DEFAULT ((uint32_t)0x10)/#define RCC_HSICALIBRATION_DEFAULT ((uint32_t)0x13)/' \ - mbed-os/targets/TARGET_STM/TARGET_STM32L0/device/stm32l0xx_hal_rcc.h" - } + execute("sed -i 's/#define RCC_HSICALIBRATION_DEFAULT ((uint32_t)0x10)/#define RCC_HSICALIBRATION_DEFAULT ((uint32_t)0x13)/' \ + mbed-os/targets/TARGET_STM/TARGET_STM32L0/device/stm32l0xx_hal_rcc.h") } if ("${target}" == "MTB_MURATA_ABZ") { - if (isUnix()) { - sh "sed -i 's/define symbol __size_heap__ = 0x800;/define symbol __size_heap__ = 0x1000;/' \ - mbed-os/targets/TARGET_STM/TARGET_STM32L0/TARGET_STM32L0x2xZ/device/TOOLCHAIN_IAR/stm32l082xZ.icf" - sh "sed -i 's/#define RCC_HSICALIBRATION_DEFAULT ((uint32_t)0x10)/#define RCC_HSICALIBRATION_DEFAULT ((uint32_t)0x16)/' \ - mbed-os/targets/TARGET_STM/TARGET_STM32L0/device/stm32l0xx_hal_rcc.h" - } else { - bat "sed -i 's/define symbol __size_heap__ = 0x800;/define symbol __size_heap__ = 0x1000;/' \ - mbed-os/targets/TARGET_STM/TARGET_STM32L0/TARGET_STM32L0x2xZ/device/TOOLCHAIN_IAR/stm32l082xZ.icf" - bat "sed -i 's/#define RCC_HSICALIBRATION_DEFAULT ((uint32_t)0x10)/#define RCC_HSICALIBRATION_DEFAULT ((uint32_t)0x16)/' \ - mbed-os/targets/TARGET_STM/TARGET_STM32L0/device/stm32l0xx_hal_rcc.h" - } + execute("sed -i 's/define symbol __size_heap__ = 0x800;/define symbol __size_heap__ = 0x1000;/' \ + mbed-os/targets/TARGET_STM/TARGET_STM32L0/TARGET_STM32L0x2xZ/device/TOOLCHAIN_IAR/stm32l082xZ.icf") + execute("sed -i 's/#define RCC_HSICALIBRATION_DEFAULT ((uint32_t)0x10)/#define RCC_HSICALIBRATION_DEFAULT ((uint32_t)0x16)/' \ + mbed-os/targets/TARGET_STM/TARGET_STM32L0/device/stm32l0xx_hal_rcc.h") } if ("${target}" == "MTB_MTS_XDOT") { - if (isUnix()) { - sh "sed -i 's/define symbol __size_heap__ = 0x800;/define symbol __size_heap__ = 0x1800;/' \ - mbed-os/targets/TARGET_STM/TARGET_STM32L1/TARGET_MTB_MTS_XDOT/device/TOOLCHAIN_IAR/stm32l152xc.icf" - } else { - bat "sed -i 's/define symbol __size_heap__ = 0x800;/define symbol __size_heap__ = 0x1800;/' \ - mbed-os/targets/TARGET_STM/TARGET_STM32L1/TARGET_MTB_MTS_XDOT/device/TOOLCHAIN_IAR/stm32l152xc.icf" - } + execute("sed -i 's/define symbol __size_heap__ = 0x800;/define symbol __size_heap__ = 0x1800;/' \ + mbed-os/targets/TARGET_STM/TARGET_STM32L1/TARGET_MTB_MTS_XDOT/device/TOOLCHAIN_IAR/stm32l152xc.icf") } - - if (isUnix()) { - sh "mbed compile --build out/${target}_${toolchain}/ -m ${target} -t ${toolchain} -c" - } else { - bat "mbed compile --build out/${target}_${toolchain}/ -m ${target} -t ${toolchain} -c" - } + execute("mbed compile --build out/${target}_${toolchain}/ -m ${target} -t ${toolchain} -c") } stash name: "${target}_${toolchain}", includes: '**/mbed-os-example-lorawan.bin' archive '**/mbed-os-example-lorawan.bin' @@ -144,3 +132,38 @@ } } } + +def build_regions(regions) { + return { + stage ("region_builder_K64F_GCC_ARM") { + node ("arm-none-eabi-gcc") { + deleteDir() + dir("mbed-os-example-lorawan") { + checkout scm + execute("mbed deploy --protocol ssh") + + if (env.MBED_OS_REVISION != '') { + dir("mbed-os") { + if (env.MBED_OS_REVISION.matches('pull/\\d+/head')) { + execute("git fetch origin ${env.MBED_OS_REVISION}:_PR_") + execute("git checkout _PR_") + } else { + execute("git checkout ${env.MBED_OS_REVISION}") + } + } + } + //Initial sed to string format for find & replacing + execute("sed -i 's/\"lora.phy\": 0,/\"lora.phy\": \"0\",/' mbed_app.json") + //lora.phy 0 build tested above already + for (int i = 1; i < regions.size(); i++) { + def curr_region = regions.get(i) + def prev_region = regions.get(i-1) + execute("sed -i 's/\"lora.phy\": ${prev_region},/\"lora.phy\": ${curr_region},/' mbed_app.json") + echo "Building region: ${curr_region}" + execute("mbed compile -t GCC_ARM -m K64F") + } + } + } + } + } +}