Skip to content

Commit c2df13a

Browse files
committed
Merge remote-tracking branch 'origin/main' into feature/event-throttle-time
2 parents 39c6e6d + 30543a6 commit c2df13a

File tree

123 files changed

+2686
-665
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+2686
-665
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: 'native-tools-setup'
2+
description: 'Set Up GraalVM Native Image Tools'
3+
inputs:
4+
binary-directory:
5+
required: true
6+
trace-directory:
7+
required: false
8+
default: ""
9+
runs:
10+
using: "composite"
11+
steps:
12+
- name: "Setting up GraalVM/Java Environment"
13+
run: |
14+
echo "Run Native Image Build"
15+
if [ -d "${{ inputs.trace-directory }}" ]; then
16+
export CLASSPATH="`cd ${{ inputs.trace-directory }}/../..; pwd`:${CLASSPATH}"
17+
fi
18+
# Attempt to use the action path to find native-images. If this fails, use a relative path in hopes
19+
# the working directory is the root of the repository.
20+
#
21+
# Docker containers don't seem to get the action path set correctly, so we need the relative path fallback.
22+
if [ -f "${{ github.action_path }}/native-images" ]
23+
then
24+
"${{ github.action_path }}/native-images" ${{ inputs.binary-directory }}
25+
else
26+
./.github/actions/build-native-images/native-images ${{ inputs.binary-directory }}
27+
fi
28+
shell: bash
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
3+
# Print and evaluate
4+
evalp()
5+
{
6+
echo "$@"
7+
"$@"
8+
}
9+
10+
# Get tool names from a directory
11+
get_tool_names()
12+
{
13+
dir=$1
14+
for file in $dir/*.jar
15+
do
16+
basename $file .jar
17+
done
18+
}
19+
20+
# Check arguments
21+
if [ ! -d "$1" ]
22+
then
23+
echo "[ERROR] Must supply binary directory"
24+
exit 1
25+
fi
26+
# Calculate directories
27+
tool_dir="$1"
28+
native_dir="${tool_dir}-native"
29+
native_final="${tool_dir}-final"
30+
mkdir -p "${native_dir}"
31+
mkdir -p "${native_final}"
32+
# Remove $1
33+
shift;
34+
tool_names="$@"
35+
if [[ "${tool_names}" == "" ]]
36+
then
37+
tool_names="$(get_tool_names ${tool_dir})"
38+
fi
39+
40+
# Generate a native emage
41+
for tool_name in $tool_names
42+
do
43+
jar_file="$tool_dir/$tool_name.jar"
44+
out_file="$native_dir/$tool_name"
45+
echo "Building $out_file"
46+
class_path="${CLASSPATH}"
47+
evalp "$GRAALVM_JAVA_HOME/bin/native-image" -H:PageSize=65536 -cp "${class_path}" $FPP_NATIVE_IMAGE_FLAGS \
48+
--no-fallback --install-exit-handlers \
49+
-jar "$jar_file" "$out_file"
50+
if [ $? -ne 0 ]
51+
then
52+
echo "[ERROR] Failed to build $out_file"
53+
exit 1
54+
fi
55+
sync; sync; sync; # Magic to fix filesystem woes
56+
cp "${out_file}" "${native_final}"
57+
done
58+
mv "$tool_dir" "$tool_dir.old"
59+
mv "$native_final" "$tool_dir"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: 'native-tools-setup'
2+
description: 'Set Up GraalVM Native Image Tools'
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: "Setting up GraalVM/Java Environment"
7+
run: |
8+
echo "Setup GraalVM Environment"
9+
# Attempt to use the action path to find env-setup. If this fails, use a relative path in hopes
10+
# the working directory is the root of the repository.
11+
#
12+
# Docker containers don't seem to get the action path set correctly, so we need the relative path fallback.
13+
if [ -f "${{ github.action_path }}/env-setup" ]
14+
then
15+
"${{ github.action_path }}/env-setup"
16+
else
17+
./.github/actions/native-tools-setup/env-setup
18+
fi
19+
shell: bash
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
3+
# Resolve architecture. Note: this is dependent on the graal version
4+
graal_arch="$(uname -m)"
5+
6+
# Override graal_arch when on amd64
7+
if [[ "$graal_arch" == "x86_64" ]] || [[ "$graal_arch" == "x64" ]]
8+
then
9+
graal_arch="amd64"
10+
elif [[ "$graal_arch" == "arm64" ]] || [[ "$graal_arch" == "aarch64" ]]
11+
then
12+
graal_arch="aarch64"
13+
fi
14+
15+
graal_ver="22.3.0"
16+
graal_os="$( uname -s | tr "[:upper:]" "[:lower:]")"
17+
graal_ar="graalvm-ce-java11-${graal_os}-${graal_arch}-${graal_ver}.tar.gz"
18+
graal_dir="$(pwd)/graalvm-ce-java11-${graal_ver}"
19+
graal_url="https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${graal_ver}/${graal_ar}"
20+
21+
# Start fresh
22+
if [ -d "${graal_dir}" ]
23+
then
24+
rm -r "${graal_dir}"
25+
fi
26+
27+
28+
# Download Graal
29+
echo "Downloading GraalVM from: ${graal_url}"
30+
curl -L "${graal_url}" > "${graal_ar}"
31+
tar -xzf "${graal_ar}"
32+
graal_bin="${graal_dir}/bin"
33+
if [ ! -d "${graal_bin}" ]
34+
then
35+
graal_bin="${graal_dir}/Contents/Home/bin"
36+
fi
37+
export PATH="${graal_bin}:${PATH}"
38+
export GRAALVM_JAVA_HOME="$(dirname ${graal_bin})"
39+
# Install native image
40+
${graal_bin}/gu install native-image
41+
42+
if [ -n "$GITHUB_ENV" ]
43+
then
44+
echo PATH="${PATH}" >> $GITHUB_ENV
45+
echo GRAALVM_JAVA_HOME="${GRAALVM_JAVA_HOME}" >> $GITHUB_ENV
46+
fi

.github/workflows/build-native.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,5 @@ jobs:
1717
build: ./compiler/install
1818
test: ./compiler/test
1919
output-directory: ./compiler/bin
20-
meta-package: fpp
21-
fast-hack: true
2220
trace: false
2321
secrets: inherit

.github/workflows/env-setup

Lines changed: 0 additions & 20 deletions
This file was deleted.

.github/workflows/native-build.yml

Lines changed: 39 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,11 @@ on:
3232
required: false
3333
default: trace/META-INF/native-image
3434
type: string
35-
meta-package:
36-
description: "Meta-package name to publish"
37-
required: false
38-
default: ""
39-
type: string
4035
extra-tools:
4136
description: "Extra meta-package tools publish"
4237
required: false
4338
default: ""
4439
type: string
45-
fast-hack:
46-
description: "Publish fast (deprecated) packages"
47-
required: false
48-
default: false
49-
type: boolean
5040
jobs:
5141
build-jars:
5242
runs-on: "ubuntu-22.04"
@@ -57,7 +47,7 @@ jobs:
5747
with:
5848
submodules: recursive
5949
- name: "Setup Native Image Tools"
60-
uses: fprime-community/native-images-action@main
50+
uses: ./.github/actions/native-tools-setup
6151
- name: "Building JAR files"
6252
run: |
6353
cd ${{ inputs.working-directory }}
@@ -67,7 +57,7 @@ jobs:
6757
uses: actions/upload-artifact@v4
6858
with:
6959
name: build-jar
70-
path: ${{ inputs.output-directory }}/*
60+
path: ${{ inputs.output-directory }}/fpp.jar
7161
retention-days: 5
7262
if-no-files-found: error
7363
- if: ${{ inputs.trace }}
@@ -102,8 +92,12 @@ jobs:
10292
matrix = {
10393
"run": [
10494
{
105-
"runner": "macos-13",
106-
"tag": "macosx_13_0_universal2"
95+
"runner": "macos-14",
96+
"tag": "macosx_14_0_arm64"
97+
},
98+
{
99+
"runner": "macos-15-intel",
100+
"tag": "macosx_15_0_x86_64"
107101
},
108102
{
109103
"runner": "ubuntu-22.04",
@@ -135,8 +129,6 @@ jobs:
135129
uses: actions/checkout@v3
136130
with:
137131
submodules: recursive
138-
- name: "Setup Native Image Tools"
139-
uses: fprime-community/native-images-action@main
140132
- name: "Download JARs"
141133
uses: actions/download-artifact@v4
142134
with:
@@ -148,21 +140,32 @@ jobs:
148140
with:
149141
name: jar-traces
150142
path: ${{ inputs.trace-directory }}
143+
- name: "Setting up GraalVM/Java Environment"
144+
uses: ./.github/actions/native-tools-setup
151145
- name: "Build Native Images"
152-
run: |
153-
export CLASSPATH="`cd ${{ inputs.trace-directory }}/../..; pwd`:${CLASSPATH}"
154-
cd ${{ inputs.working-directory }}
155-
$NATIVE_IMAGE_TOOLS_PATH/native-images ${{ inputs.output-directory }} ${{ inputs.tools }}
156-
shell: bash
146+
uses: ./.github/actions/build-native-images
147+
with:
148+
binary-directory: ${{ inputs.output-directory }}
149+
trace-directory: ${{ inputs.trace-directory }}
157150
- name: "Archive Native Images"
158151
uses: actions/upload-artifact@v4
159152
with:
160153
name: build-${{ matrix.run.tag }}
161-
path: ${{ inputs.output-directory }}/*
154+
path: ${{ inputs.output-directory }}/fpp
162155
retention-days: 5
163156
if-no-files-found: error
164157
- name: "Testing Native Images via Unit-Tests"
165158
run: |
159+
# Generate wrappers for tools
160+
tool_names=`cat ${{ inputs.working-directory }}/compiler/tools.txt`
161+
for tool in $tool_names
162+
do
163+
tool_wrapper="${{ inputs.output-directory }}/fpp-$tool"
164+
echo "Generating wrapper for fpp-$tool in $tool_wrapper"
165+
echo '#!/bin/sh
166+
"`dirname $0`/fpp" '$tool' "$@"' > $tool_wrapper
167+
chmod +x $tool_wrapper
168+
done
166169
cd ${{ inputs.working-directory }}
167170
${{ inputs.test }}
168171
build-wheels:
@@ -175,27 +178,27 @@ jobs:
175178
uses: actions/checkout@v3
176179
with:
177180
submodules: recursive
181+
- name: "Make Output Directory"
182+
run: mkdir -p ${{ inputs.output-directory }}
178183
- name: "Download Package"
179184
uses: actions/download-artifact@v4
180185
with:
181186
name: build-${{ matrix.tag }}
182187
path: ${{ inputs.output-directory }}
183-
- name: "Install Builder"
184-
run: pip install fprime-native-images
185-
shell: bash
186188
- name: "Run Builder"
187189
run: |
188-
FLAGS="--package-tag ${{ matrix.tag }} --extra-tools ${{ inputs.extra-tools }}"
189-
if [[ "${{ matrix.tag }}" == "jar" ]] && [[ "${{ inputs.meta-package }}" != "" ]]
190-
then
191-
echo "[INFO] Generating Meta-Package: ${{ inputs.meta-package }}"
192-
FLAGS="${FLAGS} --meta-package ${{ inputs.meta-package }}"
193-
elif [[ "${{ inputs.fast-hack }}" == "true" ]]
194-
then
195-
echo "[INFO] Generating fast-hack packages"
196-
FLAGS="${FLAGS} --fast-hack"
190+
pip install build
191+
# Place the native files in the python package and determine platform options
192+
PLATFORM_OPTIONS=""
193+
if [[ "${{ matrix.tag }}" != "jar" ]]; then
194+
PLATFORM_OPTIONS="--config-setting=--build-option=--plat-name=${{ matrix.tag }}"
195+
cp -vr ${{ inputs.output-directory }}/fpp python/fprime_fpp/
196+
else
197+
cp -vr ${{ inputs.output-directory }}/*.jar python/fprime_fpp/
197198
fi
198-
fprime-native-packager ${{ inputs.output-directory }} ${FLAGS}
199+
# Github archiving clears executable flag, so put it back
200+
chmod +x python/fprime_fpp/fpp*
201+
python3 -m build --wheel --outdir packages/dist $PLATFORM_OPTIONS .
199202
shell: bash
200203
- name: "Archiving Wheels"
201204
uses: actions/upload-artifact@v4
@@ -211,7 +214,7 @@ jobs:
211214
runs-on: ${{ matrix.run.runner }}
212215
steps:
213216
- name: "Setup Native Image Tools"
214-
uses: fprime-community/native-images-action@main
217+
uses: fprime-community/native-images-action@unified-tool
215218
- name: "Download Native Wheels"
216219
uses: actions/download-artifact@v4
217220
with:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*.tasty
44
*~
55
.*
6+
!.gitignore
67
!.gitattributes
78
__SHADOW__
89
__pycache__

0 commit comments

Comments
 (0)