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

Resolve merge conflicts from the origin repo #2

Open
wants to merge 74 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
64a9d3a
Support --idl-include-path argument to configure include paths
GreatCall-KayeK Jul 13, 2016
1ee7a55
Resolve import and extern based on include provided include path
GreatCall-KayeK Jul 13, 2016
6c869e1
Fix use of extended record include prefix
Aug 10, 2016
7300e57
Fixed import guard when using relative file paths
Aug 19, 2016
ddcf5bb
Merge pull request #273 from konovalov-aleks/fix_relative_paths_bug
artwyman Aug 23, 2016
5f37cfe
Fixed crash in the case where the parameters "--list-in-files" and "-…
Aug 23, 2016
74676e9
Merge pull request #274 from konovalov-aleks/fix_crash
artwyman Aug 23, 2016
a9f61c6
Set minimum compatible IDEA API version to 139. The plugin does not w…
jaetzold Oct 19, 2016
69bf8b2
Merge pull request #283 from jaetzold/master
artwyman Oct 20, 2016
2c0a5be
Update intellij plugin description to include license text. Make the …
jaetzold Oct 21, 2016
25f54f8
Merge pull request #284 from jaetzold/master
artwyman Oct 25, 2016
d28a844
Fix typo existance
ferambot Nov 5, 2016
0cf675b
Fix typo fiels
ferambot Nov 5, 2016
c3b557f
Fix typo follwoing
ferambot Nov 5, 2016
066e39d
Fix typo occured
ferambot Nov 5, 2016
490e6b8
Fix typo referencs
ferambot Nov 5, 2016
28529df
Fix typo unkown
ferambot Nov 5, 2016
64c7ef7
Update ios version in Make targets to 10.1.
Nov 10, 2016
96d8b44
Merge pull request #289 from csimmons0/ios-version-10.1
artwyman Nov 12, 2016
0983bca
Remove --idl-include-path from example
GreatCall-KayeK Dec 8, 2016
a8c8971
Default include path is directory of first included file
GreatCall-KayeK Dec 8, 2016
512f3dc
Finish searching for import files after one is found in the include path
GreatCall-KayeK Dec 9, 2016
d6ce638
Add test case for relative path not using include paths
GreatCall-KayeK Dec 9, 2016
3af6aaf
Merge remote-tracking branch 'upstream/master' into kkaye/include-paths
GreatCall-KayeK Dec 9, 2016
ef936c4
Update ObjC build files for Xcode 8.2
Dec 23, 2016
0dd240d
Test relative paths with an input file from common.djinni
Dec 23, 2016
b33d05d
djinni_jni_main target
Aug 17, 2016
7f9bfef
Add @autorelease pool in ObjC proxy destructors
Sep 29, 2016
7e09a2c
Merge pull request #285 from ronbak/feram-patches
artwyman Dec 28, 2016
bbf14ae
Simplify ObjcProxyBase
Jan 4, 2017
6a497f5
Merge pull request #292 from dropbox/atwyman/objc_proxy_cleanup
artwyman Jan 6, 2017
f9f2186
File paths are handled by File constructor
GreatCall-KayeK Jan 12, 2017
a440560
Merge remote-tracking branch 'upstream/master' into kkaye/include-paths
GreatCall-KayeK Jan 12, 2017
c5b923f
Merge pull request #252 from GreatCall-KayeK/kkaye/include-paths
artwyman Jan 14, 2017
622b870
Allow setting of ident style to all Java classes
izacus Jan 2, 2017
1d74e31
Merge pull request #228 from PSPDFKit-labs/add-class-prefix
artwyman Jan 20, 2017
715c620
fixing error from clang
alexcohn Jan 22, 2017
348e804
Merge pull request #296 from alexcohn/alexcohn-fix-294
artwyman Feb 1, 2017
eebdf49
Generate bridging header for Swift
4brunu Mar 10, 2017
b3df82b
Fix little typo in links section
Mar 14, 2017
cfd0273
add CMake support to djinni
4brunu Mar 16, 2017
697bde6
Merge pull request #302 from nmtitov/fix-readme-typo
artwyman Mar 31, 2017
568b08b
Apply target_compile_options to all targets
4brunu Mar 31, 2017
fde1163
Update example to include a swift and objc listener
4brunu Apr 3, 2017
f4580a4
Require only the bridging header name instead of it’s path
4brunu Apr 3, 2017
52f4e25
Revert "Update example to include a swift and objc listener"
4brunu Apr 4, 2017
7545e30
Simplify iOS example
4brunu Apr 4, 2017
9400d37
revert unintended generator change
4brunu Apr 4, 2017
8528ff9
move CMakeLists.txt file to root directory and rename target name to …
4brunu Apr 4, 2017
66f6d9b
Make Swift code more idiomatic
4brunu Apr 5, 2017
eb02361
Making three changes to fix compilation in our environment.
msjarrett Apr 6, 2017
6a3b969
Adding comment to warn of the potential segfault in gcc.
msjarrett Apr 6, 2017
0c1aa24
Merge pull request #303 from 4brunu/cmake
artwyman Apr 7, 2017
69ebe88
Merge pull request #301 from 4brunu/ObjcSwiftBridgingHEader
artwyman Apr 7, 2017
bdbdcc0
Renaming "temp" to "proxy_handle" to make more readable.
msjarrett Apr 7, 2017
c73950e
Swap the README.md change for a CONTRIBUTORS file for attribution.
msjarrett Apr 11, 2017
554a3b2
Fix rsync commands to not update timestamps on unchanged contents
May 18, 2017
bca8b4b
Merge pull request #309 from msjarrett/cppfixes-201704
artwyman Jun 10, 2017
b55ac10
[Android] Fix Djinni initialization crash in multi shared library cas…
Guillaume227 Jun 28, 2017
e54dab6
Avoid unused variable warning when compiling djinni_support.cpp (#319)
Aug 16, 2017
d8ef452
Added missing std:: in platform_threads_impl (#321)
choiip Aug 17, 2017
896aacb
Fix CFStringEncoding/NSStringEncoding confusion
jgus Sep 6, 2017
85e0f3f
Add Xianwen to contacts
Sep 26, 2017
a48be3e
Merge pull request #326 from RoomieRemote/master
Sep 26, 2017
2af4415
New "flags" archetype for enums oriented towards bitwise flags (#323)
choiip Sep 28, 2017
4620504
Add assembly to produce standalone jar. (#324)
yageek Oct 4, 2017
9aec188
Android parcelable support (#308)
4brunu Oct 4, 2017
e675e31
Upgrade the example to Gradle 4.2 and Android plugin 2.3.3 (#329)
sschuberth Oct 11, 2017
ddbe4d9
Add a script to build static fat binary lib. (#341)
yageek Jan 3, 2018
86ba6b5
Separate `flags` to `enum_flags.djinni` (#346)
Jan 4, 2018
565425d
Upgrade example build (#339)
sschuberth Jan 4, 2018
0001a3e
Follow naming convention for parameter names in method docstrings (#352)
louiswins Feb 22, 2018
9463fa9
Generate an XCode like bridging header. (#342)
yageek Mar 2, 2018
55af7b9
Merged inherited interfaces feature branch with the latest master
Mar 20, 2018
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
72 changes: 72 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
cmake_minimum_required(VERSION 3.6.0)

project(djinni_support_lib)

include(GNUInstallDirs)

set(SRC_SHARED
"support-lib/djinni_common.hpp"
"support-lib/proxy_cache_interface.hpp"
"support-lib/proxy_cache_impl.hpp"
)

set(SRC_JNI
"support-lib/jni/djinni_support.hpp"
"support-lib/jni/Marshal.hpp"
"support-lib/jni/djinni_support.cpp"
)

set(SRC_OBJC
"support-lib/objc/DJICppWrapperCache+Private.h"
"support-lib/objc/DJIError.h"
"support-lib/objc/DJIMarshal+Private.h"
"support-lib/objc/DJIObjcWrapperCache+Private.h"
"support-lib/objc/DJIError.mm"
"support-lib/objc/DJIProxyCaches.mm"
)

option(DJINNI_STATIC_LIB "Build Djinni support library as a static library instead of dynamic (the default)." off)
if(DJINNI_STATIC_LIB)
add_library(djinni_support_lib STATIC ${SRC_SHARED})
else()
add_library(djinni_support_lib SHARED ${SRC_SHARED})
endif()
source_group("" FILES ${SRC_SHARED})

set_target_properties(djinni_support_lib PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED true
CXX_EXTENSIONS false
)

# Objective-C support
option(DJINNI_WITH_OBJC "Include the Objective-C support code in Djinni support library." off)
if(DJINNI_WITH_OBJC)
target_include_directories(djinni_support_lib PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/support-lib/objc/>")
target_sources(djinni_support_lib PRIVATE ${SRC_OBJC})
source_group("objc" FILES ${SRC_OBJC})
target_compile_options(djinni_support_lib PUBLIC "-fobjc-arc")
endif()

# JNI support
option(DJINNI_WITH_JNI "Include the JNI support code in Djinni support library." off)
if(DJINNI_WITH_JNI)
if(NOT DJINNI_STATIC_LIB)
list(APPEND SRC_JNI "support-lib/jni/djinni_main.cpp")
endif()
target_include_directories(djinni_support_lib PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/support-lib/jni/>")
target_sources(djinni_support_lib PRIVATE ${SRC_JNI})
source_group("jni" FILES ${SRC_JNI})
# Do not use the host's jni.h on Android as it is provided automatically by the NDK
if(NOT ANDROID)
find_package(JNI REQUIRED QUIET)
target_include_directories(djinni_support_lib PUBLIC "${JNI_INCLUDE_DIRS}")
endif()
endif()

if(NOT (DJINNI_WITH_OBJC OR DJINNI_WITH_JNI))
message(FATAL_ERROR "At least one of DJINNI_WITH_OBJC or DJINNI_WITH_JNI must be enabled.")
endif()

# Store path to the "run" executable so it can be passed as argument to add_custom_command() scripts
set(DJINNI_RUN_PATH "${CMAKE_CURRENT_SOURCE_DIR}/src/run" CACHE FILEPATH "Path to the Djinni generator executable.")
8 changes: 8 additions & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
The following is a partial list of individuals or corporations
who have identified their contributions to the djinni project.

The complete list of contributors can be identified through
Git history.

- Google Inc.

19 changes: 15 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand All @@ -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
Expand All @@ -44,8 +56,7 @@ example_ios: ./build_ios/example/libtextsort.xcodeproj
xcodebuild -workspace example/objc/TextSort.xcworkspace \
-scheme TextSort \
-configuration 'Debug' \
-sdk iphonesimulator \
-destination 'platform=iOS Simulator,name=iPhone 6s,OS=9.3'
-sdk iphonesimulator

# this target implicitly depends on GypAndroid.mk since gradle will try to make it
example_android: GypAndroid.mk
Expand All @@ -59,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
119 changes: 104 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Djinni generates code based on interface definitions in an IDL file. An IDL file
three kinds of declarations: enums, records, and interfaces.

* Enums become C++ enum classes, Java enums, or ObjC `NS_ENUM`s.
* Flags become C++ enum classes with convenient bit-oriented operators, Java enums with `EnumSet`, or ObjC `NS_OPTIONS`.
* Records are pure-data value objects.
* Interfaces are objects with defined methods to call (in C++, passed by `shared_ptr`). Djinni
produces code allowing an interface implemented in C++ to be transparently used from ObjC or
Expand All @@ -40,6 +41,14 @@ Djinni's input is an interface description file. Here's an example:
option3;
}

my_flags = flags {
flag1;
flag2;
flag3;
no_flags = none;
all_flags = all;
}

my_record = record {
id: i32;
info: string;
Expand Down Expand Up @@ -125,11 +134,11 @@ For more information, run `run --help` to see all command line arguments availab
##### Includes & Build target
The following headers / code will be generated for each defined type:

| Type | C++ header | C++ source | Java | JNI header | JNI source |
|-----------|------------------------|----------------------------|---------------------|-----------------------|-----------------------|
| Enum | my\_enum.hpp | | MyEnum.java | NativeMyEnum.hpp | NativeMyEnum.cpp |
| Record | my\_record[\_base].hpp | my\_record[\_base].cpp (+) | MyRecord[Base].java | NativeMyRecord.hpp | NativeMyRecord.cpp |
| Interface | my\_interface.hpp | my\_interface.cpp (+) | MyInterface.java | NativeMyInterface.hpp | NativeMyInterface.cpp |
| Type | C++ header | C++ source | Java | JNI header | JNI source |
|------------|------------------------|----------------------------|---------------------|-----------------------|-----------------------|
| Enum/Flags | my\_enum.hpp | | MyEnum.java | NativeMyEnum.hpp | NativeMyEnum.cpp |
| Record | my\_record[\_base].hpp | my\_record[\_base].cpp (+) | MyRecord[Base].java | NativeMyRecord.hpp | NativeMyRecord.cpp |
| Interface | my\_interface.hpp | my\_interface.cpp (+) | MyInterface.java | NativeMyInterface.hpp | NativeMyInterface.cpp |

(+) Generated only for types that contain constants.

Expand Down Expand Up @@ -164,13 +173,13 @@ you'll need to add calls to your own `JNI_OnLoad` and `JNI_OnUnload` functions.
##### Includes & Build Target
Generated files for Objective-C / C++ are as follows (assuming prefix is `DB`):

| Type | C++ header | C++ source | Objective-C files | Objective-C++ files |
|-----------|------------------------|----------------------------|--------------------------|-----------------------------|
| Enum | my\_enum.hpp | | DBMyEnum.h | |
| Record | my\_record[\_base].hpp | my\_record[\_base].cpp (+) | DBMyRecord[Base].h | DBMyRecord[Base]+Private.h |
| | | | DBMyRecord[Base].mm (++) | DBMyRecord[Base]+Private.mm |
| Interface | my\_interface.hpp | my\_interface.cpp (+) | DBMyInterface.h | DBMyInterface+Private.h |
| | | | | DBMyInterface+Private.mm |
| Type | C++ header | C++ source | Objective-C files | Objective-C++ files |
|------------|------------------------|----------------------------|--------------------------|-----------------------------|
| Enum/Flags | my\_enum.hpp | | DBMyEnum.h | |
| Record | my\_record[\_base].hpp | my\_record[\_base].cpp (+) | DBMyRecord[Base].h | DBMyRecord[Base]+Private.h |
| | | | DBMyRecord[Base].mm (++) | DBMyRecord[Base]+Private.mm |
| Interface | my\_interface.hpp | my\_interface.cpp (+) | DBMyInterface.h | DBMyInterface+Private.h |
| | | | | DBMyInterface+Private.mm |

(+) Generated only for types that contain constants.
(++) Generated only for types with derived operations and/or constants. These have `.mm` extensions to allow non-trivial constants.
Expand All @@ -183,6 +192,28 @@ Note that `+Private` files can only be used with ObjC++ source (other headers ar
Enums are translated to C++ `enum class`es with underlying type `int`, ObjC `NS_ENUM`s with
underlying type `NSInteger`, and Java enums.

### Flags
Flags are translated to C++ `enum class`es with underlying type `unsigned` and a generated set
of overloaded bitwise operators for convenience, ObjC `NS_OPTIONS` with underlying type
`NSUInteger`, and Java `EnumSet<>`. Contrary to the above enums, the enumerants of flags represent
single bits instead of integral values.

When specifying a `flags` type in your IDL file you can assign special semantics to options:

```
my_flags = flags {
flag1;
flag2;
flag3;
no_flags = none;
all_flags = all;
}
```
In the above example the elements marked with `none` and `all` are given special meaning.
In C++ and ObjC the `no_flags` option is generated with a value that has no bits set (i.e. `0`),
and `all_flags` is generated as a bitwise-or combination of all other values. In Java these
special options are not generated as one can just use `EnumSet.noneOf()` and `EnumSet.allOf()`.

### Record
Records are data objects. In C++, records contain all their elements by value, including other
records (so a record cannot contain itself).
Expand All @@ -203,7 +234,7 @@ The available data types for a record, argument, or return value are:
Objective-C. Primitives in a set will be boxed in Java and Objective-C.
- Map (`map<typeA, typeB>`). This is `unordered_map<K, V>` in C++, `HashMap` in Java, and
`NSDictionary` in Objective-C. Primitives in a map will be boxed in Java and Objective-C.
- Enumerations
- Enumerations / Flags
- Optionals (`optional<typeA>`). This is `std::experimental::optional<T>` in C++11, object /
boxed primitive reference in Java (which can be `null`), and object / NSNumber strong
reference in Objective-C (which can be `nil`).
Expand Down Expand Up @@ -267,7 +298,7 @@ When generating the interface for your project and wish to make it available to
in all of C++/Objective-C/Java you can tell Djinni to generate a special YAML file as part
of the code generation process. This file then contains all the information Djinni requires
to include your types in a different project. Instructing Djinni to create these YAML files
is controlled by the follwoing arguments:
is controlled by the following arguments:
- `--yaml-out`: The output folder for YAML files (Generator disabled if unspecified).
- `--yaml-out-file`: If specified all types are merged into a single YAML file instead of generating one file per type (relative to `--yaml-out`).
- `--yaml-prefix`: The prefix to add to type names stored in YAML files (default: `""`).
Expand Down Expand Up @@ -419,13 +450,70 @@ 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.

## Generate an iOS universal binary of the support library.

The `ios-build-support-lib.sh` helps you to build an universal static library for iOS platforms.
It uses the platform file of the [ios-cmake](https://github.com/leetal/ios-cmake) repository.

It basically creates one universal static library per `IOS_PLATFORM` variable and uses `lipo`
to merge all the files in one.

There is basically two variables you would like to modify:

- `BUILD_APPLE_ARCHITECTURES`: Specifies which `IOS_PLATFORM` to build.
For more informations, take a look at https://github.com/leetal/ios-cmake.

- `ENABLE_BITCODE`: enable/disable the bitcode generation.

## Community Links

* Join the discussion with other developers at the [Mobile C++ Slack Community](https://mobilecpp.herokuapp.com/)
* There are a set of [tutorials](http://mobilecpptutorials.com/) for building a cross-platform app using Djinni.
* [mx3](https://github.com/libmx3/mx3) is an example project demonstrating use of Djinni and other tools.
* [Slides](https://bit.ly/djinnitalk) and [video](https://bit.ly/djinnivideo) from the CppCon 2014 talk where we introduced Djinni.
* [Slides](https://bit.ly/djinnitalk2) and [video](https://bit.ly/djinnivideo2) from the CppCon 2015 about Djinni implementatino techniques, and the addition of Python.
* [Slides](https://bit.ly/djinnitalk2) and [video](https://bit.ly/djinnivideo2) from the CppCon 2015 about Djinni implementation techniques, and the addition of Python.
* You can see a [CppCon 2014 talk](https://www.youtube.com/watch?v=5AZMEm3rZ2Y) by app developers at Dropbox about their cross-platform experiences.

## Authors
Expand All @@ -438,5 +526,6 @@ Run `make test` to invoke the test suite, found in the test-suite subdirectory.
- Andrew Twyman

## Contacts
- Xianwen Chen - `[email protected]`
- Andrew Twyman - `[email protected]`
- Jacob Potter - `[email protected]`
Loading