-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial commit: migrate code from original djinni repo & add some bas…
…ic integration testing (#2)
- Loading branch information
Showing
98 changed files
with
7,507 additions
and
2 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,8 @@ | ||
root=true | ||
|
||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 2 |
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,47 @@ | ||
name: CI | ||
on: | ||
push: | ||
branches: | ||
- '*' | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Caching dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/.sbt | ||
~/.ivy2 | ||
key: scala-build-deps | ||
- name: Building | ||
run: sbt assembly | ||
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: djinni-generator | ||
path: target/bin/djinni | ||
it: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Caching dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/.sbt | ||
~/.ivy2 | ||
key: scala-build-deps | ||
- uses: actions/download-artifact@v2 | ||
with: | ||
name: djinni-generator | ||
path: target/bin | ||
- name: Restoring file permissions of artifact | ||
run: chmod u+x target/bin/djinni | ||
- name: Running integration-tests | ||
run: sbt it:test |
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,5 @@ | ||
/target | ||
/project/project | ||
/project/target | ||
/test/result | ||
/classes |
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 |
---|---|---|
@@ -1,2 +1,63 @@ | ||
# djinni-generator | ||
CLI that generates gluecode from a djinni-idl file | ||
# Djinni Generator | ||
|
||
Parses an interface definition file and generates: | ||
- C++ implementations of types (enums, records) | ||
- Java implementations of types | ||
- Objective-C implementations of types | ||
- C++ code to convert between C++ and Java over JNI | ||
- Objective-C++ code to convert between C++ and Objective-C. | ||
|
||
## Build dependencies | ||
|
||
- Java 8 | ||
- sbt | ||
|
||
## Building | ||
|
||
To build once: | ||
|
||
```bash | ||
sbt compile | ||
``` | ||
|
||
To automatically re-build on every change, open the sbt shell & prefix `compile` with `~` | ||
|
||
```bash | ||
$ sbt | ||
sbt:djinni> ~compile | ||
``` | ||
|
||
|
||
## Running | ||
|
||
```bash | ||
sbt "run | ||
--idl input.djinni | ||
--cpp-out out/cpp | ||
--java-out out/java/src | ||
--jni-out out/java/jni | ||
--objc-out out/objc" | ||
``` | ||
|
||
```bash | ||
sbt "run --help" # show all options | ||
``` | ||
|
||
*It is important to put `run` and all arguments in `"`, to be able to pass arguments to the executed jar* | ||
|
||
## Packaging | ||
|
||
To create a standalone jar run | ||
|
||
```bash | ||
sbt assembly | ||
``` | ||
|
||
This will generate a standalone, self-executing jar in `target/bin`. | ||
You can run the jar like this (no need for `java -jar`): | ||
|
||
```bash | ||
./djinni --help | ||
``` | ||
|
||
On Windows the file must be renamed to `djinni.bat` to make it executable. |
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,25 @@ | ||
import sbtassembly.AssemblyPlugin.defaultUniversalScript | ||
|
||
ThisBuild / scalaVersion := "2.12.12" | ||
ThisBuild / organization := "com.github.cross-language-cpp" | ||
|
||
lazy val djinni = (project in file(".")) | ||
.configs(IntegrationTest) | ||
.settings( | ||
name := "djinni", | ||
version := "0.1.0", | ||
Defaults.itSettings, | ||
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.5" % "it", | ||
libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "1.1.2", | ||
libraryDependencies += "org.yaml" % "snakeyaml" % "1.26", | ||
libraryDependencies += "com.github.scopt" %% "scopt" % "3.7.1", | ||
assemblyOutputPath in assembly := { file("target/bin") / (assemblyJarName in assembly).value }, | ||
assemblyJarName in assembly := s"${name.value}", | ||
assemblyOption in assembly := (assemblyOption in assembly).value.copy(prependShellScript = Some(defaultUniversalScript(shebang = false))), | ||
test in assembly := {} | ||
) | ||
|
||
|
||
|
||
|
||
|
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 @@ | ||
sbt.version=1.3.13 |
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 @@ | ||
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.15.0") |
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,16 @@ | ||
all_datatypes = record { | ||
booleanData: bool; | ||
integer8Data: i8; | ||
integer16Data: i16; | ||
integer32Data: i32; | ||
integer64Data: i64; | ||
float32Data: f32; | ||
float64Data: f64; | ||
stringData: string; | ||
binaryData: binary; | ||
dateData: date; | ||
listData: list<bool>; | ||
setData: set<bool>; | ||
mapData: map<i8, bool>; | ||
optionalData: optional<bool>; | ||
} |
60 changes: 60 additions & 0 deletions
60
src/it/resources/expected/all_datatypes/cpp/all_datatypes.hpp
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,60 @@ | ||
// AUTOGENERATED FILE - DO NOT MODIFY! | ||
// This file generated by Djinni from all_datatypes.djinni | ||
|
||
#pragma once | ||
|
||
#include <chrono> | ||
#include <cstdint> | ||
#include <optional> | ||
#include <string> | ||
#include <unordered_map> | ||
#include <unordered_set> | ||
#include <utility> | ||
#include <vector> | ||
|
||
struct AllDatatypes final { | ||
bool booleanData; | ||
int8_t integer8Data; | ||
int16_t integer16Data; | ||
int32_t integer32Data; | ||
int64_t integer64Data; | ||
float float32Data; | ||
double float64Data; | ||
std::string stringData; | ||
std::vector<uint8_t> binaryData; | ||
std::chrono::system_clock::time_point dateData; | ||
std::vector<bool> listData; | ||
std::unordered_set<bool> setData; | ||
std::unordered_map<int8_t, bool> mapData; | ||
std::optional<bool> optionalData; | ||
|
||
AllDatatypes(bool booleanData_, | ||
int8_t integer8Data_, | ||
int16_t integer16Data_, | ||
int32_t integer32Data_, | ||
int64_t integer64Data_, | ||
float float32Data_, | ||
double float64Data_, | ||
std::string stringData_, | ||
std::vector<uint8_t> binaryData_, | ||
std::chrono::system_clock::time_point dateData_, | ||
std::vector<bool> listData_, | ||
std::unordered_set<bool> setData_, | ||
std::unordered_map<int8_t, bool> mapData_, | ||
std::optional<bool> optionalData_) | ||
: booleanData(std::move(booleanData_)) | ||
, integer8Data(std::move(integer8Data_)) | ||
, integer16Data(std::move(integer16Data_)) | ||
, integer32Data(std::move(integer32Data_)) | ||
, integer64Data(std::move(integer64Data_)) | ||
, float32Data(std::move(float32Data_)) | ||
, float64Data(std::move(float64Data_)) | ||
, stringData(std::move(stringData_)) | ||
, binaryData(std::move(binaryData_)) | ||
, dateData(std::move(dateData_)) | ||
, listData(std::move(listData_)) | ||
, setData(std::move(setData_)) | ||
, mapData(std::move(mapData_)) | ||
, optionalData(std::move(optionalData_)) | ||
{} | ||
}; |
149 changes: 149 additions & 0 deletions
149
src/it/resources/expected/all_datatypes/java/AllDatatypes.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,149 @@ | ||
// AUTOGENERATED FILE - DO NOT MODIFY! | ||
// This file generated by Djinni from all_datatypes.djinni | ||
|
||
package djinni.it; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Date; | ||
import java.util.HashMap; | ||
import java.util.HashSet; | ||
|
||
public final class AllDatatypes { | ||
|
||
|
||
/*package*/ final boolean booleanData; | ||
|
||
/*package*/ final byte integer8Data; | ||
|
||
/*package*/ final short integer16Data; | ||
|
||
/*package*/ final int integer32Data; | ||
|
||
/*package*/ final long integer64Data; | ||
|
||
/*package*/ final float float32Data; | ||
|
||
/*package*/ final double float64Data; | ||
|
||
/*package*/ final String stringData; | ||
|
||
/*package*/ final byte[] binaryData; | ||
|
||
/*package*/ final Date dateData; | ||
|
||
/*package*/ final ArrayList<Boolean> listData; | ||
|
||
/*package*/ final HashSet<Boolean> setData; | ||
|
||
/*package*/ final HashMap<Byte, Boolean> mapData; | ||
|
||
/*package*/ final Boolean optionalData; | ||
|
||
public AllDatatypes( | ||
boolean booleanData, | ||
byte integer8Data, | ||
short integer16Data, | ||
int integer32Data, | ||
long integer64Data, | ||
float float32Data, | ||
double float64Data, | ||
String stringData, | ||
byte[] binaryData, | ||
Date dateData, | ||
ArrayList<Boolean> listData, | ||
HashSet<Boolean> setData, | ||
HashMap<Byte, Boolean> mapData, | ||
Boolean optionalData) { | ||
this.booleanData = booleanData; | ||
this.integer8Data = integer8Data; | ||
this.integer16Data = integer16Data; | ||
this.integer32Data = integer32Data; | ||
this.integer64Data = integer64Data; | ||
this.float32Data = float32Data; | ||
this.float64Data = float64Data; | ||
this.stringData = stringData; | ||
this.binaryData = binaryData; | ||
this.dateData = dateData; | ||
this.listData = listData; | ||
this.setData = setData; | ||
this.mapData = mapData; | ||
this.optionalData = optionalData; | ||
} | ||
|
||
public boolean getBooleanData() { | ||
return booleanData; | ||
} | ||
|
||
public byte getInteger8Data() { | ||
return integer8Data; | ||
} | ||
|
||
public short getInteger16Data() { | ||
return integer16Data; | ||
} | ||
|
||
public int getInteger32Data() { | ||
return integer32Data; | ||
} | ||
|
||
public long getInteger64Data() { | ||
return integer64Data; | ||
} | ||
|
||
public float getFloat32Data() { | ||
return float32Data; | ||
} | ||
|
||
public double getFloat64Data() { | ||
return float64Data; | ||
} | ||
|
||
public String getStringData() { | ||
return stringData; | ||
} | ||
|
||
public byte[] getBinaryData() { | ||
return binaryData; | ||
} | ||
|
||
public Date getDateData() { | ||
return dateData; | ||
} | ||
|
||
public ArrayList<Boolean> getListData() { | ||
return listData; | ||
} | ||
|
||
public HashSet<Boolean> getSetData() { | ||
return setData; | ||
} | ||
|
||
public HashMap<Byte, Boolean> getMapData() { | ||
return mapData; | ||
} | ||
|
||
public Boolean getOptionalData() { | ||
return optionalData; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "AllDatatypes{" + | ||
"booleanData=" + booleanData + | ||
"," + "integer8Data=" + integer8Data + | ||
"," + "integer16Data=" + integer16Data + | ||
"," + "integer32Data=" + integer32Data + | ||
"," + "integer64Data=" + integer64Data + | ||
"," + "float32Data=" + float32Data + | ||
"," + "float64Data=" + float64Data + | ||
"," + "stringData=" + stringData + | ||
"," + "binaryData=" + binaryData + | ||
"," + "dateData=" + dateData + | ||
"," + "listData=" + listData + | ||
"," + "setData=" + setData + | ||
"," + "mapData=" + mapData + | ||
"," + "optionalData=" + optionalData + | ||
"}"; | ||
} | ||
|
||
} |
Oops, something went wrong.