Skip to content

Commit

Permalink
Merge pull request #261 from ivpn/bugfix/fdroid-build-issue
Browse files Browse the repository at this point in the history
Compile liboqs library from source
  • Loading branch information
jurajhilje authored Aug 31, 2023
2 parents eb9cf45 + 3d342fe commit 71881ed
Show file tree
Hide file tree
Showing 14 changed files with 55 additions and 7 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ jobs:

- name: Checkout submodules
run: git submodule update --init --recursive

- name: Set up NDK
uses: nttld/setup-ndk@v1
with:
ndk-version: r25b

- name: Install liboqs dependencies
run: sudo apt-get update && sudo apt-get install -y astyle cmake gcc ninja-build libssl-dev python3-pytest python3-pytest-xdist unzip xsltproc doxygen graphviz python3-yaml valgrind

- name: Set up JDK 11
uses: actions/setup-java@v3
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ keystore.properties
core/.cxx/
/store/production/
/production/
liboqs-android/**/*.so
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@
[submodule "core/src/main/cpp/lz4"]
path = core/src/main/cpp/lz4
url = https://github.com/lz4/lz4.git
[submodule "liboqs-android/jni/liboqs"]
path = liboqs-android/jni/liboqs
url = https://github.com/ivpn/liboqs
40 changes: 38 additions & 2 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ android {
targetSdkVersion 31
versionCode 124
versionName "2.10.2"
ndkVersion "25.1.8937393"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments clearPackageData: 'true'
Expand Down Expand Up @@ -143,12 +144,47 @@ def File registerGenTask(variantName, variantDirName) {
return baseDir
}

def kemScript = "./../liboqs-android/jni/liboqs/scripts/build-android.sh"
def kemPlatform = "android-21"
def kemMechanisms = "KEM_kyber_1024;"

tasks.register("buildLiboqsARM64", Exec) {
commandLine kemScript, android.ndkDirectory, "-a", "arm64-v8a", "-p", kemPlatform, "-m", kemMechanisms
}

tasks.register("buildLiboqsARM", Exec) {
commandLine kemScript, android.ndkDirectory, "-a", "armeabi-v7a", "-p", kemPlatform, "-m", kemMechanisms
}

tasks.register("buildLiboqsX8664", Exec) {
commandLine kemScript, android.ndkDirectory, "-a", "x86_64", "-p", kemPlatform, "-m", kemMechanisms
}

tasks.register("buildLiboqsX86", Exec) {
commandLine kemScript, android.ndkDirectory, "-a", "x86", "-p", kemPlatform, "-m", kemMechanisms
}

android.libraryVariants.all { variant ->
def sourceDir = registerGenTask(variant.name, variant.baseName.replace("-", "/"))
def task = tasks.named("generateOpenVPN3Swig${variant.name}").get()
def generateOpenVPN3Swig = tasks.named("generateOpenVPN3Swig${variant.name}").get()
def buildLiboqsARM64 = tasks.named("buildLiboqsARM64").get()
def buildLiboqsARM = tasks.named("buildLiboqsARM").get()
def buildLiboqsX8664 = tasks.named("buildLiboqsX8664").get()
def buildLiboqsX86 = tasks.named("buildLiboqsX86").get()
variant.registerJavaGeneratingTask(generateOpenVPN3Swig, sourceDir)
variant.registerJavaGeneratingTask(buildLiboqsARM64, sourceDir)
variant.registerJavaGeneratingTask(buildLiboqsARM, sourceDir)
variant.registerJavaGeneratingTask(buildLiboqsX8664, sourceDir)
variant.registerJavaGeneratingTask(buildLiboqsX86, sourceDir)
}

variant.registerJavaGeneratingTask(task, sourceDir)
project.afterEvaluate {
preBuild.dependsOn(
tasks.named("buildLiboqsARM64").get(),
tasks.named("buildLiboqsARM").get(),
tasks.named("buildLiboqsX8664").get(),
tasks.named("buildLiboqsX86").get()
)
}

ext {
Expand Down
4 changes: 0 additions & 4 deletions core/tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
cmake_minimum_required(VERSION 3.4.1)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")

# Work around https://github.com/android-ndk/ndk/issues/602
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")

add_executable(libwg-quick.so wireguard-tools/src/wg-quick/android.c ndk-compat/compat.c)
target_compile_options(libwg-quick.so PUBLIC -O3 -std=gnu11 -Wall -include ${CMAKE_CURRENT_SOURCE_DIR}/ndk-compat/compat.h -DWG_PACKAGE_NAME=\"${ANDROID_PACKAGE_NAME}\")
target_link_libraries(libwg-quick.so -ldl)
Expand All @@ -26,7 +23,6 @@ add_custom_target(libwg-go.so WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/lib
ANDROID_PACKAGE_NAME=${ANDROID_PACKAGE_NAME}
GRADLE_USER_HOME=${GRADLE_USER_HOME}
CFLAGS=${CMAKE_C_FLAGS}\ -Wno-unused-command-line-argument
LDFLAGS=${CMAKE_SHARED_LINKER_FLAGS}\ -fuse-ld=gold
DESTDIR=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
BUILDDIR=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/../generated-src
)
Expand Down
1 change: 1 addition & 0 deletions fdroid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ android {
targetSdkVersion 30
versionCode 124
versionName "2.10.2"
ndkVersion "25.1.8937393"

manifestPlaceholders = [SENTRY_DSN: keystoreProperties['sentry.dsn']]
buildConfigField "String", "BILLING_PUBLIC_KEY", keystoreProperties['billing.public.key']
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
android.enableJetifier=true
android.useAndroidX=true
android.bundle.enableUncompressedNativeLibs = false
org.gradle.jvmargs=-Xmx1536m
org.gradle.jvmargs=-Xmx2048M

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
Expand Down
Binary file removed liboqs-android/jni/jniLibs/arm64-v8a/liboqs.so
Binary file not shown.
Binary file removed liboqs-android/jni/jniLibs/armeabi-v7a/liboqs.so
Binary file not shown.
Binary file removed liboqs-android/jni/jniLibs/x86/liboqs.so
Binary file not shown.
Binary file removed liboqs-android/jni/jniLibs/x86_64/liboqs.so
Binary file not shown.
1 change: 1 addition & 0 deletions liboqs-android/jni/liboqs
Submodule liboqs added at fbb67a
1 change: 1 addition & 0 deletions site/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ android {
targetSdkVersion 31
versionCode 124
versionName "2.10.2"
ndkVersion "25.1.8937393"

manifestPlaceholders = [SENTRY_DSN: keystoreProperties['sentry.dsn']]
buildConfigField "String", "BILLING_PUBLIC_KEY", keystoreProperties['billing.public.key']
Expand Down
1 change: 1 addition & 0 deletions store/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ android {
targetSdkVersion 31
versionCode 124
versionName "2.10.2"
ndkVersion "25.1.8937393"

manifestPlaceholders = [SENTRY_DSN: keystoreProperties['sentry.dsn']]
buildConfigField "String", "BILLING_PUBLIC_KEY", keystoreProperties['billing.public.key']
Expand Down

0 comments on commit 71881ed

Please sign in to comment.