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

Add new preset for libecl library #947

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion cppbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ function sedinplace {
}

if [[ -z ${PROJECTS:-} ]]; then
PROJECTS=(opencv ffmpeg flycapture spinnaker libdc1394 libfreenect libfreenect2 librealsense librealsense2 videoinput artoolkitplus chilitags flandmark arrow hdf5 hyperscan mkl mkl-dnn dnnl openblas arpack-ng cminpack fftw gsl cpython numpy scipy gym llvm libpostal leptonica tesseract caffe openpose cuda mxnet tensorflow tensorrt ale onnx ngraph onnxruntime liquidfun qt skia cpu_features systems)
PROJECTS=(opencv ffmpeg flycapture spinnaker libdc1394 libfreenect libfreenect2 librealsense librealsense2 videoinput artoolkitplus chilitags flandmark arrow hdf5 hyperscan mkl mkl-dnn dnnl openblas arpack-ng cminpack fftw gsl cpython numpy scipy gym llvm libpostal leptonica tesseract caffe openpose cuda mxnet tensorflow tensorrt ale onnx ngraph onnxruntime liquidfun qt skia cpu_features systems libecl)
fi

for PROJECT in ${PROJECTS[@]}; do
Expand Down
104 changes: 104 additions & 0 deletions libecl/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
JavaCPP Presets for libecl
==========================

Introduction
------------
This directory contains the JavaCPP Presets module for:

* libecl 2.9.1 https://github.com/equinor/libecl

Please refer to the parent README.md file for more detailed information about the JavaCPP Presets.


Documentation
-------------
Java API documentation is available here:

* http://bytedeco.org/javacpp-presets/libecl/apidocs/


Sample Usage
------------
Here is a simple example of libecl ported to Java from this C source file:

* https://github.com/equinor/libecl/blob/2.9.1/applications/ecl/kw_list.c

We can use [Maven 3](http://maven.apache.org/) to download and install automatically all the class files as well as the native binaries. To run this sample code, after creating the `pom.xml` and `KeywordsList.java` source files below, simply execute on the command line:
```bash
$ mvn compile exec:java
```

### The `pom.xml` build file
```xml
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.bytedeco.libecl</groupId>
<artifactId>KeywordsList</artifactId>
<version>1.5.4</version>
<properties>
<exec.mainClass>KeywordsList</exec.mainClass>
</properties>
<dependencies>
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>libecl-platform</artifactId>
<version>2.9.1-1.5.4</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>.</sourceDirectory>
</build>
</project>
```

### The `KeywordsList.java` source file
```java
/*
* Copyright (C) 2011 Statoil ASA, Norway.
* The file 'kw_list.c' is part of ERT - Ensemble based Reservoir Tool.
* ERT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* ERT is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
* for more details.
*/
import org.bytedeco.libecl.fortio_type;
import org.bytedeco.libecl.ecl_kw_type;
import static org.bytedeco.libecl.global.libecl.*;

public class KeywordsList {

public static void main(String[] args) {
for (int i = 0; i < args.length; i++) {
kw_list(args[i]);
}
}

private static void kw_list(String filename) {
fortio_type fortio;
ecl_kw_type ecl_kw = ecl_kw_alloc_empty();
BooleanPointer fmt_file = new BooleanPointer();
if (ecl_util_fmt_file(filename, fmt_file)) {

System.out.println("-----------------------------------------------------------------");
System.out.printf("%s: %n", filename);
fortio = fortio_open_reader(filename, fmt_file, ECL_ENDIAN_FLIP);
while (ecl_kw_fread_realloc(ecl_kw, fortio)) {
ecl_kw_summarize(ecl_kw);
}
System.out.println("-----------------------------------------------------------------");

ecl_kw_free(ecl_kw);
fortio_fclose(fortio);
} else {
System.err.printf("Could not determine formatted/unformatted status of:%s - skipping%n", filename);
}
}

}
```

52 changes: 52 additions & 0 deletions libecl/cppbuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash
# This file is meant to be included by the parent cppbuild.sh script
if [[ -z "$PLATFORM" ]]; then
pushd ..
bash cppbuild.sh "$@" libecl
popd
exit
fi

LIBECL_VERSION=2.9.1
download https://github.com/equinor/libecl/archive/$LIBECL_VERSION.zip libecl-$LIBECL_VERSION.zip

mkdir -p $PLATFORM
cd $PLATFORM
INSTALL_PATH=`pwd`

echo "Decompressing archives..."
unzip -o ../libecl-$LIBECL_VERSION.zip


cd libecl-$LIBECL_VERSION

mkdir -p build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=../../ -DENABLE_PYTHON=OFF

case $PLATFORM in
linux-x86)
make
make install
;;
linux-x86_64)
make
make install
;;
macosx-*)
make
make install
;;
windows-x86)
cmake --build . --config Release --target install
;;
windows-x86_64)
cmake --build . --config Release --target install
;;
*)
echo "Error: Platform \"$PLATFORM\" is not supported"
;;
esac

