Skip to content

Commit

Permalink
Add on demand 'build' and 'tag release' for static libs (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinayagarwal authored Sep 3, 2024
1 parent deb4256 commit 4c9a901
Show file tree
Hide file tree
Showing 9 changed files with 811 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/actions/do-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ runs:
- name: 'Build'
id: build
run: >
make LOG=info ${{ inputs.make-target }}
make LOG=cmdlines,info ${{ inputs.make-target }}
|| bash ./.github/scripts/gen-build-failure-report.sh "$GITHUB_STEP_SUMMARY"
shell: bash

Expand Down
83 changes: 81 additions & 2 deletions .github/actions/upload-bundles/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -32,6 +32,9 @@ inputs:
debug-suffix:
description: 'File name suffix denoting debug level, possibly empty'
required: false
make-target:
description: 'Make target'
required: false

runs:
using: composite
Expand Down Expand Up @@ -68,10 +71,86 @@ runs:
fi
shell: bash

- name: 'Create libjdk.a'
run: |
cd build
mkdir -p allobjs
cd allobjs
find .. -name "*.a" -exec ar x {} \;
ar rcs ../libjdk.a *.o
cd ..
rm -rf allobjs
shell: bash
if: inputs.make-target == 'static-libs' && inputs.debug-suffix != '-debug' && !startsWith(inputs.platform, 'windows')

- name: 'List all *.lib files'
run: |
Get-ChildItem -Path .\build -Filter *.lib -Recurse
shell: pwsh
if: inputs.make-target == 'static-libs' && inputs.debug-suffix != '-debug' && startsWith(inputs.platform, 'windows')

- name: 'Create libjdk.lib for windows'
run: |
# Define the root path where to start the search
$searchRoot = "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC"
# Search for lib.exe using a wildcard for the version
$libPath = Get-ChildItem -Path $searchRoot -Recurse -Filter "lib.exe" -ErrorAction SilentlyContinue | Where-Object { $_.FullName -like "*14.29*\bin\Hostx64\x64\lib.exe" }
# Check if libPath is not empty
if ($libPath) {
# Store the full path of the first found lib.exe (if there are multiple, you can adjust as needed)
$libPath = $libPath[0].FullName
Write-Output "Found lib.exe at: $libPath"
# Change directory to where .lib files are located
cd build
# Collect all .lib files in the directory and subdirectories
$libFiles = Get-ChildItem -Path . -Filter *.lib -Recurse | Select-Object -ExpandProperty FullName
# Check if any .lib files were found
if ($libFiles.Count -eq 0) {
Write-Output "No .lib files found in the specified directory."
exit 1
}
# Prepare the command arguments
$arguments = "/OUT:libjdk.lib " + ($libFiles -join " ")
# Construct the command
$command = "& `"$libPath`" $arguments"
# Execute the command
Write-Output "Executing command: $command"
Invoke-Expression $command
# Check if the output file was created
if (Test-Path "libjdk.lib") {
Write-Output "Successfully created libjdk.lib"
} else {
Write-Output "Failed to create libjdk.lib"
exit 1
}
} else {
Write-Output "lib.exe not found."
exit 1
}
shell: pwsh
if: inputs.make-target == 'static-libs' && inputs.debug-suffix != '-debug' && startsWith(inputs.platform, 'windows')

- name: 'Upload bundles artifact'
uses: actions/upload-artifact@v4
with:
name: bundles-${{ inputs.platform }}${{ inputs.debug-suffix }}
path: bundles
retention-days: 1
if: steps.bundles.outputs.bundles-found == 'true'
if: steps.bundles.outputs.bundles-found == 'true' && inputs.make-target != 'static-libs'

- name: 'Upload static image artifact'
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.platform }}
path: build/libjdk.*
retention-days: 1
if: inputs.make-target == 'static-libs' && inputs.debug-suffix != '-debug'
149 changes: 149 additions & 0 deletions .github/workflows/build-android-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
#
# Copyright (c) 2024, Gluon and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#

name: 'Build (android)'

on:
workflow_call:
inputs:
platform:
required: true
type: string
extra-conf-options:
required: false
type: string
make-target:
required: false
type: string
default: 'static-libs'
debug-levels:
required: false
type: string
default: '[ "release" ]'
gcc-major-version:
required: true
type: string
gcc-package-suffix:
required: false
type: string
default: ''
apt-architecture:
required: false
type: string
apt-extra-packages:
required: false
type: string
configure-arguments:
required: false
type: string
make-arguments:
required: false
type: string

jobs:
build-android:
name: build
runs-on: ubuntu-22.04

steps:
- name: 'Checkout the JDK source'
uses: actions/checkout@v4

- name: 'Get the BootJDK'
id: bootjdk
uses: ./.github/actions/get-bootjdk
with:
platform: linux-x64

- name: 'Get JTReg'
id: jtreg
uses: ./.github/actions/get-jtreg

- name: 'Get GTest'
id: gtest
uses: ./.github/actions/get-gtest

- name: 'Set architecture'
id: arch
run: |
# Set a proper suffix for packages if using a different architecture
if [[ '${{ inputs.apt-architecture }}' != '' ]]; then
echo 'suffix=:${{ inputs.apt-architecture }}' >> $GITHUB_OUTPUT
fi
# Upgrading apt to solve libc6 installation bugs, see JDK-8260460.
- name: 'Install toolchain and dependencies'
run: |
# Install dependencies using apt-get
if [[ '${{ inputs.apt-architecture }}' != '' ]]; then
sudo dpkg --add-architecture ${{ inputs.apt-architecture }}
fi
sudo apt-get update
sudo apt-get install --only-upgrade apt
sudo apt-get install gcc-${{ inputs.gcc-major-version }}${{ inputs.gcc-package-suffix }} g++-${{ inputs.gcc-major-version }}${{ inputs.gcc-package-suffix }} libxrandr-dev${{ steps.arch.outputs.suffix }} libxtst-dev${{ steps.arch.outputs.suffix }} libcups2-dev${{ steps.arch.outputs.suffix }} libasound2-dev${{ steps.arch.outputs.suffix }} ${{ inputs.apt-extra-packages }}
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${{ inputs.gcc-major-version }} 100 --slave /usr/bin/g++ g++ /usr/bin/g++-${{ inputs.gcc-major-version }}
- name: 'Android NDK'
uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r26c
add-to-path: false

- name: 'Configure'
run: >
bash configure
--with-conf-name=android-linux-aarch64
--enable-headless-only
--with-boot-jdk=${{ steps.bootjdk.outputs.path }}
--with-toolchain-path=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin
--with-sysroot=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/sysroot
--with-toolchain-type=clang
--with-jvm-variants=minimal
--host=aarch64-linux-android
--target=aarch64-linux-android
--with-version-opt=${GITHUB_ACTOR}-${GITHUB_SHA}
${{ matrix.flags }}
${{ inputs.extra-conf-options }} ${{ inputs.configure-arguments }} || (
echo "Dumping config.log:" &&
cat config.log &&
exit 1)
env:
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}

- name: 'Build'
id: build
uses: ./.github/actions/do-build
with:
make-target: '${{ inputs.make-target }} ${{ inputs.make-arguments }}'
platform: ${{ inputs.platform }}
debug-suffix: '${{ matrix.suffix }}'

- name: 'Upload bundles'
uses: ./.github/actions/upload-bundles
with:
platform: ${{ inputs.platform }}
debug-suffix: '${{ matrix.suffix }}'
make-target: 'static-libs'
118 changes: 118 additions & 0 deletions .github/workflows/build-ios-macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#
# Copyright (c) 2024, Gluon and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#

name: 'Build (ios)'

on:
workflow_call:
inputs:
platform:
required: true
type: string
runs-on:
required: true
type: string
extra-conf-options:
required: false
type: string
make-target:
required: false
type: string
default: 'static-libs'
debug-levels:
required: false
type: string
default: '[ "release" ]'
xcode-toolset-version:
required: true
type: string
configure-arguments:
required: false
type: string
make-arguments:
required: false
type: string

jobs:
build-macos:
name: build
runs-on: ${{ inputs.runs-on }}

steps:
- name: 'Checkout the JDK source'
uses: actions/checkout@v4

- name: 'Get the BootJDK'
id: bootjdk
uses: ./.github/actions/get-bootjdk
with:
platform: macos-aarch64

- name: 'Get JTReg'
id: jtreg
uses: ./.github/actions/get-jtreg

- name: 'Get GTest'
id: gtest
uses: ./.github/actions/get-gtest

- name: 'Install toolchain and dependencies'
run: |
# Run Homebrew installation and xcode-select
brew install autoconf make
sudo xcode-select --switch /Applications/Xcode_${{ inputs.xcode-toolset-version }}.app/Contents/Developer
# This will make GNU make available as 'make' and not only as 'gmake'
echo '/usr/local/opt/make/libexec/gnubin' >> $GITHUB_PATH
wget -P /tmp https://github.com/apple/cups/archive/refs/tags/v2.3.6.zip && unzip /tmp/v2.3.6.zip -d /tmp
- name: 'Configure'
run: >
bash configure
--with-conf-name=ios-macos-aarch64
--enable-headless-only
--with-boot-jdk=${{ steps.bootjdk.outputs.path }}
--openjdk-target=aarch64-macos-ios
--with-cups-include=/tmp/cups-2.3.6
--with-sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk
--with-version-opt=${GITHUB_ACTOR}-${GITHUB_SHA}
${{ matrix.flags }}
${{ inputs.extra-conf-options }} ${{ inputs.configure-arguments }} || (
echo "Dumping config.log:" &&
cat config.log &&
exit 1)
- name: 'Build'
id: build
uses: ./.github/actions/do-build
with:
make-target: '${{ inputs.make-target }} ${{ inputs.make-arguments }}'
platform: ${{ inputs.platform }}
debug-suffix: '${{ matrix.suffix }}'

- name: 'Upload bundles'
uses: ./.github/actions/upload-bundles
with:
platform: ${{ inputs.platform }}
debug-suffix: '${{ matrix.suffix }}'
make-target: 'static-libs'
1 change: 1 addition & 0 deletions .github/workflows/build-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,4 @@ jobs:
with:
platform: ${{ inputs.platform }}
debug-suffix: '${{ matrix.suffix }}'
make-target: 'static-libs'
1 change: 1 addition & 0 deletions .github/workflows/build-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,4 @@ jobs:
with:
platform: ${{ inputs.platform }}
debug-suffix: '${{ matrix.suffix }}'
make-target: 'static-libs'
1 change: 1 addition & 0 deletions .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,4 @@ jobs:
with:
platform: ${{ inputs.platform }}
debug-suffix: '${{ matrix.suffix }}'
make-target: 'static-libs'
Loading

0 comments on commit 4c9a901

Please sign in to comment.