- job:
    name: jdk11-build-image
    project-type: matrix
    defaults: global
    description: |
        * Configures and builds jdk11 (ie, bin/java, bin/javac, et al) for various configurations.<br>
        * The source tarball is copied from the jdk11-update-src-tree job.<br>
        * <b>Note:</b> we are no longer building -fastdebug variants as there is not enough time to test the images.
    properties:
        - authorization:
            anonymous:
                - job-read
                - job-extended-read
            openjdk-members:
                - job-build
                - job-cancel
                - job-workspace
        - build-discarder:
            days-to-keep: 30
            num-to-keep: 10
            artifact-num-to-keep: 5
    disabled: true
    node: j12-qrep-01
    display-name: 'DELETE ME'
    axes:
        - axis:
            type: user-defined
            name: BUILD_TYPE
            values:
                - release
        - axis:
            type: slave
            name: label
            values:
                - j12-qrep-01
    execution-strategy:
        sequential: true
    wrappers:
        - workspace-cleanup:
            dirmatch: false
        - timestamps
        - matrix-tie-parent:
            node: j12-qrep-01
    builders:
        - copyartifact:
            project: jdk11-update-src-tree
            filter: 'out/jdk11u.tar.gz'
            target: incoming
            flatten: true
        - shell: |
            #!/bin/bash

            set -exu

            ccache_build_opts=--disable-ccache

            rm -rf jdk* primordial-jdk* build* out

            cd $HOME/srv/jdk-cache/jdk10
            export JAVA_HOME=${PWD}

            export PATH=${JAVA_HOME}/bin:${PATH}

            cd ${WORKSPACE}

            # Extract sources from upstream job
            tar xf incoming/jdk11u.tar.gz

            shopt -s nullglob



            # Configure and build.
            mkdir -p build-stage1 build-stage2 out

            two_stage_build=0

            which java
            java -version

            if [ $two_stage_build = 1 ]; then
              pushd build-stage1
              sh ../jdk11u/configure --with-debug-level=${BUILD_TYPE} --with-boot-jdk=${WORKSPACE}/primordial-jdk11 ${ccache_build_opts} --disable-warnings-as-errors
              make images build-test-hotspot-jtreg-native build-test-jdk-jtreg-native
              popd

              pushd build-stage2
              sh ../jdk11u/configure --with-debug-level=${BUILD_TYPE} --with-boot-jdk=${WORKSPACE}/build-stage1/images/jdk ${ccache_build_opts} --disable-warnings-as-errors
              make images build-test-hotspot-jtreg-native build-test-jdk-jtreg-native test-image-hotspot-gtest
              popd
            else
              pushd build-stage2
              sh ../jdk11u/configure --with-debug-level=${BUILD_TYPE} ${ccache_build_opts} --disable-warnings-as-errors
              make images build-test-hotspot-jtreg-native build-test-jdk-jtreg-native test-image-hotspot-gtest
              popd
            fi

            # Archive the result
            artifact_name=jdk11u-${BUILD_TYPE}
            tar -C build-stage2/images/jdk --exclude=\*.diz --transform="s!^./!$artifact_name/!" -acf out/${artifact_name}.tar.gz .

            # Copy gtest materials to the correct place.
            ( cd build-stage2
              mkdir support/test/hotspot/jtreg/native/lib/server
              cp -r hotspot/variant-server/libjvm/gtest/gtestLauncher hotspot/variant-server/libjvm/gtest/libjvm.so support/test/hotspot/jtreg/native/lib/server
            )

            # Archive test support files.
            tar -C build-stage2/ --exclude=hotspot/jtreg/native/support/\* --transform="s!^support/!${artifact_name}-support/support/!" -acf out/${artifact_name}-support.tar.gz support/test
    publishers:
        - archive:
            artifacts: 'out/*.tar.gz'
        - email:
            recipients: 'stuart.monteith@linaro.org fathi.boudra@linaro.org'
