Skip to content

Commit c2b76da

Browse files
authored
Chore/code comments (#9)
* Cleaned up all modules * Added inline code comments * Improved tests * Added native library loader * Cleaned native build scripts
1 parent c32f201 commit c2b76da

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+790
-427
lines changed

.scalafmt.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ continuationIndent.callSite = 2
1010
continuationIndent.defnSite = 2
1111
danglingParentheses = true
1212
indentOperator = spray
13-
maxColumn = 180
13+
maxColumn = 380
1414
project.git = true
1515
rewrite.rules = [RedundantParens, SortImports, PreferCurlyFors, SortModifiers]
1616
spaces.inImportCurlyBraces = false

build.sbt

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
name := "sdk-scala-binding"
1+
name := "freeton-sdk-client-scala-binding"
22

3-
version := "0.1"
3+
version := "1.0.0-M2"
44

5-
scalaVersion := "2.12.12"
5+
organization := "com.dancingcode"
66

7-
lazy val circeVersion = "0.13.0"
7+
scalaVersion := "2.12.12"
88

99
libraryDependencies ++= Seq(
1010
"org.slf4j" % "slf4j-api" % "1.7.30",
11-
"ch.qos.logback" % "logback-classic" % "1.2.3" % Test, // TODO make provided
11+
"ch.qos.logback" % "logback-classic" % "1.2.3" % Provided,
1212
"org.scalatest" %% "scalatest" % "3.2.2" % Test
1313
)
1414

15-
libraryDependencies ++= Seq("circe-core", "circe-generic", "circe-parser", "circe-literal").map("io.circe" %% _ % circeVersion)
15+
libraryDependencies ++= Seq("circe-core", "circe-generic", "circe-parser", "circe-literal").map("io.circe" %% _ % "0.13.0")
1616

1717
scalacOptions in Compile ++= Seq(
1818
"-Xlog-reflective-calls",
@@ -25,12 +25,23 @@ scalacOptions in Compile ++= Seq(
2525
"-Ywarn-numeric-widen",
2626
"-Ywarn-value-discard",
2727
"-Yrangepos"
28-
// "-Xfatal-warnings"
2928
)
3029

3130
fork in Test := true
3231

32+
// settings for Sonatype
33+
homepage := Some(url("https://github.com/slavaschmidt/ton-sdk-client-scala-binding"))
34+
scmInfo := Some(ScmInfo(url("https://github.com/slavaschmidt/ton-sdk-client-scala-binding"), "[email protected]:slavaschmidt/ton-sdk-client-scala-binding.git"))
35+
developers := List(Developer("slasch", "Slava Schmidt", "[email protected]", url("https://github.com/slavaschmidt")))
36+
licenses += ("Apache-2.0", url("http://www.apache.org/licenses/LICENSE-2.0"))
37+
publishMavenStyle := true
38+
39+
// Add sonatype repository settings
40+
publishTo := Some(if (isSnapshot.value) Opts.resolver.sonatypeSnapshots else Opts.resolver.sonatypeStaging)
41+
42+
credentials += Credentials(Path.userHome / ".sbt" / "sonatype_credentials")
43+
3344
envVars in Test := Map(
34-
"LD_LIBRARY_PATH" -> (baseDirectory.value / "lib").getPath,
35-
"PATH" -> (baseDirectory.value / "lib").getPath
45+
"LD_LIBRARY_PATH" -> (resourceDirectory in Compile).value.getAbsolutePath,
46+
"PATH" -> (resourceDirectory in Compile).value.getAbsolutePath
3647
)

project/plugins.sbt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.0")
2-
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.0")
1+
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.0")
2+
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.0")
3+
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.3")
4+
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.1")

src/main/c/build_jni_header.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash -eE
2+
3+
cd ../../..
4+
5+
sbt compile
6+
7+
CP=~/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.12.12.jar
8+
9+
javah -cp $CP:target/scala-2.12/classes/ton.sdk.client.jni.Binding
10+
11+
mv ton_sdk_client_jni_Binding.h src/main/c/
12+
13+
cd -

src/main/c/build_linux.sh

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,16 @@
22

33
export JAVA_HOME=`dirname $(dirname $(readlink -f $(which javac)))`
44

5-
export LIBS="$(pwd)/lib"
6-
7-
echo "$LIBS"
8-
echo "$JAVA_HOME"
9-
10-
ls "$JAVA_HOME/include/linux"
11-
12-
cd src/main/c
13-
145
gcc \
156
-shared \
167
-fPIC \
178
-I"$JAVA_HOME/include/linux" \
189
-I"$JAVA_HOME/include" \
1910
-L"$LIBS" \
2011
*.c \
21-
-o "$LIBS/libTonSdkClientJniBinding.so" \
12+
-o "libTonSdkClientJniBinding.so" \
2213
-lton_client
2314

24-
# -dynamiclib \
25-
cd -
2615

2716

2817

src/main/c/build_mac_os_x.sh

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22

33
export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
44

5-
export LIBS="$(pwd)/lib"
6-
7-
#sbt compile
8-
#CP=/Users/slasch/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.13.3.jar
9-
#javah -cp $CP:target/scala-2.13/classes/ ton.sdk.client.jni.Binding
10-
#mv ton_sdk_client_jni_Binding.h src/main/c/
115

126
cd src/main/c
137

src/main/c/build_windows.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
@ECHO OFF
2+
3+
# expects JAVA_HOME to be properly set on system level and point to JDK
4+
# for example JAVA_HOME="c:\work\jdk1.8.0_271"
5+
6+
## don't forget to add long long definition to jni_md.h as in following:
7+
8+
# # ifdef __GNUC__
9+
# typedef long long jlong;
10+
# #else
11+
# typedef _int64 jlong;
12+
# #endif
13+
14+
cl *.c -I"!JAVA_HOME!\include\win32" -I"!JAVA_HOME!\include" -MD -LD -link "ton_client.dll.lib"
15+

src/main/c/run.sh

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/main/c/windows_build.sh

Lines changed: 0 additions & 18 deletions
This file was deleted.
File renamed without changes.

0 commit comments

Comments
 (0)