Skip to content

Commit

Permalink
Build native version of graalpy-install-package.
Browse files Browse the repository at this point in the history
  • Loading branch information
fniephaus committed Jul 22, 2024
1 parent 14eec59 commit 67f32ab
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 10 deletions.
18 changes: 15 additions & 3 deletions .github/workflows/graalpy-install-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,21 @@ jobs:
- name: Run 'graalpy-install-package java'
run: |
cd graalpy-install-package
mvn --no-transfer-progress clean package
mvn exec:exec &
mvn -B clean package
mvn -B exec:exec &
PID=$!
sleep 60
kill $PID
- name: Run 'graalpy-install-package native'
run: |
cd graalpy-install-package
mvn -B clean -DskipTests package
# Collect metadata
mvn -Pnative -Dagent=true test
# Build native
mvn -Pnative -DskipTests package
# Run native executable
./target/package-graalpy &
PID=$!
sleep 60
kill $PID
# Cannot test native due to https://github.com/graalvm/native-build-tools/issues/584
24 changes: 17 additions & 7 deletions graalpy-install-package/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
<maven.compiler.target>21</maven.compiler.target>
<maven.compiler.source>21</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<nativeimage.agentlib.argument>-showversion</nativeimage.agentlib.argument>
</properties>

<dependencies>
Expand All @@ -82,6 +81,12 @@
<artifactId>python-embedding</artifactId>
<version>${graalpy.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.10.0</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -132,20 +137,21 @@
<arguments>
<argument>-classpath</argument>
<classpath />
<argument>${nativeimage.agentlib.argument}</argument>
<argument>${main.class}</argument>
</arguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>native</id>
<properties>
<nativeimage.agentlib.argument>-agentlib:native-image-agent=config-merge-dir=${project.build.outputDirectory}/META-INF/native-image/</nativeimage.agentlib.argument>
</properties>
<build>
<plugins>
<plugin>
Expand All @@ -165,8 +171,12 @@
<configuration>
<fallback>false</fallback>
<mainClass>${main.class}</mainClass>
<buildArgs>
</buildArgs>
<agent>
<defaultMode>direct</defaultMode>
<modes>
<direct>config-merge-dir=${project.build.outputDirectory}/META-INF/native-image/</direct>
</modes>
</agent>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[
{
"name": "java.lang.Thread",
"methods": [
{ "name": "currentThread", "parameterTypes": [ ] },
{ "name": "yield", "parameterTypes": [ ] }
]
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"resources": {
"includes": [],
"excludes": []
},
"bundles": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"types": [],
"lambdaCapturingTypes": [],
"proxies": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* The Universal Permissive License (UPL), Version 1.0
*
* Subject to the condition set forth below, permission is hereby granted to any
* person obtaining a copy of this software, associated documentation and/or
* data (collectively the "Software"), free of charge and under any and all
* copyright rights in the Software, and any and all patent rights owned or
* freely licensable by each licensor hereunder covering either (i) the
* unmodified Software as contributed to or provided by such licensor, or (ii)
* the Larger Works (as defined below), to deal in both
*
* (a) the Software, and
*
* (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
* one is included with the Software each a "Larger Work" to which the Software
* is contributed by such licensors),
*
* without restriction, including without limitation the rights to copy, create
* derivative works of, display, perform, and distribute the Software and make,
* use, sell, offer for sale, import, export, have made, and have sold the
* Software and the Larger Work(s), and to sublicense the foregoing rights on
* either these or other terms.
*
* This license is subject to the following condition:
*
* The above copyright notice and either this complete permission notice or at a
* minimum a reference to the UPL must be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.oracle.example.graalpy;

import static com.oracle.example.graalpy.Main.main;

import org.junit.jupiter.api.Test;


/**
* Unit test for Main.
*/
class MainTest {
/**
* UI tests for all critical code paths, to be used to collect reachability
* metadata with the tracing agent for Native Image compilation.
*/
@Test
public void testMainUI() throws Exception {
main(new String[0]);
System.out.println("Done testing main UI");
}
}

0 comments on commit 67f32ab

Please sign in to comment.