1 #
2 # Copyright (c) 2022, 2025, 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 runs-on:
35 required: true
36 type: string
37 extra-conf-options:
38 required: false
39 type: string
40 make-target:
41 required: false
42 type: string
43 default: 'product-bundles test-bundles'
44 debug-levels:
45 required: false
46 type: string
47 default: '[ "debug", "release" ]'
48 msvc-toolset-version:
49 required: true
50 type: string
51 architecture:
52 required: true
53 type: string
54 configure-arguments:
55 required: false
56 type: string
57 make-arguments:
58 required: false
59 type: string
60 dry-run:
61 required: false
62 type: boolean
63 default: false
64
65 env:
66 # These are needed to make the MSYS2 bash work properly
67 MSYS2_PATH_TYPE: minimal
68 CHERE_INVOKING: 1
69
70 jobs:
71 build-windows:
72 name: build
73 runs-on: ${{ inputs.runs-on }}
74 defaults:
75 run:
76 shell: bash
77
78 strategy:
79 fail-fast: false
80 matrix:
81 debug-level: ${{ fromJSON(inputs.debug-levels) }}
82 include:
83 - debug-level: debug
84 flags: --with-debug-level=fastdebug
85 suffix: -debug
86
87 steps:
88 - name: 'Checkout the JDK source'
89 uses: actions/checkout@v6
90
91 - name: 'Get MSYS2'
92 uses: ./.github/actions/get-msys2
93 with:
94 architecture: ${{ inputs.architecture }}
95
96 - name: 'Get the BootJDK'
97 id: bootjdk
98 uses: ./.github/actions/get-bootjdk
99 with:
100 platform: ${{ inputs.platform }}
101
102 - name: 'Get JTReg'
103 id: jtreg
104 uses: ./.github/actions/get-jtreg
105
106 - name: 'Get GTest'
107 id: gtest
108 uses: ./.github/actions/get-gtest
109
110 - name: 'Check toolchain installed for x64'
111 id: toolchain-check-x64
112 run: |
113 set +e
114 '/c/Program Files/Microsoft Visual Studio/2022/Enterprise/vc/auxiliary/build/vcvars64.bat' -vcvars_ver=${{ inputs.msvc-toolset-version }}
115 if [ $? -eq 0 ]; then
116 echo "Toolchain is already installed for x64"
117 echo "toolchain-installed=true" >> $GITHUB_OUTPUT
118 else
119 echo "Toolchain is not yet installed for x64"
120 echo "toolchain-installed=false" >> $GITHUB_OUTPUT
121 fi
122 if: ${{ inputs.architecture == 'x86.x64' }}
123
124 - name: 'Check toolchain installed for ARM64'
125 id: toolchain-check-arm64
126 run: |
127 set +e
128 "/c/Program Files/Microsoft Visual Studio/2022/Enterprise/vc/auxiliary/build/vcvarsarm64.bat" -vcvars_ver=${{ inputs.msvc-toolset-version }}
129 if [ $? -eq 0 ]; then
130 echo "Toolchain is already installed for ARM64"
131 echo "toolchain-installed=true" >> $GITHUB_OUTPUT
132 else
133 echo "Toolchain is not yet installed for ARM64"
134 echo "toolchain-installed=false" >> $GITHUB_OUTPUT
135 fi
136 if: ${{ inputs.architecture == 'ARM64' }}
137
138 - name: 'Install toolchain and dependencies for x64'
139 run: |
140 # Run Visual Studio Installer
141 '/c/Program Files (x86)/Microsoft Visual Studio/Installer/vs_installer.exe' \
142 modify --quiet --installPath 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise' \
143 --add Microsoft.VisualStudio.Component.VC.${{ inputs.msvc-toolset-version }}.x86.x64
144 if: ${{ (inputs.architecture == 'x86.x64') && (steps.toolchain-check-x64.outputs.toolchain-installed != 'true') }}
145
146 - name: 'Install toolchain and dependencies for ARM64'
147 run: |
148 # Run Visual Studio Installer
149 '/c/Program Files (x86)/Microsoft Visual Studio/Installer/vs_installer.exe' \
150 modify --quiet --installPath 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise' \
151 --add Microsoft.VisualStudio.Component.VC.${{ inputs.msvc-toolset-version }}.ARM64
152 if: ${{ ( inputs.architecture == 'ARM64') && (steps.toolchain-check-arm64.outputs.toolchain-installed != 'true') }}
153
154 - name: 'Configure'
155 run: >
156 bash configure
157 --with-conf-name=${{ inputs.platform }}
158 ${{ matrix.flags }}
159 --with-version-opt=${GITHUB_ACTOR}-${GITHUB_SHA}
160 --with-boot-jdk=${{ steps.bootjdk.outputs.path }}
161 --with-jtreg=${{ steps.jtreg.outputs.path }}
162 --with-gtest=${{ steps.gtest.outputs.path }}
163 --with-msvc-toolset-version=${{ inputs.msvc-toolset-version }}
164 --with-jmod-compress=zip-1
165 --disable-jvm-feature-shenandoahgc
166 --with-external-symbols-in-bundles=none
167 ${{ inputs.extra-conf-options }} ${{ inputs.configure-arguments }} || (
168 echo "Dumping config.log:" &&
169 cat config.log &&
170 exit 1)
171 env:
172 # We need a minimal PATH on Windows
173 # Set PATH to "", so just GITHUB_PATH is included
174 PATH: ''
175 shell: env /usr/bin/bash --login -eo pipefail {0}
176 if: ${{ inputs.dry-run == false }}
177
178 - name: 'Build'
179 id: build
180 uses: ./.github/actions/do-build
181 with:
182 make-target: '${{ inputs.make-target }} ${{ inputs.make-arguments }}'
183 platform: ${{ inputs.platform }}
184 debug-suffix: '${{ matrix.suffix }}'
185 if: ${{ inputs.dry-run == false }}
186
187 - name: 'Upload bundles'
188 uses: ./.github/actions/upload-bundles
189 with:
190 platform: ${{ inputs.platform }}
191 debug-suffix: '${{ matrix.suffix }}'
192 if: ${{ inputs.dry-run == false }}