Skip to content

Commit

Permalink
Separated module that holds only mbedtls binaries: mbedtls-lib
Browse files Browse the repository at this point in the history
  • Loading branch information
szysas committed Dec 28, 2022
1 parent 14ce878 commit 8a8fec9
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/compile-mbedtls.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: linux-x86-64
path: kotlin-mbedtls/src/main/resources/linux-x86-64/*
path: mbedtls-lib/bin/linux-x86-64/*
if-no-files-found: error

compile-macos:
Expand All @@ -35,5 +35,5 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: darwin
path: kotlin-mbedtls/src/main/resources/darwin/*
path: mbedtls-lib/bin/darwin/*
if-no-files-found: error
15 changes: 7 additions & 8 deletions compileMbedtls.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
#!/bin/bash
MBEDTLS_VERSION=3.3.0
BUILD_DIR=kotlin-mbedtls/build/mbedtls-${MBEDTLS_VERSION}
SRC=kotlin-mbedtls/src
BUILD_DIR=mbedtls-lib/build/mbedtls-${MBEDTLS_VERSION}
DLEXT="${DLEXT:-so}"
OSARCH="${OSARCH:-linux-x86-64}"

# download
mkdir -p kotlin-mbedtls/build
wget -N https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/v${MBEDTLS_VERSION}.tar.gz -O kotlin-mbedtls/build/mbedtls.tar.gz
mkdir -p mbedtls-lib/build
wget -N https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/v${MBEDTLS_VERSION}.tar.gz -O mbedtls-lib/build/mbedtls.tar.gz
rm -rf ${BUILD_DIR}
tar -xf kotlin-mbedtls/build/mbedtls.tar.gz -C kotlin-mbedtls/build/ --no-same-owner
tar -xf mbedtls-lib/build/mbedtls.tar.gz -C mbedtls-lib/build/ --no-same-owner

# install python requirements
python3 -m pip install -r ${BUILD_DIR}/scripts/basic.requirements.txt
Expand All @@ -25,13 +24,13 @@ export SHARED=true
(cd ${BUILD_DIR} && make lib)

# copy binaries
LIB_DIR="$SRC/main/resources/$OSARCH"
LIB_DIR="mbedtls-lib/bin/$OSARCH"
rm ${LIB_DIR}/*
cp ${BUILD_DIR}/library/libmbedtls.${DLEXT} ${LIB_DIR}/libmbedtls-${MBEDTLS_VERSION}.${DLEXT}
cp ${BUILD_DIR}/library/libmbedcrypto.${DLEXT} ${LIB_DIR}/libmbedcrypto-${MBEDTLS_VERSION}.${DLEXT}
cp ${BUILD_DIR}/library/libmbedx509.${DLEXT} ${LIB_DIR}/libmbedx509-${MBEDTLS_VERSION}.${DLEXT}


# generate kotlin object with memory sizes
gcc $SRC/test/c/mbedtls_sizeof_generator.c -I${BUILD_DIR}/include -I${BUILD_DIR}/crypto/include -o kotlin-mbedtls/build/mbedtls_sizeof_generator
./kotlin-mbedtls/build/mbedtls_sizeof_generator > $SRC/main/kotlin/org/opencoap/ssl/MbedtlsSizeOf.kt
gcc mbedtls-lib/mbedtls_sizeof_generator.c -I${BUILD_DIR}/include -I${BUILD_DIR}/crypto/include -o mbedtls-lib/build/mbedtls_sizeof_generator
./mbedtls-lib/build/mbedtls_sizeof_generator > kotlin-mbedtls/src/main/kotlin/org/opencoap/ssl/MbedtlsSizeOf.kt
2 changes: 2 additions & 0 deletions kotlin-mbedtls/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ plugins {
}

dependencies {
api(project(":mbedtls-lib"))

api(platform("org.jetbrains.kotlin:kotlin-bom"))
api("org.jetbrains.kotlin:kotlin-stdlib-jdk8")

Expand Down
12 changes: 12 additions & 0 deletions mbedtls-lib/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
plugins {
id("java-library")
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

sourceSets.main {
resources.srcDirs("bin")
}
File renamed without changes.
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
include(":mbedtls-lib")
include(":kotlin-mbedtls")
rootProject.name = "kotlin-mbedtls"

0 comments on commit 8a8fec9

Please sign in to comment.