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 LiquidFun presets #356

Merged
merged 6 commits into from
Mar 4, 2017
Merged
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 @@ -97,7 +97,7 @@ function download {
}

if [[ -z ${PROJECTS:-} ]]; then
PROJECTS=(opencv ffmpeg flycapture libdc1394 libfreenect librealsense videoinput artoolkitplus chilitags flandmark hdf5 openblas fftw gsl llvm leptonica tesseract caffe cuda mxnet tensorflow)
PROJECTS=(opencv ffmpeg flycapture libdc1394 libfreenect libfreenect2 librealsense videoinput artoolkitplus chilitags flandmark hdf5 openblas fftw gsl llvm leptonica tesseract caffe cuda mxnet tensorflow liquidfun)
fi

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

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

* LiquidFun master as of 2015-04-01 https://github.com/google/liquidfun

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


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

* TODO


Sample Usage
------------
Here is a simple example of LiquidFun ported to Java.

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 `src/main/java/Example.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.javacpp-presets.liquidfun</groupId>
<artifactId>example</artifactId>
<version>1.0</version>
<properties>
<exec.mainClass>Example</exec.mainClass>
</properties>
<dependencies>
<dependency>
<groupId>org.bytedeco.javacpp-presets</groupId>
<artifactId>liquidfun-platform</artifactId>
<version>20150401-0708ce1-1.3.2-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
```

### The `src/main/java/Example.java` source file
```java
import org.bytedeco.javacpp.*;
import static org.bytedeco.javacpp.liquidfun.*;

public class Example {
public static void main(String[] args) {
b2World w = new b2World(0.0f, -10.0f);
b2BodyDef bd = new b2BodyDef();
bd.type(b2_dynamicBody);
bd.SetPosition(1.0f, 5.0f);
b2CircleShape c = new b2CircleShape();
c.m_radius(2.0f);
b2FixtureDef fd = new b2FixtureDef();
fd.shape(c).density(1.0f);
b2Body b = w.CreateBody(bd);
b.CreateFixture(fd);
for (int i = 1; i <= 5; i++) {
System.out.println(i + ": ball at " + b.GetPositionX() + "," + b.GetPositionY());
w.Step(0.1f, 2, 8);
}
System.exit(0);
}
}
```
45 changes: 45 additions & 0 deletions liquidfun/cppbuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash
# This file is meant to be included by the parent cppbuild.sh script
if [[ -z "$PLATFORM" ]]; then
pushd ..
bash cppbuild.sh "$@" liquidfun
popd
exit
fi

LIQUIDFUN_SHA=0708ce1 # 20150401
download https://github.com/google/liquidfun/archive/$LIQUIDFUN_SHA.zip liquidfun_$LIQUIDFUN_SHA.zip

mkdir -p $PLATFORM
cd $PLATFORM
INSTALL_PATH=`pwd`
mkdir -p include lib bin
unzip -o ../liquidfun_$LIQUIDFUN_SHA.zip
cd `ls -d liquidfun-*`

case $PLATFORM in
linux-x86)
cd liquidfun/Box2D
CC="$OLDCC -m32" CXX="$OLDCXX -m32" $CMAKE -DBOX2D_INSTALL=ON -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DBOX2D_BUILD_SHARED=ON -DBOX2D_BUILD_EXAMPLES=OFF -DBOX2D_BUILD_UNITTESTS=OFF
make -j $MAKEJ
make install/strip
;;
linux-x86_64)
cd liquidfun/Box2D
CC="$OLDCC -m64" CXX="$OLDCXX -m64" $CMAKE -DBOX2D_INSTALL=ON -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DBOX2D_BUILD_SHARED=ON -DBOX2D_BUILD_EXAMPLES=OFF -DBOX2D_BUILD_UNITTESTS=OFF
make -j $MAKEJ
make install/strip
;;
macosx-*)
patch -Np1 <$INSTALL_PATH/../../liquidfun-$LIQUIDFUN_SHA-macosx.patch
cd liquidfun/Box2D
$CMAKE -G "Xcode" -DBOX2D_INSTALL=ON -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DBOX2D_BUILD_SHARED=ON -DBOX2D_BUILD_EXAMPLES=OFF -DBOX2D_BUILD_UNITTESTS=OFF
xcodebuild -project Box2D.xcodeproj -configuration Release -target install
;;
*)
echo "Error: Platform \"$PLATFORM\" is not supported"
;;
esac

