Skip to content

Commit

Permalink
Merge pull request #128 from LeStarch/v1.0.2
Browse files Browse the repository at this point in the history
Python Wrapper Package and Automatic Building of Packages
  • Loading branch information
bocchino authored Jun 21, 2022
2 parents 39cd0ac + 6ec0d4d commit 29a7000
Show file tree
Hide file tree
Showing 13 changed files with 612 additions and 19 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/build-native.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build Native Images
on:
release:
types: [published]
jobs:
Build-Native-Images:
strategy:
matrix:
os: ["ubuntu-latest", "macos-10.15"]
runs-on: ${{ matrix.os }}
steps:
- name: "Checkout FPP Repository"
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Image Build Step
working-directory: ./compiler
run: |
. ${GITHUB_WORKSPACE}/.github/workflows/env-setup
./release
mv native-fpp-*.tar.gz "${GITHUB_WORKSPACE}"
- name: Publish Release Binaries
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ${GITHUB_WORKSPACE}/.github/workflows/publish native-fpp-*.tar.gz
Build-PyPI-Package:
needs: Build-Native-Images
runs-on: ubuntu-latest
steps:
- name: "Checkout FPP Repository"
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Test PyPI
uses: fprime-community/publish-pypi@main
env:
TWINE_PASSWORD: ${{ secrets.TESTPYPI_CREDENTIAL }}
with:
package: "fprime-fpp"
steps: "sdist"
- name: PyPI
uses: fprime-community/publish-pypi@main
env:
TWINE_PASSWORD: ${{ secrets.PYPI_CREDENTIAL }}
with:
repo: "pypi"
package: "fprime-fpp"
steps: "sdist"
19 changes: 19 additions & 0 deletions .github/workflows/env-setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
graal_ver="22.1.0"
graal_os="$( uname -s | tr "[:upper:]" "[:lower:]")"
graal_ar="graalvm-ce-java11-${graal_os}-amd64-${graal_ver}.tar.gz"
graal_dir="$(pwd)/graalvm-ce-java11-${graal_ver}"
graal_url="https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${graal_ver}/${graal_ar}"

# Download Graal
curl -L "${graal_url}" | tar -xz
graal_bin="${graal_dir}/bin"
if [ ! -d "${graal_bin}" ]
then
graal_bin="${graal_dir}/Contents/Home/bin"
fi
export PATH="${graal_bin}:${PATH}"
export GRAALVM_JAVA_HOME="$(dirname ${graal_bin})"
# Install native image
${graal_bin}/gu install native-image

16 changes: 16 additions & 0 deletions .github/workflows/publish
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
#
# inputs: path(s) to file to release
#
auth="Authorization: token ${GITHUB_TOKEN}"
content="Content-Type:application/octet-stream"
release="$(python -c "import json; print(json.load(open('${GITHUB_EVENT_PATH}', 'r'))['release']['id'])")"

