Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panama-backend - basic integration with jextract #499

Open
wants to merge 73 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
e260451
panama-backend - basic integration with jextract
jcrist1 Jun 14, 2024
7c5b60d
panama-backend - bench / test / and cleaning
jcrist1 Jun 14, 2024
037aacf
panama-backend - add generated code for ICU4X / basic opaque generation
jcrist1 Jun 28, 2024
c8282c9
panama-backend - add enums and structs / limited slice support
jcrist1 Jul 11, 2024
5272832
panam-backend - semicolon
jcrist1 Jul 11, 2024
dc8969f
panama-backend - fixing structs
jcrist1 Jul 17, 2024
aa87b13
panama-backend - fix struct generation
jcrist1 Jul 19, 2024
c3cb18f
panama-backend - basic lifetime bounds
jcrist1 Aug 1, 2024
e863425
panama-backend - revert lifetime experimentation
jcrist1 Aug 1, 2024
68e6beb
panama-backend - fix lifetimes
jcrist1 Aug 1, 2024
e58ed73
Merge remote-tracking branch 'origin/main' into panama-backend
jcrist1 Aug 3, 2024
7005062
panama-backend - remove accidental type
jcrist1 Aug 3, 2024
c02c92f
panama-backend - adding overrides
jcrist1 Aug 4, 2024
fdc619b
panamaa-backend - complete pipeline
jcrist1 Aug 10, 2024
031272d
panama-backend - clippy
jcrist1 Aug 10, 2024
a323918
panama-backend - manually address clippy issues
jcrist1 Aug 10, 2024
127d6ff
panama-backend - accept tests / gen all code
jcrist1 Aug 10, 2024
2b10d7a
panama-backend - remove java from gen as ci would need jextract
jcrist1 Aug 10, 2024
69cbab6
panama-backend - fix test
jcrist1 Aug 10, 2024
eb6e890
panama-backend - remove printlns
jcrist1 Aug 10, 2024
7cd8e8a
Merge remote-tracking branch 'origin/main' into panama-backend
jcrist1 Aug 10, 2024
ee58338
panama-backend - fix merge issues
jcrist1 Aug 10, 2024
d620460
panama-backend - change attribute goals
jcrist1 Aug 10, 2024
18a5762
panama-backend - fix diplomat view changes
jcrist1 Aug 14, 2024
770b99b
panam-backend - update snapshots
jcrist1 Aug 14, 2024
15b0f7e
Merge remote-tracking branch 'origin/main' into panama-backend
jcrist1 Sep 1, 2024
b442eea
panama-backend - add make tas / add ci / disable a feature method
jcrist1 Sep 1, 2024
04fdbba
panama-backend - make ci actually test java and not kotlin
jcrist1 Sep 1, 2024
42898fe
panama-backend - remove static string from test
jcrist1 Sep 1, 2024
3973f19
panama-backend - test adding jextract
jcrist1 Sep 1, 2024
2148183
panama-backend - test new ci
jcrist1 Sep 1, 2024
57e67e6
panama-backend - test jextract ci
jcrist1 Sep 1, 2024
9bebc5b
panama-backend - debug ci
jcrist1 Sep 1, 2024
b9bc603
panama-backend - limit ci to new task
jcrist1 Sep 1, 2024
5666887
panama-backend - use taiki-e to install curl?
jcrist1 Sep 1, 2024
e323f50
panama-backend - remove enflo
jcrist1 Sep 1, 2024
d56671e
panama-backend - good ol' apt?
jcrist1 Sep 1, 2024
0d9a024
panama-backend - sudo make me a sandwich
jcrist1 Sep 1, 2024
99e0ec2
panama-backend - full test pipeline
jcrist1 Sep 1, 2024
89f1aab
panama-backend - see if it downloaded
jcrist1 Sep 1, 2024
fba6db2
panama-backend - test jextract
jcrist1 Sep 1, 2024
108417a
panama-backend - test path
jcrist1 Sep 1, 2024
fc5a255
panama-backend - more debugging
jcrist1 Sep 1, 2024
85da4d5
panama-backend - cat profile
jcrist1 Sep 1, 2024
6c2f94e
panama-backend - change last step
jcrist1 Sep 1, 2024
7aabcc2
panama-backend - fix bashrc debug
jcrist1 Sep 1, 2024
cae2a94
panama-backend - add export to set env var
jcrist1 Sep 1, 2024
2252b85
panama - uncomment PATH var debug
jcrist1 Sep 1, 2024
9878fb9
panama-backend - add jextract --help to steps
jcrist1 Sep 1, 2024
f3eb060
panama-backend - source the rc file
jcrist1 Sep 1, 2024
4de1b97
panama-backend - fix source path
jcrist1 Sep 1, 2024
2ec7735
panama-backend - use $GITHUB_PATH for path vars
jcrist1 Sep 1, 2024
5ab860a
panama-backend - cleanup debug and add cargo make gen-java-feature
jcrist1 Sep 1, 2024
a796ffb
panama-backend - uncomment other actions
jcrist1 Sep 1, 2024
5abfc5d
panama-backend - remove ICU4X java code
jcrist1 Sep 1, 2024
d6e61f9
panama-backend - add general gen-java step
jcrist1 Sep 1, 2024
d8e7509
panama-backend - remove result types
jcrist1 Sep 1, 2024
41becfa
panama-backend - only generate code for attr enabled files / use aren…
jcrist1 Sep 7, 2024
5b6fbd8
panama-backend - clippy
jcrist1 Sep 7, 2024
fc37865
panama-backend fix tests
jcrist1 Sep 7, 2024
35a587c
panama-backend - refactor to use simpler conversion code for types
jcrist1 Sep 9, 2024
596b0c2
panama-backend - remove support for owned slices
jcrist1 Sep 13, 2024
bc7c3fe
panama-backend - clippy
jcrist1 Sep 13, 2024
47f7ce9
Merge remote-tracking branch 'origin/main' into panama-backend
jcrist1 Sep 13, 2024
dfe88e3
panama-backend - fix merge issues
jcrist1 Sep 13, 2024
42d941b
panama-backend - fix kotlin test from merge
jcrist1 Sep 13, 2024
4aa75d6
panama-backend - more test fixes
jcrist1 Sep 13, 2024
d633c3b
panama-backend - fix demo changes and some cpp stuff
jcrist1 Sep 13, 2024
7f37a99
panama-backend - mac os S**t
jcrist1 Sep 13, 2024
bfc71ea
panama-backend - more test fixing
jcrist1 Sep 13, 2024
14ae4a5
panama-backend - remove IntelliJ cruft
jcrist1 Sep 13, 2024
b00adf6
panama-backend - troubleshoot mvn test
jcrist1 Sep 13, 2024
8675eb3
panama-backend - remove pom comments
jcrist1 Sep 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ jobs:

- name: Test Dart
run: cargo make test-dart

test-kotlin:
runs-on: ubuntu-latest
steps:
Expand All @@ -231,3 +232,43 @@ jobs:
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
- name: Test Kotlin
run: cargo make test-kotlin

test-java:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install cargo-make
uses: taiki-e/install-action@cargo-make
- name: Set up JDK 22 for x64
uses: actions/setup-java@v4
with:
java-version: '22'
distribution: 'temurin'
architecture: x64
cache: maven
- name: Test Java
run: cargo make test-java

test-java-gen:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install cargo-make
uses: taiki-e/install-action@cargo-make
- name: Install curl
run: sudo apt-get update && sudo apt-get install -y curl
- name: Set up JDK 22 for x64
uses: actions/setup-java@v4
with:
java-version: '22'
distribution: 'temurin'
architecture: x64
cache: maven
- name: get jextract
run: curl -o /opt/jextract.tgz https://download.java.net/java/early_access/jextract/22/5/openjdk-22-jextract+5-33_linux-x64_bin.tar.gz
- name: config jextract
run: tar -xzf /opt/jextract.tgz -C /opt/
- name: Add jextract to path
run: echo "/opt/jextract-22/bin" >> $GITHUB_PATH
- name: Run generated java
run: cargo make gen-java
39 changes: 39 additions & 0 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ dependencies = [
"test-kotlin-feature",
]

[tasks.test-java]
category = "Tests"
dependencies = [
"test-java-feature",
]