cd $INSTALL_PATH
cd ..
25 changes: 25 additions & 0 deletions liquidfun/liquidfun-0708ce1-macosx.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
diff --git a/liquidfun/Box2D/Box2D/Particle/b2ParticleSystem.cpp b/liquidfun/Box2D/Box2D/Particle/b2ParticleSystem.cpp
index ce1c01e..4469eb1 100644
--- a/liquidfun/Box2D/Box2D/Particle/b2ParticleSystem.cpp
+++ b/liquidfun/Box2D/Box2D/Particle/b2ParticleSystem.cpp
@@ -52,7 +52,7 @@ static const uint32 yMask = ((1u << yTruncBits) - 1u) << yShift;
static const uint32 xMask = ~yMask;
static const uint32 relativeTagRight = 1u << xShift;
static const uint32 relativeTagBottomLeft = (uint32)((1 << yShift) +
- (-1 << xShift));
+ ((1 << xShift) * -1));

static const uint32 relativeTagBottomRight = (1u << yShift) + (1u << xShift);

diff --git a/liquidfun/Box2D/CMakeLists.txt b/liquidfun/Box2D/CMakeLists.txt
index 050016a..623f3e4 100644
--- a/liquidfun/Box2D/CMakeLists.txt
+++ b/liquidfun/Box2D/CMakeLists.txt
@@ -160,6 +160,7 @@ set(EXE_OUTPUT_DIR "${OUTPUT_SUBDIR}")
foreach(target ${ALL_TARGETS})
set_target_properties(
${target} PROPERTIES
+ INSTALL_NAME_DIR "@rpath"
ARCHIVE_OUTPUT_DIRECTORY "${LIB_OUTPUT_DIR}"
LIBRARY_OUTPUT_DIRECTORY "${LIB_OUTPUT_DIR}"
RUNTIME_OUTPUT_DIRECTORY "${EXE_OUTPUT_DIR}")
68 changes: 68 additions & 0 deletions liquidfun/platform/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?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.3.2-SNAPSHOT</version>
<relativePath>../../</relativePath>
</parent>

<groupId>org.bytedeco.javacpp-presets</groupId>
<artifactId>liquidfun-platform</artifactId>
<version>20150401-0708ce1-${project.parent.version}</version>
<name>JavaCPP Presets Platform for LiquidFun</name>

<properties>
<javacpp.moduleId>liquidfun</javacpp.moduleId>
</properties>

<dependencies>
<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>
</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</Class-Path>
</manifestEntries>
</archive>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
74 changes: 74 additions & 0 deletions liquidfun/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?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.3.2-SNAPSHOT</version>
</parent>

<groupId>org.bytedeco.javacpp-presets</groupId>
<artifactId>liquidfun</artifactId>
<version>20150401-0708ce1-${project.parent.version}</version>
<packaging>jar</packaging>
<name>JavaCPP Presets for LiquidFun</name>

<properties>
<javacpp.platform.oldcompiler>${javacpp.platform.compiler}</javacpp.platform.oldcompiler>
</properties>

<dependencies>
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>javacpp</artifactId>
<version>1.3.2-SNAPSHOT</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.bytedeco</groupId>
<artifactId>javacpp</artifactId>
<version>1.3.2-SNAPSHOT</version>
<configuration>
<propertyKeysAndValues>
<property>
<name>platform.root</name>
<value>${javacpp.platform.root}</value>
</property>
<property>
<name>platform.compiler</name>
<value>${javacpp.platform.oldcompiler}</value>
</property>
</propertyKeysAndValues>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-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