# Upload every file
for file in "$@"
do
url="https://uploads.github.com/repos/${GITHUB_REPOSITORY}/releases/${release}/assets?name=$( basename "${file}" )"
echo "Publishing: ${file} to ${url}"
curl -sSL -XPOST -H "${auth}" --upload-file "${file}" --header "${content}" "${url}" || exit $?
done
exit 0
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
.*
*.bak
*~
*.egg-info
__SHADOW__
__pycache__
dist/
fprim_fpp/fpp_version_info.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,73 @@
[
{
"name":"fpp.compiler.FPPFormat",
"methods":[{"name":"main","parameterTypes":["java.lang.String[]"] }]
},
{
"name":"fpp.compiler.FPPSyntax",
"methods":[{"name":"main","parameterTypes":["java.lang.String[]"] }]
},
{
"name":"fpp.compiler.tools.FPPCheck",
"methods":[{"name":"main","parameterTypes":["java.lang.String[]"] }]
},
{
"name":"fpp.compiler.tools.FPPDepend",
"methods":[{"name":"main","parameterTypes":["java.lang.String[]"] }]
},
{
"name":"fpp.compiler.tools.FPPFilenames",
"methods":[{"name":"main","parameterTypes":["java.lang.String[]"] }]
},
{
"name":"fpp.compiler.tools.FPPFromXml",
"methods":[{"name":"main","parameterTypes":["java.lang.String[]"] }]
},
{
"name":"fpp.compiler.tools.FPPLocateDefs",
"methods":[{"name":"main","parameterTypes":["java.lang.String[]"] }]
},
{
"name":"fpp.compiler.tools.FPPLocateUses",
"methods":[{"name":"main","parameterTypes":["java.lang.String[]"] }]
},
{
"name":"fpp.compiler.tools.FPPToCpp",
"methods":[{"name":"main","parameterTypes":["java.lang.String[]"] }]
},
{
"name":"fpp.compiler.tools.FPPToXml",
"methods":[{"name":"main","parameterTypes":["java.lang.String[]"] }]
},
{
"name":"java.lang.ClassLoader",
"methods":[{"name":"getPlatformClassLoader","parameterTypes":[] }]
"methods":[
{"name":"getPlatformClassLoader","parameterTypes":[] },
{"name":"loadClass","parameterTypes":["java.lang.String"] }
]
},
{
"name":"java.lang.NoSuchMethodError"
},
{
"name":"java.lang.String",
"methods":[
{"name":"lastIndexOf","parameterTypes":["int"] },
{"name":"substring","parameterTypes":["int"] }
]
},
{
"name":"java.lang.System",
"methods":[
{"name":"getProperty","parameterTypes":["java.lang.String"] },
{"name":"setProperty","parameterTypes":["java.lang.String","java.lang.String"] }
]
},
{
"name":"jdk.internal.loader.ClassLoaders$PlatformClassLoader"
},
{
"name":"org.graalvm.jniutils.JNIExceptionWrapperEntryPoints",
"methods":[{"name":"getClassName","parameterTypes":["java.lang.Class"] }]
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[
{
"type":"agent-extracted",
"classes":[
]
}
]

Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
[
{
"name":"[Lfpp.compiler.analysis.ComponentInstance;"
},
{
"name":"[Lfpp.compiler.analysis.Connection;"
},
{
"name":"[Lfpp.compiler.codegen.Line;"
},
{
"name":"[Ljava.lang.String;"
},
{
"name":"com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl",
"methods":[{"name":"<init>","parameterTypes":[] }]
Expand All @@ -11,30 +23,30 @@
},
{
"name":"fpp.compiler.analysis.Format$Parser$",
"fields":[{"name":"0bitmap$1", "allowUnsafeAccess":true}]
"fields":[{"name":"0bitmap$1"}]
},
{
"name":"fpp.compiler.codegen.CppDocCppWriter$",
"fields":[{"name":"0bitmap$1", "allowUnsafeAccess":true}]
"fields":[{"name":"0bitmap$1"}]
},
{
"name":"fpp.compiler.codegen.CppDocHppWriter$",
"fields":[{"name":"0bitmap$1", "allowUnsafeAccess":true}]
"fields":[{"name":"0bitmap$1"}]
},
{
"name":"fpp.compiler.codegen.Line[]"
},
{
"name":"fpp.compiler.syntax.Lexer$",
"fields":[{"name":"0bitmap$2", "allowUnsafeAccess":true}]
"fields":[{"name":"0bitmap$2"}]
},
{
"name":"fpp.compiler.syntax.Lexer$$anon$1",
"fields":[{"name":"0bitmap$1", "allowUnsafeAccess":true}]
"fields":[{"name":"0bitmap$1"}]
},
{
"name":"fpp.compiler.syntax.Parser$",
"fields":[{"name":"0bitmap$1", "allowUnsafeAccess":true}]
"fields":[{"name":"0bitmap$1"}]
},
{
"name":"java.lang.ClassValue"
Expand All @@ -48,23 +60,23 @@
},
{
"name":"scala.util.parsing.input.OffsetPosition",
"fields":[{"name":"0bitmap$1", "allowUnsafeAccess":true}]
"fields":[{"name":"0bitmap$1"}]
},
{
"name":"scala.util.parsing.input.OffsetPosition$",
"fields":[{"name":"0bitmap$2", "allowUnsafeAccess":true}]
"fields":[{"name":"0bitmap$2"}]
},
{
"name":"scala.xml.XML$",
"fields":[{"name":"0bitmap$2", "allowUnsafeAccess":true}]
"fields":[{"name":"0bitmap$2"}]
},
{
"name":"scala.xml.parsing.FactoryAdapter",
"fields":[{"name":"0bitmap$1", "allowUnsafeAccess":true}]
"fields":[{"name":"0bitmap$1"}]
},
{
"name":"scopt.OParser$",
"fields":[{"name":"0bitmap$1", "allowUnsafeAccess":true}]
"fields":[{"name":"0bitmap$1"}]
},
{
"name":"sun.misc.Unsafe",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"resources":{
"includes":[]},
"bundles":[{"name":"com.sun.org.apache.xerces.internal.impl.msg.XMLMessages"}]
"bundles":[{
"name":"com.sun.org.apache.xerces.internal.impl.msg.XMLMessages",
"locales":["und"]
}]
}
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
[
]
{
"types":[
],
"lambdaCapturingTypes":[
]
}
47 changes: 43 additions & 4 deletions compiler/release
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,41 @@ then
echo "release: environment variable GRAALVM_JAVA_HOME is not set" 1>&2
exit 1
fi

directory=`dirname $0`
native_bin="$directory/native-fpp-`uname`-`uname -m`"
native_image="$GRAALVM_JAVA_HOME/bin/native-image"
meta_inf_dir="$directory/lib/src/main/resources/META-INF/native-image/"

# Make directories
mkdir -p "$meta_inf_dir"
mkdir -p "$native_bin"

# Versioning information
echo "C compiler version"
cc --version
echo "Java version"
java --version
echo "Native Image Version"
native-image --version


# Install jar files here
$directory/install
$directory/install-trace
# Test a run before running test
$directory/bin/fpp-locate-defs tools/fpp-locate-defs/test/defs/defs-1.fpp tools/fpp-locate-defs/test/defs/defs-2.fpp 1>/dev/null
if [ $? -ne 0 ]
then
echo "[ERROR] Failed to run tracable JAR"
exit 1
fi

# Trace through testing
$directory/test
if [ $? -ne 0 ]
then
echo "[WARNING] Failed to run tests"
fi
sync; sync; sync;
# Convert jar files to binaries
for jar_file in $directory/bin/*.jar
do
Expand All @@ -38,13 +63,27 @@ do
echo "release: Failed to build $out_file"
exit 1
fi
sync; sync; sync;
if ! $out_file --help 1>/dev/null
then
echo "release: Failed, $out_file not executable"
exit 1
fi
done
sync; sync; sync;

# Clean up native directory
rm "$native_bin"/*.txt
sync; sync; sync;

# Create tar ball
release_tgz="$native_bin.tar.gz"
tar -czf "$release_tgz" "$native_bin"

echo "Release archive written to $release_tgz"
sync; sync; sync;
# Check if file size too small
if [ `stat -f %z $release_tgz` -lt 55846858 ]
then
echo "Release archive $release_tgz too small with size `du -hs $release_tgz`"
exit 99
fi
echo "Release archive written to $release_tgz with size `du -hs $release_tgz`"
Empty file added fprime_fpp/__init__.py
Empty file.
Loading

0 comments on commit 29a7000

Please sign in to comment.