1 #
  2 # Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
  3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4 #
  5 # This code is free software; you can redistribute it and/or modify it
  6 # under the terms of the GNU General Public License version 2 only, as
  7 # published by the Free Software Foundation.  Oracle designates this
  8 # particular file as subject to the "Classpath" exception as provided
  9 # by Oracle in the LICENSE file that accompanied this code.
 10 #
 11 # This code is distributed in the hope that it will be useful, but WITHOUT
 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 13 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 14 # version 2 for more details (a copy is included in the LICENSE file that
 15 # accompanied this code).
 16 #
 17 # You should have received a copy of the GNU General Public License version
 18 # 2 along with this work; if not, write to the Free Software Foundation,
 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 20 #
 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 22 # or visit www.oracle.com if you need additional information or have any
 23 # questions.
 24 #
 25 
 26 name: 'Build (windows)'
 27 
 28 on:
 29   workflow_call:
 30     inputs:
 31       platform:
 32         required: true
 33         type: string
 34       extra-conf-options:
 35         required: false
 36         type: string
 37       make-target:
 38         required: false
 39         type: string
 40         default: 'product-bundles test-bundles'
 41       debug-levels:
 42         required: false
 43         type: string
 44         default: '[ "debug", "release" ]'
 45       msvc-toolset-version:
 46         required: true
 47         type: string
 48       msvc-toolset-architecture:
 49         required: true
 50         type: string
 51       configure-arguments:
 52         required: false
 53         type: string
 54       make-arguments:
 55         required: false
 56         type: string
 57       dry-run:
 58         required: false
 59         type: boolean
 60         default: false
 61 
 62 env:
 63   # These are needed to make the MSYS2 bash work properly
 64   MSYS2_PATH_TYPE: minimal
 65   CHERE_INVOKING: 1
 66 
 67 jobs:
 68   build-windows:
 69     name: build
 70     runs-on: windows-2025
 71     defaults:
 72       run:
 73         shell: bash
 74 
 75     strategy:
 76       fail-fast: false
 77       matrix:
 78         debug-level: ${{ fromJSON(inputs.debug-levels) }}
 79         include:
 80           - debug-level: debug
 81             flags: --with-debug-level=fastdebug
 82             suffix: -debug
 83 
 84     steps:
 85       - name: 'Checkout the JDK source'
 86         uses: actions/checkout@v4
 87 
 88       - name: 'Get MSYS2'
 89         uses: ./.github/actions/get-msys2
 90 
 91       - name: 'Get the BootJDK'
 92         id: bootjdk
 93         uses: ./.github/actions/get-bootjdk
 94         with:
 95           platform: windows-x64
 96 
 97       - name: 'Get JTReg'
 98         id: jtreg
 99         uses: ./.github/actions/get-jtreg
100 
101       - name: 'Get GTest'
102         id: gtest
103         uses: ./.github/actions/get-gtest
104 
105       - name: 'Check toolchain installed'
106         id: toolchain-check
107         run: |
108           set +e
109           '/c/Program Files/Microsoft Visual Studio/2022/Enterprise/vc/auxiliary/build/vcvars64.bat' -vcvars_ver=${{ inputs.msvc-toolset-version }}
110           if [ $? -eq 0 ]; then
111             echo "Toolchain is already installed"
112             echo "toolchain-installed=true" >> $GITHUB_OUTPUT
113           else
114             echo "Toolchain is not yet installed"
115             echo "toolchain-installed=false" >> $GITHUB_OUTPUT
116           fi
117 
118       - name: 'Install toolchain and dependencies'
119         run: |
120           # Run Visual Studio Installer
121           '/c/Program Files (x86)/Microsoft Visual Studio/Installer/vs_installer.exe' \
122             modify --quiet --installPath 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise' \
123             --add Microsoft.VisualStudio.Component.VC.${{ inputs.msvc-toolset-version }}.${{ inputs.msvc-toolset-architecture }}
124         if: steps.toolchain-check.outputs.toolchain-installed != 'true'
125 
126       - name: 'Configure'
127         run: >
128           bash configure
129           --with-conf-name=${{ inputs.platform }}
130           ${{ matrix.flags }}
131           --with-version-opt=${GITHUB_ACTOR}-${GITHUB_SHA}
132           --with-boot-jdk=${{ steps.bootjdk.outputs.path }}
133           --with-jtreg=${{ steps.jtreg.outputs.path }}
134           --with-gtest=${{ steps.gtest.outputs.path }}
135           --with-msvc-toolset-version=${{ inputs.msvc-toolset-version }}
136           --with-jmod-compress=zip-1
137           --disable-jvm-feature-shenandoahgc
138           ${{ inputs.extra-conf-options }} ${{ inputs.configure-arguments }} || (
139           echo "Dumping config.log:" &&
140           cat config.log &&
141           exit 1)
142         env:
143           # We need a minimal PATH on Windows
144           # Set PATH to "", so just GITHUB_PATH is included
145           PATH: ''
146         shell: env /usr/bin/bash --login -eo pipefail {0}
147         if: ${{ inputs.dry-run == false }}
148 
149       - name: 'Build'
150         id: build
151         uses: ./.github/actions/do-build
152         with:
153           make-target: '${{ inputs.make-target }} ${{ inputs.make-arguments }}'
154           platform: ${{ inputs.platform }}
155           debug-suffix: '${{ matrix.suffix }}'
156         if: ${{ inputs.dry-run == false }}
157 
158       - name: 'Upload bundles'
159         uses: ./.github/actions/upload-bundles
160         with:
161           platform: ${{ inputs.platform }}
162           debug-suffix: '${{ matrix.suffix }}'
163         if: ${{ inputs.dry-run == false }}