[tasks.test-example]
category = "Tests"
dependencies = [
Expand All @@ -93,6 +99,7 @@ dependencies = [
"test-demo-feature",
"test-dart-feature",
"test-kotlin-feature",
"test-java-feature",
]

[tasks.test-cpp-example]
Expand Down Expand Up @@ -214,6 +221,23 @@ cd feature_tests/kotlin/somelib
exec --fail-on-error gradle test --warning-mode all
'''

[tasks.test-java-feature.mac]
env = {"OUT_FILE" = "dylib"}

[tasks.test-java-feature.linux]
env = {"OUT_FILE" = "so", "LD_LIBRARY_PATH" = "./"}

[tasks.test-java-feature]
category = "Tests"
script_runner = "@duckscript"
dependencies = ["build-feature"]
script = '''
exit_on_error true
cp target/debug/libdiplomat_feature_tests.${OUT_FILE} feature_tests/java/somelib/libsomelib.${OUT_FILE}
cd feature_tests/java/somelib
exec --fail-on-error mvn test
'''

[tasks.check-c-example]
category = "Tests"
script_runner = "@duckscript"
Expand Down Expand Up @@ -372,13 +396,20 @@ dependencies = [
"gen-dart-feature",
"gen-dart-example",
]

[tasks.gen-kotlin]
category = "Code generation"
dependencies = [
"gen-kotlin-feature",
"gen-kotlin-example",
]

[tasks.gen-java]
category = "Code generation"
dependencies = [
"gen-java-feature",
]




Expand Down Expand Up @@ -473,6 +504,14 @@ exit_on_error true
generate_generic example dart lib/src
'''

[tasks.gen-java-feature]
category = "Code generation"
script_runner = "@duckscript"
script = '''
exit_on_error true
!include_files ./support/functions.ds
generate_generic feature_tests java somelib "-l diplomat-java-conf.toml" /src/main/java
'''
# this task generates all of the kotlin code but does not copy generated project files over
# we only copy the generated main src files to preserve the tests
[tasks.gen-kotlin-feature]
Expand Down
1 change: 1 addition & 0 deletions core/src/ast/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ pub enum StdlibOrDiplomat {
}

/// A local type reference, such as the type of a field, parameter, or return value.
///
/// Unlike [`CustomType`], which represents a type declaration, [`TypeName`]s can compose
/// types through references and boxing, and can also capture unresolved paths.
#[derive(Clone, PartialEq, Eq, Hash, Serialize, Deserialize, Debug)]
Expand Down
2 changes: 0 additions & 2 deletions feature_tests/c/include/MyString.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions feature_tests/c/include/Opaque.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions feature_tests/cpp/include/MyString.d.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions feature_tests/cpp/include/MyString.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions feature_tests/cpp/include/Opaque.d.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions feature_tests/cpp/include/Opaque.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions feature_tests/dart/lib/src/Opaque.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions feature_tests/diplomat-java-conf.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
domain = "dev.diplomattest"
lib_name = "somelib"
45 changes: 45 additions & 0 deletions feature_tests/java/somelib/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
.idea/encodings.xml
.idea/misc.xml
.idea/vcs.xml
.idea/codeStyles
.idea/**
*.iws
*.iml
*.ipr

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store

libsomelib.dylib
55 changes: 55 additions & 0 deletions feature_tests/java/somelib/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>dev.diplomattest.somelib</groupId>
<artifactId>somelib</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>22</maven.compiler.source>
<maven.compiler.target>22</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>5.14.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.10.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
<version>1.37</version>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>1.37</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>3.5.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.0</version>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package dev.diplomattest.somelib;

import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.infra.Blackhole;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;

public class OpaqueBench {
Copy link
Contributor Author

@jcrist1 jcrist1 Sep 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a shell command to actually run this yet. I only ran it from IntelliJ, but want to keep it as it'll be nice to have to compare to the kotlin backend once the icu4x example can be made to work

@Benchmark
public static void benchOpaque(Blackhole bh) {
var opaque = Opaque.fromStr("it's amazing to be here");
bh.consume(opaque);
// opaque.destroy();
}

public static void main(String[] args) throws RunnerException {
Options opt = new OptionsBuilder()
.include(OpaqueBench.class.getSimpleName())
.warmupIterations(2)
.measurementIterations(2)
.forks(1)
.build();

new Runner(opt).run();
}
}
Loading
Loading