cd ../..

138 changes: 138 additions & 0 deletions libecl/platform/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.bytedeco</groupId>
<artifactId>javacpp-presets</artifactId>
<version>1.5.5-SNAPSHOT</version>
<relativePath>../../</relativePath>
</parent>

<groupId>org.bytedeco</groupId>
<artifactId>libecl-platform</artifactId>
<version>${libecl.version}-${project.parent.version}</version>
<name>JavaCPP Presets Platform for libecl</name>

<properties>
<javacpp.moduleId>libecl</javacpp.moduleId>
<libecl.version>2.9.1</libecl.version>
</properties>

<dependencies>
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>javacpp-platform</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>${javacpp.moduleId}</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>${javacpp.moduleId}</artifactId>
<version>${project.version}</version>
<classifier>${javacpp.platform.linux-x86}</classifier>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>${javacpp.moduleId}</artifactId>
<version>${project.version}</version>
<classifier>${javacpp.platform.linux-x86_64}</classifier>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>${javacpp.moduleId}</artifactId>
<version>${project.version}</version>
<classifier>${javacpp.platform.macosx-x86_64}</classifier>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>${javacpp.moduleId}</artifactId>
<version>${project.version}</version>
<classifier>${javacpp.platform.windows-x86}</classifier>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>${javacpp.moduleId}</artifactId>
<version>${project.version}</version>
<classifier>${javacpp.platform.windows-x86_64}</classifier>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>default-jar</id>
<configuration>
<archive>
<manifestEntries>
<Class-Path>${javacpp.moduleId}.jar ${javacpp.moduleId}-linux-x86.jar ${javacpp.moduleId}-linux-x86_64.jar ${javacpp.moduleId}-macosx-x86_64.jar ${javacpp.moduleId}-windows-x86.jar ${javacpp.moduleId}-windows-x86_64.jar</Class-Path>
</manifestEntries>
</archive>
</configuration>
</execution>
<execution>
<id>empty-javadoc-jar</id>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>javadoc</classifier>
</configuration>
</execution>
<execution>
<id>empty-sources-jar</id>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>sources</classifier>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.moditect</groupId>
<artifactId>moditect-maven-plugin</artifactId>
<executions>
<execution>
<id>add-module-infos</id>
<phase>none</phase>
</execution>
<execution>
<id>add-platform-module-info</id>
<phase>package</phase>
<goals>
<goal>add-module-info</goal>
</goals>
<configuration>
<modules>
<module>
<file>${project.build.directory}/${project.artifactId}.jar</file>
<moduleInfoSource>
module org.bytedeco.${javacpp.moduleId}.platform {
requires static org.bytedeco.${javacpp.moduleId}.linux.x86;
requires static org.bytedeco.${javacpp.moduleId}.linux.x86_64;
requires static org.bytedeco.${javacpp.moduleId}.macosx.x86_64;
requires static org.bytedeco.${javacpp.moduleId}.windows.x86;
requires static org.bytedeco.${javacpp.moduleId}.windows.x86_64;
}
</moduleInfoSource>
</module>
</modules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>

70 changes: 70 additions & 0 deletions libecl/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.bytedeco</groupId>
<artifactId>javacpp-presets</artifactId>
<version>1.5.5-SNAPSHOT</version>
</parent>

<groupId>org.bytedeco</groupId>
<artifactId>libecl</artifactId>
<version>${libecl.version}-${project.parent.version}</version>
<name>JavaCPP Presets for libecl</name>

<dependencies>
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>javacpp</artifactId>
</dependency>
</dependencies>

<properties>
<libecl.version>2.9.1</libecl.version>
</properties>

<build>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.bytedeco</groupId>
<artifactId>javacpp</artifactId>
<configuration>
<includePaths>
<includePath>${basedir}/cppbuild/${javacpp.platform}/include/</includePath>
<includePath>${basedir}/cppbuild/${javacpp.platform}/include/libecl-${libecl.version}/lib/private-include/</includePath>
</includePaths>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.moditect</groupId>
<artifactId>moditect-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>

Loading