Skip to content

Commit cf8fa48

Browse files
committed
Updated Gradle to 8.13, fix typo, added module + manifest in annotation project.
1 parent abc8947 commit cf8fa48

File tree

14 files changed

+77
-40
lines changed

14 files changed

+77
-40
lines changed

annotation-processor-test/build.gradle

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,25 @@ plugins {
33
}
44

55
group = 'io.github.digitalsmile.native'
6+
version = "1.1.5"
7+
8+
java {
9+
targetCompatibility = "22"
10+
sourceCompatibility = "22"
11+
}
612

713
repositories {
814
mavenCentral()
915
}
1016

1117
dependencies {
12-
testImplementation 'io.github.digitalsmile.native:annotation:1.1.4'
13-
testAnnotationProcessor 'io.github.digitalsmile.native:annotation-processor:1.1.4'
18+
testImplementation 'io.github.digitalsmile.native:annotation:${version}'
19+
testAnnotationProcessor 'io.github.digitalsmile.native:annotation-processor:${version}'
1420

1521
testImplementation platform('org.junit:junit-bom:5.10.0')
1622
testImplementation 'org.junit.jupiter:junit-jupiter'
1723
testImplementation("org.assertj:assertj-core:3.25.1")
24+
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
1825
}
1926

2027
jar {

annotation-processor-test/src/test/java/io/github/digitalsmile/gpio/functions/LibcFunctionTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
import io.github.digitalsmile.annotation.NativeMemoryException;
44
import org.junit.jupiter.api.Test;
5-
5+
import static org.junit.jupiter.api.Assertions.*;
66
public class LibcFunctionTests {
77

88
@Test
99
public void testOpenRead() throws NativeMemoryException {
1010
var file = new LibcFunctionsNative();
1111
var osRelease = file.open("/etc/os-release", 0);
12-
var buffer = file.read(osRelease, new byte[1024], 1024);
13-
System.out.println(new String(buffer));
12+
var buffer = new String(file.read(osRelease, new byte[1024], 1024));
13+
assertTrue(buffer.contains("Ubuntu"));
1414
file.close();
1515
}
1616
}

annotation-processor-test/src/test/java/io/github/digitalsmile/gpio/functions/LibcFunctions.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
11
package io.github.digitalsmile.gpio.functions;
22

3+
import io.github.digitalsmile.annotation.NativeMemory;
4+
import io.github.digitalsmile.annotation.NativeMemoryOptions;
35
import io.github.digitalsmile.annotation.function.*;
46
import io.github.digitalsmile.annotation.NativeMemoryException;
7+
import io.github.digitalsmile.annotation.structure.Enums;
8+
import io.github.digitalsmile.annotation.structure.Struct;
9+
import io.github.digitalsmile.annotation.structure.Structs;
10+
import io.github.digitalsmile.annotation.structure.Unions;
511
import io.github.digitalsmile.annotation.types.interfaces.NativeMemoryLayout;
6-
12+
@NativeMemory(headers = "/usr/include/x86_64-linux-gnu/sys/stat.h")
13+
@NativeMemoryOptions(systemIncludes = {
14+
"/usr/lib/gcc/x86_64-linux-gnu/${gcc-version}/include/"
15+
}, processRootConstants = true, debugMode = true)
16+
@Structs({
17+
@Struct(name = "stat", javaName = "Stat")
18+
})
19+
@Enums
20+
@Unions
721
public interface LibcFunctions {
822
@NativeManualFunction(name = "ioctl", useErrno = true)
923
int callByValue(int fd, long command, long data) throws NativeMemoryException;

annotation-processor-test/src/test/java/io/github/digitalsmile/gpio/libcurl/LibcurlTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ public class LibcurlTest {
1313
public void libcurl() throws NativeMemoryException {
1414
try (var libcurl = new LibcurlNative()) {
1515
var code = libcurl.globalInit(CurlConstants.CURL_GLOBAL_DEFAULT);
16-
assertEquals(code, CURLCode.CURLE_OK);
16+
assertEquals(CURLCode.CURLE_OK, code);
1717
var curl = libcurl.easyInit();
1818
code = libcurl.easySetOpt(curl, CURLOption.CURLOPT_URL, "https://example.com");
19-
assertEquals(code, CURLCode.CURLE_OK);
19+
assertEquals(CURLCode.CURLE_OK, code);
2020
code = libcurl.easySetOpt(curl, CURLOption.CURLOPT_FOLLOWLOCATION, 1L);
21-
assertEquals(code, CURLCode.CURLE_OK);
21+
assertEquals(CURLCode.CURLE_OK, code);
2222

2323
code = libcurl.easyPerform(curl);
24-
assertEquals(code, CURLCode.CURLE_OK);
24+
assertEquals(CURLCode.CURLE_OK, code);
2525
}
2626
}
2727
}

annotation-processor-test/src/test/java/io/github/digitalsmile/gpio/shared/SharedTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public void shared() throws Throwable {
2121

2222
try (var statLib = new SharedTestTwoNative()) {
2323
var stats = statLib.stat(fd, Stat.createEmpty());
24-
assertEquals(stats.stSize(), 35);
24+
assertEquals(35, stats.stSize());
2525
}
2626
}
2727
}

annotation-processor-test/src/test/java/io/github/digitalsmile/gpio/types/all/GPIOTest.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,37 +24,37 @@ public void testGPIOV1AllTypes() {
2424
var newChipInfo = GpiochipInfo.createEmpty().fromBytes(memoryBuffer);
2525
assertArrayEquals(newChipInfo.name(), prepareByteArray(32, STRING));
2626
assertArrayEquals(newChipInfo.label(), prepareByteArray(32, STRING));
27-
assertEquals(newChipInfo.lines(), 3);
27+
assertEquals(3, newChipInfo.lines());
2828
assertTrue(GpiochipInfo.createEmpty().isEmpty());
2929

30-
assertEquals(GpioConstants.class.getFields().length, 40);
30+
assertEquals(40, GpioConstants.class.getFields().length);
3131

3232
//assertEquals(GpioConstants.values().length, 3);
3333

3434
var eventData = new GpioeventData(100, 5);
3535
memoryBuffer = arena.allocate(eventData.getMemoryLayout());
3636
eventData.toBytes(memoryBuffer);
3737
var newEventData = GpioeventData.createEmpty().fromBytes(memoryBuffer);
38-
assertEquals(newEventData.timestamp(), 100);
39-
assertEquals(newEventData.id(), 5);
38+
assertEquals(100, newEventData.timestamp());
39+
assertEquals(5, newEventData.id());
4040
assertTrue(GpioeventData.createEmpty().isEmpty());
4141

4242
var eventRequest = new GpioeventRequest(1, 2, 3, STRING, 4);
4343
memoryBuffer = arena.allocate(eventRequest.getMemoryLayout());
4444
eventRequest.toBytes(memoryBuffer);
4545
var newEventRequest = GpioeventRequest.createEmpty().fromBytes(memoryBuffer);
46-
assertEquals(newEventRequest.lineoffset(), 1);
47-
assertEquals(newEventRequest.handleflags(), 2);
48-
assertEquals(newEventRequest.eventflags(), 3);
46+
assertEquals(1, newEventRequest.lineoffset());
47+
assertEquals(2, newEventRequest.handleflags());
48+
assertEquals(3, newEventRequest.eventflags());
4949
assertArrayEquals(newEventRequest.consumerLabel(), prepareByteArray(32, STRING));
50-
assertEquals(newEventRequest.fd(), 4);
50+
assertEquals(4, newEventRequest.fd());
5151
assertTrue(GpioeventRequest.createEmpty().isEmpty());
5252

5353
var handleConfig = new GpiohandleConfig(1, BYTE_ARRAY, INT_ARRAY);
5454
memoryBuffer = arena.allocate(handleConfig.getMemoryLayout());
5555
handleConfig.toBytes(memoryBuffer);
5656
var newHandleConfig = GpiohandleConfig.createEmpty().fromBytes(memoryBuffer);
57-
assertEquals(newHandleConfig.flags(), 1);
57+
assertEquals(1, newHandleConfig.flags());
5858
assertArrayEquals(newHandleConfig.defaultValues(), prepareByteArray(64, BYTE_ARRAY));
5959
assertArrayEquals(newHandleConfig.padding(), prepareIntArray(4, INT_ARRAY));
6060
assertTrue(GpiohandleConfig.createEmpty().isEmpty());
@@ -71,19 +71,19 @@ public void testGPIOV1AllTypes() {
7171
handleRequest.toBytes(memoryBuffer);
7272
var newHandleRequest = GpiohandleRequest.createEmpty().fromBytes(memoryBuffer);
7373
assertArrayEquals(newHandleRequest.lineoffsets(), prepareIntArray(64, INT_ARRAY));
74-
assertEquals(newHandleRequest.flags(), 1);
74+
assertEquals(1, newHandleRequest.flags());
7575
assertArrayEquals(newHandleRequest.defaultValues(), prepareByteArray(64, BYTE_ARRAY));
7676
assertArrayEquals(newHandleRequest.consumerLabel(), prepareByteArray(32, STRING));
77-
assertEquals(newHandleRequest.lines(), 2);
78-
assertEquals(newHandleRequest.fd(), 3);
77+
assertEquals(2, newHandleRequest.lines());
78+
assertEquals(3, newHandleRequest.fd());
7979
assertTrue(GpiohandleRequest.createEmpty().isEmpty());
8080

8181
var lineInfo = new GpiolineInfo(1, 2, STRING, STRING);
8282
memoryBuffer = arena.allocate(lineInfo.getMemoryLayout());
8383
lineInfo.toBytes(memoryBuffer);
8484
var newLineInfo = GpiolineInfo.createEmpty().fromBytes(memoryBuffer);
85-
assertEquals(newLineInfo.lineOffset(), 1);
86-
assertEquals(newLineInfo.flags(), 2);
85+
assertEquals(1, newLineInfo.lineOffset());
86+
assertEquals(2, newLineInfo.flags());
8787
assertArrayEquals(newLineInfo.name(), prepareByteArray(32, STRING));
8888
assertArrayEquals(newLineInfo.consumer(), prepareByteArray(32, STRING));
8989
assertTrue(GpiolineInfo.createEmpty().isEmpty());
@@ -93,8 +93,8 @@ public void testGPIOV1AllTypes() {
9393
lineInfoChanged.toBytes(memoryBuffer);
9494
var newLineInfoChanged = GpiolineInfoChanged.createEmpty().fromBytes(memoryBuffer);
9595
assertThat(newLineInfoChanged.info()).usingRecursiveComparison().isEqualTo(newLineInfo);
96-
assertEquals(newLineInfoChanged.timestamp(), 1);
97-
assertEquals(newLineInfoChanged.eventType(), 2);
96+
assertEquals(1, newLineInfoChanged.timestamp());
97+
assertEquals(2, newLineInfoChanged.eventType());
9898
assertArrayEquals(newLineInfoChanged.padding(), prepareIntArray(5, INT_ARRAY));
9999
assertTrue(GpiolineInfoChanged.createEmpty().isEmpty());
100100
} catch (Throwable e) {

annotation-processor-test/src/test/java/io/github/digitalsmile/gpio/types/custom/GPIOTest.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22

33
import io.github.digitalsmile.annotation.NativeMemory;
44
import io.github.digitalsmile.annotation.NativeMemoryOptions;
5-
import io.github.digitalsmile.annotation.structure.Enums;
65
import io.github.digitalsmile.annotation.structure.Struct;
76
import io.github.digitalsmile.annotation.structure.Structs;
8-
import io.github.digitalsmile.annotation.structure.Unions;
97

108
@NativeMemory(headers = "/usr/src/linux-headers-${linux-version}/include/uapi/linux/gpio.h")
119
@NativeMemoryOptions(
@@ -21,7 +19,5 @@
2119
@Struct(name = "gpio_v2_line_request", javaName = "LineRequest"),
2220
@Struct(name = "gpio_v2_line_values", javaName = "LineValues")
2321
})
24-
@Enums
25-
@Unions
2622
public interface GPIOTest {
2723
}

annotation-processor/build.gradle

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
plugins {
22
id 'java'
33
id "com.vanniktech.maven.publish" version "0.29.0"
4+
id "org.gradlex.extra-java-module-info" version "1.11"
45
}
56

67
group = 'io.github.digitalsmile.native'
7-
version = '1.1.4'
8+
version = '1.1.5'
89

910
repositories {
1011
mavenCentral()
1112
}
1213

14+
extraJavaModuleInfo {
15+
automaticModule("io.soabase.java-composer:java-composer", "com.squareup.javapoet")
16+
automaticModule("org.barfuin.texttree:text-tree", "org.barfuin.texttree")
17+
}
18+
1319
dependencies {
1420
implementation 'io.soabase.java-composer:java-composer:1.0'
15-
implementation 'io.github.digitalsmile.native:annotation:1.1.4'
21+
implementation 'io.github.digitalsmile.native:annotation:${version}'
1622

1723
annotationProcessor 'io.avaje:avaje-prisms:1.28'
1824
implementation 'io.avaje:avaje-prisms:1.28'
@@ -26,7 +32,7 @@ import com.vanniktech.maven.publish.SonatypeHost
2632
mavenPublishing {
2733
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
2834
signAllPublications()
29-
coordinates("io.github.digitalsmile.native", "annotation-processor", "1.1.4")
35+
coordinates("io.github.digitalsmile.native", "annotation-processor", "${version}")
3036

3137
pom {
3238
name = "Native Memory Annotation processor"
@@ -60,7 +66,8 @@ javadoc {
6066
}
6167

6268
java {
63-
targetCompatibility = "22";
69+
targetCompatibility = "22"
70+
sourceCompatibility = "22"
6471
}
6572

6673
jar {

annotation-processor/src/main/java/io/github/digitalsmile/headers/DeclarationParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ private String parseScoped(Declaration.Scoped declarationScoped, NodeType nodeTy
103103
public void parseDeclaration(Declaration declaration, NativeMemoryNode parentNode, boolean isTopLevel) {
104104
switch (declaration) {
105105
case Declaration.Scoped declarationScoped -> {
106-
if (skipParsing(declaration.name(), declarationScoped.kind())) {
106+
if (isTopLevel && skipParsing(declaration.name(), declarationScoped.kind())) {
107107
return;
108108
}
109109
var nodeType = getNodeType(declarationScoped, declarationScoped.attributes());
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module annotation.processor.main {
2+
requires io.avaje.prism;
3+
requires io.github.digitalsmile.annotation;
4+
requires java.compiler;
5+
6+
requires com.squareup.javapoet;
7+
requires org.barfuin.texttree;
8+
9+
provides javax.annotation.processing.Processor with io.github.digitalsmile.NativeProcessor;
10+
}

0 commit comments

Comments
 (0)