summaryrefslogtreecommitdiff
path: root/.gitlab-ci.yml
blob: 09b30433c9345c06132c533d83fb8c7fcbcdc922 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
image: $CI_IMAGE

variables:
# uncomment for the pipeline debug purpose 
# CI_DEBUG_TRACE: "true"
  
# Please choose possible 32/64 builder image and appropriate compiler
  CI_IMAGE: gitlab.int.toradex.com:4567/yuiry.erofeev/linux-toradex/ci-kernel-builder:latest
  #CI_IMAGE: gitlab.int.toradex.com:4567/yuiry.erofeev/linux-toradex/ci-kernel-builder:aarch64
  #CI_IMAGE: gitlab.int.toradex.com:4567/yuiry.erofeev/linux-toradex/ci-kernel-builder:aarch64-linaro
  DOCKER_HOST: tcp://docker:2375
  DOCKER_DRIVER: overlay2
  DOCKER_TLS_CERTDIR: ""
  
# Kernel Configuration Section 
# Supplementary Tool Section 
 # Artifacts configuring section  
  KERNEL_CONFIG_BUILD_LOG_FILE_NAME: build_config.log
  KERNEL_BUILD_LOG_FILE_NAME: build.log
  KERNEL_CONFIGURATION_FILE: .config
# Defining temporary build folder to do outside of the box builds.  Absolute path
  TEMP_BUILD_FOLDER: /builds/temp-builds
  
stages:
  - build-product

.build_base:
  stage: build-product
  variables:
   GIT_STRATEGY: fetch
#  we are only using 3 latest commits to speed up the fetch process, as we are running pipeline each time we do a commit or a MR  https://docs.gitlab.com/ee/ci/large_repositories/index.html#shallow-cloning
   GIT_DEPTH: "3"
#  To run just on merge request 
#  only:
#     - merge_requests
#  when: manual
  script: | 
    #set -o xtrace
    cd $CI_PROJECT_DIR
    echo -e "Compiler used to build binaries is"
    which ${CROSS_COMPILE}gcc
    ${CROSS_COMPILE}gcc --version
    echo -e "Arch is \e[36m$ARCH\e[39m"
    THREADS=$(grep processor /proc/cpuinfo -c)
    # due to specific of the kernel build we need to use the latest configuration from the nightly builds. We are getting $Version dynamically , as a variable , based on parsing URL page with Nightly builds ID  
    rm -f index.html 
    wget http://artifactory-horw.int.toradex.com/artifactory/list/torizoncore-oe-prerelease-horw/dunfell-5.x.y/nightly/
    version=$( cat index.html| grep ^"<a" | sed -e 's/[<>="//]/ /g' | awk '{ print $3}' | sort -nrk1,1 | head -1)
    wget http://artifactory-horw.int.toradex.com/artifactory/list/torizoncore-oe-prerelease-horw/dunfell-5.x.y/nightly/$version/$KERNEL_FILE_PATH/oedeploy/kernel-config
    mkdir -p $TEMP_BUILD_FOLDER
    cp kernel-config $TEMP_BUILD_FOLDER/$KERNEL_CONFIGURATION_FILE
    ##### 
    make O=$TEMP_BUILD_FOLDER -j $THREADS 2>&1 | tee $KERNEL_BUILD_LOG_FILE_NAME
  artifacts:
    when: always
    name: "$CI_COMMIT_REF_NAME" 
    paths:
      - $KERNEL_BUILD_LOG_FILE_NAME
      #As we do not generate config for 5.x and use generated one,  we have just kernel config and kernel build log
      - kernel-config
  allow_failure: true
  after_script:
    - set -o xtrace
    - rm -rf $TEMP_BUILD_FOLDER

      # If you need additional products build just copy-paste build_******_product section with new config name 
build_default_defconfig :
  extends: .build_base
  variables:
    # Defining the path, which we will use to take a config file  to build a kernel 
   KERNEL_FILE_PATH:  colibri-imx7/torizon-upstream/torizon-core-docker
  stage: build-product