-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f62d201
Showing
16 changed files
with
1,449 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
**/.gradle/** | ||
**/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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
dist: xenial | ||
before_cache: | ||
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock | ||
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/ | ||
cache: | ||
directories: | ||
- $HOME/.m2/repository/ | ||
- $HOME/.gradle/caches/ | ||
- $HOME/.gradle/wrapper/ | ||
language: java | ||
jdk: openjdk8 | ||
|
||
before_install: | ||
- > | ||
if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then | ||
export GRADLE_PUBLISH="publishToMavenLocal"; | ||
elif [[ "$TRAVIS_BRANCH" != "release" ]]; then | ||
export GRADLE_PUBLISH="publish"; | ||
else | ||
curl -L "https://drive.google.com/uc?export=download&id=$GDOWNLOAD_ID" -o $HOME/settings.tar.gz; | ||
tar -xzf $HOME/settings.tar.gz -C $HOME; | ||
export GNUPGHOME="$HOME/.gnupg/"; | ||
export GRADLE_PUBLISH="publish"; | ||
fi | ||
script: | ||
- gradle build $GRADLE_PUBLISH |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
Initial release |
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,81 @@ | ||
Gradle JavaCPP | ||
============== | ||
|
||
[](https://gitter.im/bytedeco/javacpp) [](https://maven-badges.herokuapp.com/maven-central/org.bytedeco/gradle-javacpp) [](http://bytedeco.org/builds/) [](https://travis-ci.org/bytedeco/gradle-javacpp) | ||
|
||
|
||
Introduction | ||
------------ | ||
Gradle JavaCPP offers plugins that make it easy to use [JavaCPP](https://github.com/bytedeco/javacpp) as part of the Gradle build system. | ||
|
||
Please feel free to ask questions on [the mailing list](http://groups.google.com/group/javacpp-project) if you encounter any problems with the software! I am sure it is far from perfect... | ||
|
||
|
||
Required Software | ||
----------------- | ||
To use Gradle JavaCPP, you will need to download and install the following software: | ||
|
||
* An implementation of Java SE 8 or newer: | ||
* OpenJDK http://openjdk.java.net/install/ or | ||
* Oracle JDK http://www.oracle.com/technetwork/java/javase/downloads/ or | ||
* IBM JDK http://www.ibm.com/developerworks/java/jdk/ | ||
* A C++ compiler, out of which these have been tested: | ||
* GNU C/C++ Compiler (Linux, etc.) http://gcc.gnu.org/ | ||
* For Windows x86 and x64 http://mingw-w64.org/ | ||
* LLVM Clang (Mac OS X, etc.) http://clang.llvm.org/ | ||
* Microsoft C/C++ Compiler, part of Visual Studio https://visualstudio.microsoft.com/ | ||
* https://docs.microsoft.com/en-us/cpp/build/walkthrough-compiling-a-native-cpp-program-on-the-command-line | ||
* Gradle 5.0 or newer: https://gradle.org/releases/ | ||
|
||
To produce binary files for Android 4.0 or newer, you will also have to install: | ||
|
||
* Android NDK r7 or newer http://developer.android.com/ndk/downloads/ | ||
|
||
And similarly to target iOS, you will need to install either: | ||
|
||
* Gluon VM http://gluonhq.com/products/mobile/vm/ or | ||
* RoboVM 1.x or newer http://robovm.mobidevelop.com/downloads/ | ||
|
||
|
||
Getting Started | ||
--------------- | ||
To understand how [JavaCPP](https://github.com/bytedeco/javacpp) is meant to be used, one should first take a look at the [Mapping Recipes for C/C++ Libraries](https://github.com/bytedeco/javacpp/wiki/Mapping-Recipes), but a high-level overview of the [Basic Architecture](https://github.com/bytedeco/javacpp/wiki/Basic-Architecture) is also available to understand the bigger picture. | ||
|
||
Once comfortable enough with the command line interface, the build plugin for Gradle can be used to integrate easily that workflow as part of `build.gradle` as shown below. By default, it creates a `javacppJar` task that archives the native libraries into a separate JAR file and sets its classifier to `$javacppPlatform`, while excluding those files from the default `jar` task. To customize the behavior, there are properties and extensions that can be modified and whose documentation is available as part of the source code in these files: | ||
* [`BuildTask.java`](src/main/java/org/bytedeco//gradle/javacpp/BuildTask.java) | ||
* [`BuildPlugin.java`](src/main/java/org/bytedeco//gradle/javacpp/BuildPlugin.java) | ||
|
||
Fully functional sample projects are also provided in the [`samples`](samples) subdirectory and can be used as templates. | ||
|
||
```groovy | ||
plugins { | ||
id 'java-library' | ||
id 'org.bytedeco.gradle-javacpp-build' version "$javacppVersion" | ||
} | ||
dependencies { | ||
api "org.bytedeco:javacpp:$javacppVersion" | ||
} | ||
tasks.withType(org.bytedeco.gradle.javacpp.BuildTask) { | ||
// set here default values for all build tasks below, typically just includePath and linkPath | ||
} | ||
javacppBuildCommand { | ||
// typically set here the buildCommand to the script that fills up includePath and linkPath | ||
} | ||
javacppBuildParser { | ||
// typically set here the classOrPackageNames to class names implementing InfoMap | ||
} | ||
javacppBuildCompiler { | ||
// typically set here boolean flags like copyLibs | ||
} | ||
``` | ||
|
||
|
||
---- | ||
Project lead: Samuel Audet [samuel.audet `at` gmail.com](mailto:samuel.audet at gmail.com) | ||
Developer site: https://github.com/bytedeco/gradle-javacpp | ||
Discussion group: http://groups.google.com/group/javacpp-project |
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 |
---|---|---|
@@ -0,0 +1,128 @@ | ||
plugins { | ||
id 'java-library' | ||
id 'java-gradle-plugin' | ||
id 'maven-publish' | ||
id 'signing' | ||
} | ||
|
||
group = 'org.bytedeco' | ||
version = '1.5.4-SNAPSHOT' | ||
|
||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } | ||
} | ||
|
||
dependencies { | ||
api "org.bytedeco:javacpp:$version" | ||
testImplementation 'junit:junit:4.12' | ||
} | ||
|
||
gradlePlugin { | ||
plugins { | ||
build { | ||
id = 'org.bytedeco.gradle-javacpp-build' | ||
implementationClass = 'org.bytedeco.gradle.javacpp.BuildPlugin' | ||
} | ||
} | ||
} | ||
|
||
jar { | ||
manifest { | ||
attributes 'Implementation-Title': 'Gradle JavaCPP', | ||
'Implementation-Vendor': 'Bytedeco', | ||
'Implementation-Version': version, | ||
'Specification-Title': 'Gradle JavaCPP', | ||
'Specification-Vendor': 'Bytedeco', | ||
'Specification-Version': version | ||
} | ||
} | ||
|
||
javadoc { | ||
options.memberLevel = JavadocMemberLevel.PRIVATE | ||
options.links = ['https://docs.oracle.com/javase/8/docs/api', | ||
'https://docs.gradle.org/current/javadoc', | ||
'http://bytedeco.org/javacpp/apidocs', | ||
'http://junit.org/junit4/javadoc/4.12'] | ||
} | ||
|
||
//java { | ||
// withJavadocJar() | ||
// withSourcesJar() | ||
//} | ||
|
||
task javadocJar(type: Jar, dependsOn: javadoc) { | ||
classifier = 'javadoc' | ||
from javadoc.destinationDir | ||
} | ||
|
||
task sourcesJar(type: Jar, dependsOn: classes) { | ||
classifier = 'sources' | ||
from sourceSets.main.allSource | ||
} | ||
|
||
artifacts { | ||
archives javadocJar | ||
archives sourcesJar | ||
} | ||
|
||
signing { | ||
if (!version.endsWith('SNAPSHOT')) sign publishing.publications.mavenJava | ||
} | ||
|
||
publishing { | ||
publications { | ||
mavenJava(MavenPublication) { | ||
from components.java | ||
artifact javadocJar | ||
artifact sourcesJar | ||
pom { | ||
name = 'Gradle JavaCPP' | ||
description = 'Gradle plugins to automate the build process of JavaCPP' | ||
url = 'http://bytedeco.org/gradle-javacpp/' | ||
licenses { | ||
license { | ||
name = 'Apache License, Version 2.0' | ||
url = 'http://www.apache.org/licenses/LICENSE-2.0' | ||
distribution = 'repo' | ||
} | ||
license { | ||
name = 'GNU General Public License (GPL) version 2, or any later version' | ||
url = 'http://www.gnu.org/licenses/' | ||
distribution = 'repo' | ||
} | ||
license { | ||
name = 'GPLv2 with Classpath exception' | ||
url = 'http://www.gnu.org/software/classpath/license.html' | ||
distribution = 'repo' | ||
} | ||
} | ||
developers { | ||
developer { | ||
id = 'saudet' | ||
name = 'Samuel Audet' | ||
email = '[email protected]' | ||
} | ||
} | ||
scm { | ||
url = 'https://github.com/bytedeco/gradle-javacpp' | ||
connection = 'scm:git:git://github.com/bytedeco/gradle-javacpp.git' | ||
developerConnection = 'scm:git:ssh://[email protected]/bytedeco/gradle-javacpp.git' | ||
} | ||
} | ||
} | ||
} | ||
repositories { | ||
maven { | ||
def releasesRepoUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' | ||
def snapshotsRepoUrl = 'https://oss.sonatype.org/content/repositories/snapshots/' | ||
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl | ||
credentials { | ||
username System.getenv('CI_DEPLOY_USERNAME') | ||
password System.getenv('CI_DEPLOY_PASSWORD') | ||
} | ||
} | ||
} | ||
} | ||
|
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
plugins { | ||
id 'java-library' | ||
id 'org.bytedeco.gradle-javacpp-build' version '1.5.4-SNAPSHOT' | ||
} | ||
|
||
group = 'org.bytedeco' | ||
version = "1.2.11-$javacppVersion" | ||
|
||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } | ||
} | ||
|
||
dependencies { | ||
api "org.bytedeco:javacpp:$javacppVersion" | ||
// api "org.bytedeco:javacpp:$javacppVersion:$javacppPlatform" | ||
testImplementation 'junit:junit:4.12' | ||
} | ||
|
||
tasks.withType(org.bytedeco.gradle.javacpp.BuildTask) { | ||
includePath = ["$buildDir/$javacppPlatform/include"] | ||
linkPath = ["$buildDir/$javacppPlatform/lib"] | ||
} | ||
|
||
javacppBuildCommand { | ||
buildCommand = ['bash', 'build.sh'] | ||
} | ||
|
||
javacppBuildParser { | ||
classOrPackageNames = ['org.bytedeco.zlib.presets.*'] | ||
} | ||
|
||
javacppBuildCompiler { | ||
copyLibs = true | ||
} | ||
|
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
mkdir -p build/$PLATFORM | ||
cd build/$PLATFORM | ||
|
||
ZLIB_VERSION=1.2.11 | ||
if [[ ! -e "zlib-$ZLIB_VERSION.tar.gz" ]]; then | ||
curl -L "http://zlib.net/zlib-$ZLIB_VERSION.tar.gz" -o "zlib-$ZLIB_VERSION.tar.gz" | ||
fi | ||
echo "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1 zlib-$ZLIB_VERSION.tar.gz" | shasum -a 256 -c - | ||
|
||
echo "Decompressing archives..." | ||
tar --totals -xf "zlib-$ZLIB_VERSION.tar.gz" | ||
cd zlib-$ZLIB_VERSION | ||
|
||
case $PLATFORM in | ||
linux-x86) | ||
CC="gcc -m32 -fPIC" ./configure --prefix=.. --static | ||
make -j $MAKEJ | ||
make install | ||
;; | ||
linux-x86_64) | ||
CC="gcc -m64 -fPIC" ./configure --prefix=.. --static | ||
make -j $MAKEJ | ||
make install | ||
;; | ||
macosx-x86_64) | ||
./configure --prefix=.. --static | ||
make -j $MAKEJ | ||
make install | ||
;; | ||
windows-x86) | ||
nmake -f win32/Makefile.msc zlib.lib | ||
mkdir -p ../include ../lib | ||
cp zconf.h zlib.h ../include/ | ||
cp zlib.lib ../lib/ | ||
;; | ||
windows-x86_64) | ||
nmake -f win32/Makefile.msc zlib.lib | ||
mkdir -p ../include ../lib | ||
cp zconf.h zlib.h ../include/ | ||
cp zlib.lib ../lib/ | ||
;; | ||
*) | ||
echo "Error: Platform \"$PLATFORM\" is not supported" | ||
;; | ||
esac | ||
|
||
cd ../../.. |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
pluginManagement { | ||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } | ||
} | ||
} | ||
|
||
rootProject.name = 'zlib' | ||
|
||
gradle.rootProject { ext.javacppVersion = '1.5.4-SNAPSHOT' } |
33 changes: 33 additions & 0 deletions
33
samples/zlib/src/main/java/org/bytedeco/zlib/presets/zlib.java
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.bytedeco.zlib.presets; | ||
|
||
import org.bytedeco.javacpp.*; | ||
import org.bytedeco.javacpp.annotation.*; | ||
import org.bytedeco.javacpp.tools.*; | ||
|
||
@Properties( | ||
value = { | ||
@Platform(include = "<zlib.h>", link = "[email protected]#"), | ||
@Platform(value = "windows", link = "zlib#") | ||
}, | ||
target = "org.bytedeco.zlib", | ||
global = "org.bytedeco.zlib.global.zlib" | ||
) | ||
public class zlib implements InfoMapper { | ||
static { Loader.checkVersion("org.bytedeco", "zlib"); } | ||
|
||
public void map(InfoMap infoMap) { | ||
infoMap.put(new Info("ZEXTERN", "ZEXPORT", "z_const", "zlib_version").cppTypes().annotations()) | ||
.put(new Info("FAR").cppText("#define FAR")) | ||
.put(new Info("OF").cppText("#define OF(args) args")) | ||
.put(new Info("Z_ARG").cppText("#define Z_ARG(args) args")) | ||
.put(new Info("Byte", "Bytef", "charf").cast().valueTypes("byte").pointerTypes("BytePointer")) | ||
.put(new Info("uInt", "uIntf").cast().valueTypes("int").pointerTypes("IntPointer")) | ||
.put(new Info("uLong", "uLongf", "z_crc_t", "z_off_t", "z_size_t").cast().valueTypes("long").pointerTypes("CLongPointer")) | ||
.put(new Info("z_off64_t").cast().valueTypes("long").pointerTypes("LongPointer")) | ||
.put(new Info("voidp", "voidpc", "voidpf").valueTypes("Pointer")) | ||
.put(new Info("gzFile_s").pointerTypes("gzFile")) | ||
.put(new Info("gzFile").valueTypes("gzFile")) | ||
.put(new Info("Z_LARGE64", "!defined(ZLIB_INTERNAL) && defined(Z_WANT64)").define(false)) | ||
.put(new Info("inflateGetDictionary", "gzopen_w", "gzvprintf").skip()); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
samples/zlib/src/test/java/org/bytedeco/zlib/UnitTest.java
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.bytedeco.zlib; | ||
|
||
import org.junit.Test; | ||
import static org.bytedeco.zlib.global.zlib.*; | ||
|
||
public class UnitTest { | ||
@Test public void test() { | ||
System.out.println(zlibVersion().getString()); | ||
} | ||
} | ||
|
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
rootProject.name = 'gradle-javacpp' |
Oops, something went wrong.