Commit 46205049 authored by Yannick Heinrich's avatar Yannick Heinrich Committed by Xianwen Chen

Add assembly to produce standalone jar. (#324)

parent 2af44158
......@@ -6,13 +6,17 @@ ifndef ANDROID_NDK_HOME
ANDROID_NDK_HOME = $(abspath $(dir $(realpath $(shell which ndk-build))))
endif
SCALA_VERSION=2.11
DJINNI_VERSION=0.1-SNAPSHOT
OUTPUT_JAR=src/target/scala-$(SCALA_VERSION)/djinni-assembly-$(DJINNI_VERSION).jar
#
# Global targets.
#
all: djinni example_ios example_android example_localhost test
clean:
clean: djinni_jar_clean
-ndk-build -C example/android/app/ clean
-xcodebuild -workspace example/objc/TextSort.xcworkspace -scheme TextSort -configuration 'Debug' -sdk iphonesimulator clean
-rm -rf libs/
......@@ -30,6 +34,14 @@ clean:
djinni:
cd src && ./build
$(OUTPUT_JAR):
cd src && sbt assembly
djinni_jar: $(OUTPUT_JAR)
djinni_jar_clean:
cd src && sbt clean
# we specify a root target for android to prevent all of the targets from spidering out
GypAndroid.mk: ./deps/gyp example/libtextsort.gyp support-lib/support_lib.gyp example/example.djinni
./example/run_djinni.sh
......@@ -58,4 +70,4 @@ example_localhost: ./deps/java
test: ./deps/java
make -C test-suite
.PHONY: example_android example_ios example_localhost test djinni clean all
.PHONY: example_android example_ios example_localhost test djinni clean all dinni_jar
......@@ -450,6 +450,48 @@ integers are not included because they are not available in Java.
## Test Suite
Run `make test` to invoke the test suite, found in the test-suite subdirectory. It will build and run Java code on a local JVMy, plus Objective-C on an iOS simulator. The latter will only work on a Mac with Xcode.
## Generate a standalone jar
The `djinni_jar` target of the main `Makefile` creates a standalone `.jar`.
This uses the [sbt assembly plugin](https://github.com/sbt/sbt-assembly) under the hoods.
Simply call this target from the root directory:
```shell
make djinni_jar
```
This will produce a `.jar` file inside the `src/target/scala_<SCALA_VERSION>/djinni-assembly-<VERSION>.jar`.
You can move and use it as any other executable `.jar`.
Assuming the `.jar` is located at `$DJINNI_JAR_DIR` its version equals `0.1-SNAPSHOT`:
```shell
# Example
java -jar $DJINNI_JAR_DIR/djinni-assembly-0.1-SNAPSHOT.jar \
--java-out "$temp_out/java" \
--java-package $java_package \
--java-class-access-modifier "package" \
--java-nullable-annotation "javax.annotation.CheckForNull" \
--java-nonnull-annotation "javax.annotation.Nonnull" \
--ident-java-field mFooBar \
\
--cpp-out "$temp_out/cpp" \
--cpp-namespace textsort \
--ident-cpp-enum-type foo_bar \
\
--jni-out "$temp_out/jni" \
--ident-jni-class NativeFooBar \
--ident-jni-file NativeFooBar \
\
--objc-out "$temp_out/objc" \
--objcpp-out "$temp_out/objc" \
--objc-type-prefix TXS \
--objc-swift-bridging-header "TextSort-Bridging-Header" \
\
--idl "$in"
```
*Note*: The `all` target of the main `Makefile` includes the `djinni_jar` target.
## Community Links
* Join the discussion with other developers at the [Mobile C++ Slack Community](https://mobilecpp.herokuapp.com/)
......
addSbtPlugin("com.typesafe.sbt" % "sbt-start-script" % "0.10.0")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.5")
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment