Skip to content
Olivier Chafik edited this page Nov 8, 2022 · 3 revisions

How to build BridJ

BridJ is built as part of the NativeLibs4Java sub-projects.

Full build (first time)

This will build all of NativeLibs4Java's projects, including JNAerator. It will take some time, so you'll want to have a coffee during the build (if you've never used Maven before, this can take up to 15 minutes, so that might be enough for two coffees).

Subsequent builds will be much quicker (see next section), and can be launched from your Maven-aware IDE of choice.

svn checkout http://nativelibs4java.googlecode.com/svn/trunk/libraries nativelibs4java cd nativelibs4java

  * Run the following Maven command :
    ```
mvn install -Dmaven.test.skip=true

BridJ's JARs are in Runtime/Bridj/target (pick bridj-x.x-SNAPSHOT.jar if you don't have specific size needs).

JAR File C C++ COM MFC Objective-C .NET Windows MacOS X Linux Solaris FreeBSD
bridj-x.x-SNAPSHOT.jar x x x x x x x x x x
bridj-x.x-SNAPSHOT-c-only.jar x x x x x
bridj-x.x-SNAPSHOT-windows-only.jar x x x x x x
bridj-x.x-SNAPSHOT-unix-only.jar x x x x x x
bridj-x.x-SNAPSHOT-macosx-only.jar x x x x

Incremental build

cd Runtime/BridJ
mvn clean install

Building BridJ's native library

TODO(ochafik): update this section

See README.md at the root of the repo.

If it's not a platform already supported by BridJ, you must update Runtime/BridJ/src/main/velocity/org/bridj/JNI.java and Platform.java so it can find your binary at runtime (search for getEmbeddedLibraryResource in [http://code.google.com/p/nativelibs4java/source/browse/trunk/libraries/Runtime/BridJ/src/main/velocity/org/bridj/JNI.java]).

To run the tests on your new binary :

mvn test

About BridJ's source code

BridJ contains Java and C code.

Some of its sources are autogenerated from Velocity templates. For instance, all the Pointer.getInt, .setInt, getFloat, .setFloat... are generated automatically from a template.

So if you look for Pointer.java and JNI.java, they're not directly in the source control : they're created during the Maven build from their template located in src/main/velocity.

Likewise, some test classes are autogenerated, which helps cover more cases with less code (there's even autogenerated C functions in the test library, that is matched by the corresponding autogenerated test cases on the Java side).

Clone this wiki locally