-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use unix line endings, new gradle, prepare kotlin gradle
- Loading branch information
Showing
9 changed files
with
282 additions
and
282 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# Ignore Gradle project-specific cache directory | ||
.gradle | ||
|
||
# Ignore Gradle build output directory | ||
build | ||
out | ||
# Ignore Gradle project-specific cache directory | ||
.gradle | ||
|
||
# Ignore Gradle build output directory | ||
build | ||
out | ||
tracy-jni/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,41 @@ | ||
## TracyJavaBindings – Java bindings for the Tracy Profiler | ||
### Prerequisites | ||
- After cloning the repository, ensure that you have checked-out submodules with `git submodule update --init`. | ||
### Building | ||
#### JNI Bindings | ||
- You can build the JNI bindings with `gradlew jar` | ||
#### Tracy profiler GUI | ||
> _All commands need to be run in the `tracy-jni/tracy` subdirectory._ | ||
- Create a new `build` folder under `tracy-jni/tracy/profiler`. | ||
- Configure the profiler using `cmake -B profiler/build -S profiler -DCMAKE_BUILD_TYPE=Release` (this only needs to be done once). | ||
- Build the profiler using `cmake --build profiler/build --parallel --config Release`. | ||
- The built `tracy-profiler` executable can be found in the `profiler/build/Release` directory. | ||
|
||
### Integration | ||
- At runtime, the `java.library.path` system property should contain a path to the native JNI libraries found in `tracy-jni/build/lib/main/release`. | ||
### Usage Example | ||
```java | ||
import io.github.benjaminamos.tracy.Tracy; | ||
|
||
public class TracyTest { | ||
public static void main(String[] args) { | ||
// Start profiling | ||
Tracy.startupProfiler(); | ||
|
||
// Allocate and begin zone | ||
long handle = Tracy.allocSourceLocation(0, "Test.java", "test()", "Test!", 0); | ||
Tracy.ZoneContext zoneContext = Tracy.zoneBegin(handle, 1); | ||
|
||
// Do work... | ||
|
||
// End zone | ||
Tracy.zoneEnd(zoneContext); | ||
|
||
// Begin new frame | ||
Tracy.markFrame(); | ||
|
||
// Stop profiling | ||
Tracy.shutdownProfiler(); | ||
} | ||
} | ||
## TracyJavaBindings – Java bindings for the Tracy Profiler | ||
### Prerequisites | ||
- After cloning the repository, ensure that you have checked-out submodules with `git submodule update --init`. | ||
### Building | ||
#### JNI Bindings | ||
- You can build the JNI bindings with `gradlew jar` | ||
#### Tracy profiler GUI | ||
> _All commands need to be run in the `tracy-jni/tracy` subdirectory._ | ||
- Create a new `build` folder under `tracy-jni/tracy/profiler`. | ||
- Configure the profiler using `cmake -B profiler/build -S profiler -DCMAKE_BUILD_TYPE=Release` (this only needs to be done once). | ||
- Build the profiler using `cmake --build profiler/build --parallel --config Release`. | ||
- The built `tracy-profiler` executable can be found in the `profiler/build/Release` directory. | ||
|
||
### Integration | ||
- At runtime, the `java.library.path` system property should contain a path to the native JNI libraries found in `tracy-jni/build/lib/main/release`. | ||
### Usage Example | ||
```java | ||
import io.github.benjaminamos.tracy.Tracy; | ||
|
||
public class TracyTest { | ||
public static void main(String[] args) { | ||
// Start profiling | ||
Tracy.startupProfiler(); | ||
|
||
// Allocate and begin zone | ||
long handle = Tracy.allocSourceLocation(0, "Test.java", "test()", "Test!", 0); | ||
Tracy.ZoneContext zoneContext = Tracy.zoneBegin(handle, 1); | ||
|
||
// Do work... | ||
|
||
// End zone | ||
Tracy.zoneEnd(zoneContext); | ||
|
||
// Begin new frame | ||
Tracy.markFrame(); | ||
|
||
// Stop profiling | ||
Tracy.shutdownProfiler(); | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,58 @@ | ||
// Copyright 2024 The Terasology Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
plugins { | ||
id 'java-library' | ||
} | ||
|
||
group 'io.github.benjaminamos.TracyJavaBindings' | ||
version '1.0-SNAPSHOT' | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
testImplementation 'org.junit.jupiter:junit-jupiter:5.8.1' | ||
testRuntimeOnly("org.junit.platform:junit-platform-launcher") | ||
} | ||
|
||
sourceSets { | ||
main | ||
} | ||
|
||
tasks.withType(Jar).configureEach { | ||
def sharedLibraryTasks = project('tracy-jni').tasks.withType(LinkSharedLibrary) | ||
dependsOn sharedLibraryTasks | ||
def sharedLibraryOutputs = sharedLibraryTasks.find { task -> | ||
task.name.toLowerCase().contains("release") | ||
}.outputs.files.asFileTree.files | ||
from(sharedLibraryOutputs) { | ||
include("*.dll") | ||
into("windows") | ||
} | ||
from(sharedLibraryOutputs) { | ||
include("*.so") | ||
into("linux") | ||
} | ||
from(sharedLibraryOutputs) { | ||
include("*.dylib") | ||
into("macosx") | ||
} | ||
from (new File(project('tracy-jni').projectDir, "tracy")) { | ||
include("LICENSE") | ||
rename("LICENSE", "TRACY_LICENSE") | ||
} | ||
} | ||
|
||
tasks.named("test", Test) { | ||
useJUnitPlatform() | ||
|
||
maxHeapSize = "1G" | ||
|
||
testLogging { | ||
events("passed") | ||
} | ||
|
||
systemProperty "java.library.path", project(":tracy-jni").getLayout().getBuildDirectory().dir("lib/main/debug").get().asFile.absolutePath | ||
} | ||
// Copyright 2024 The Terasology Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
plugins { | ||
id("java-library") | ||
} | ||
|
||
group "io.github.benjaminamos.TracyJavaBindings" | ||
version "1.0-SNAPSHOT" | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
testImplementation("org.junit.jupiter:junit-jupiter:5.8.1") | ||
testRuntimeOnly("org.junit.platform:junit-platform-launcher") | ||
} | ||
|
||
sourceSets { | ||
main | ||
} | ||
|
||
tasks.withType(Jar).configureEach { | ||
def sharedLibraryTasks = project("tracy-jni").tasks.withType(LinkSharedLibrary) | ||
dependsOn sharedLibraryTasks | ||
def sharedLibraryOutputs = sharedLibraryTasks.find { task -> | ||
task.name.toLowerCase().contains("release") | ||
}.outputs.files.asFileTree.files | ||
from(sharedLibraryOutputs) { | ||
include("*.dll") | ||
into("windows") | ||
} | ||
from(sharedLibraryOutputs) { | ||
include("*.so") | ||
into("linux") | ||
} | ||
from(sharedLibraryOutputs) { | ||
include("*.dylib") | ||
into("macosx") | ||
} | ||
from (new File(project("tracy-jni").projectDir, "tracy")) { | ||
include("LICENSE") | ||
rename("LICENSE", "TRACY_LICENSE") | ||
} | ||
} | ||
|
||
tasks.named("test", Test) { | ||
useJUnitPlatform() | ||
|
||
maxHeapSize = "1G" | ||
|
||
testLogging { | ||
events("passed") | ||
} | ||
|
||
systemProperty "java.library.path", project(":tracy-jni").getLayout().getBuildDirectory().dir("lib/main/debug").get().asFile.absolutePath | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
rootProject.name = "TracyJavaBindings" | ||
|
||
include 'tracy-jni' | ||
rootProject.name = "TracyJavaBindings" | ||
|
||
include("tracy-jni") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,46 @@ | ||
// Copyright 2024 The Terasology Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package io.github.benjaminamos.tracy; | ||
|
||
import java.io.File; | ||
|
||
public final class Tracy { | ||
private Tracy() { | ||
} | ||
|
||
static { | ||
String libraryPath = System.getProperty("org.terasology.librarypath"); | ||
if (libraryPath == null) { | ||
System.loadLibrary("tracy-jni-" + System.getProperty("os.arch")); | ||
} else { | ||
File libraryDirectory = new File(libraryPath); | ||
if (libraryDirectory.exists() && libraryDirectory.isDirectory()) { | ||
String architecture = System.getProperty("os.arch"); | ||
for (File file : libraryDirectory.listFiles()) { | ||
if (file.getName().startsWith("tracy-jni-" + architecture) || file.getName().startsWith("libtracy-jni-" + architecture)) { | ||
System.load(file.getPath()); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
public static native void startupProfiler(); | ||
public static native void shutdownProfiler(); | ||
public static native boolean isConnected(); | ||
public static native void markFrame(); | ||
public static native long allocSourceLocation(int line, String source, String function, String name, int colour); | ||
public static native ZoneContext zoneBegin(long sourceLocation, int active); | ||
public static native void zoneEnd(ZoneContext zoneContext); | ||
|
||
public static final class ZoneContext { | ||
public final int id; | ||
public final int active; | ||
|
||
public ZoneContext(int id, int active) { | ||
this.id = id; | ||
this.active = active; | ||
} | ||
} | ||
} | ||
// Copyright 2024 The Terasology Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package io.github.benjaminamos.tracy; | ||
|
||
import java.io.File; | ||
|
||
public final class Tracy { | ||
private Tracy() { | ||
} | ||
|
||
static { | ||
String libraryPath = System.getProperty("org.terasology.librarypath"); | ||
if (libraryPath == null) { | ||
System.loadLibrary("tracy-jni-" + System.getProperty("os.arch")); | ||
} else { | ||
File libraryDirectory = new File(libraryPath); | ||
if (libraryDirectory.exists() && libraryDirectory.isDirectory()) { | ||
String architecture = System.getProperty("os.arch"); | ||
for (File file : libraryDirectory.listFiles()) { | ||
if (file.getName().startsWith("tracy-jni-" + architecture) || file.getName().startsWith("libtracy-jni-" + architecture)) { | ||
System.load(file.getPath()); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
public static native void startupProfiler(); | ||
public static native void shutdownProfiler(); | ||
public static native boolean isConnected(); | ||
public static native void markFrame(); | ||
public static native long allocSourceLocation(int line, String source, String function, String name, int colour); | ||
public static native ZoneContext zoneBegin(long sourceLocation, int active); | ||
public static native void zoneEnd(ZoneContext zoneContext); | ||
|
||
public static final class ZoneContext { | ||
public final int id; | ||
public final int active; | ||
|
||
public ZoneContext(int id, int active) { | ||
this.id = id; | ||
this.active = active; | ||
} | ||
} | ||
} |
Oops, something went wrong.