diff options
-rw-r--r-- | main/build.gradle.kts | 80 | ||||
-rw-r--r-- | main/src/ui/java/de/blinkt/openvpn/core/OpenVPNThreadv3.java (renamed from main/src/ovpn3/java/de/blinkt/openvpn/core/OpenVPNThreadv3.java) | 19 |
2 files changed, 54 insertions, 45 deletions
diff --git a/main/build.gradle.kts b/main/build.gradle.kts index 39a7498c..83c6b9dd 100644 --- a/main/build.gradle.kts +++ b/main/build.gradle.kts @@ -1,3 +1,5 @@ +import com.android.build.gradle.api.ApplicationVariant + /* * Copyright (c) 2012-2016 Arne Schwabe * Distributed under the GNU GPL v2 with additional terms. For full terms see the file doc/LICENSE.txt @@ -36,20 +38,19 @@ android { sourceSets { getByName("main") { assets.srcDirs("src/main/assets", "build/ovpnassets") + } create("ui") { - java.srcDirs("src/ovpn3/java/", getOpenvpn3SwigFiles()) } + create("skeleton") { } getByName("debug") { - } getByName("release") { - } } @@ -111,8 +112,45 @@ android { isUniversalApk = true } } + + +} + +var swigcmd = "swig" +// Workaround for Mac OS X since it otherwise does not find swig and I cannot get +// the Exec task to respect the PATH environment :( +if (File("/usr/local/bin/swig").exists()) + swigcmd = "/usr/local/bin/swig" + + +fun registerGenTask(variantName: String, variantDirName: String): File { + val baseDir = File(buildDir, "generated/source/ovpn3swig/${variantDirName}") + val genDir = File(baseDir, "net/openvpn/ovpn3") + + tasks.register<Exec>("generateOpenVPN3Swig${variantName}") + { + + doFirst { + mkdir(genDir) + } + commandLine(listOf(swigcmd, "-outdir", genDir, "-outcurrentdir", "-c++", "-java", "-package", "net.openvpn.ovpn3", + "-Isrc/main/cpp/openvpn3/client", "-Isrc/main/cpp/openvpn3/", + "-o", "${genDir}/ovpncli_wrap.cxx", "-oh", "${genDir}/ovpncli_wrap.h", + "src/main/cpp/openvpn3/javacli/ovpncli.i")) + } + return baseDir } +android.applicationVariants.all(object : Action<ApplicationVariant> { + override fun execute(variant: ApplicationVariant) { + val sourceDir = registerGenTask(variant.name, variant.baseName.replace("-", "/")) + val task = tasks.named("generateOpenVPN3Swig${variant.name}").get() + + variant.registerJavaGeneratingTask(task, sourceDir) + } +}) + + dependencies { val preferenceVersion = "1.1.0" val coreVersion = "1.1.0" @@ -140,40 +178,6 @@ dependencies { testImplementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.61") testImplementation("junit:junit:4.12") - testImplementation("org.mockito:mockito-core:3.2.0") + testImplementation("org.mockito:mockito-core:3.2.4") testImplementation("org.robolectric:robolectric:4.3.1") } - - -/* swig magic for building openvpn3 */ -fun getOpenvpn3SwigFiles(): File { - return File(buildDir, "generated/source/ovpn3swig/ovpn3") -} - -tasks.register<Exec>("generateOpenVPN3Swig") -{ - var swigcmd = "swig" - // Workaround for Mac OS X since it otherwise does not find swig and I cannot get - // the Exec task to respect the PATH environment :( - if (File("/usr/local/bin/swig").exists()) - swigcmd = "/usr/local/bin/swig" - - doFirst { - mkdir(getOpenvpn3SwigFiles()) - } - commandLine(listOf(swigcmd, "-outdir", getOpenvpn3SwigFiles(), "-outcurrentdir", "-c++", "-java", "-package", "net.openvpn.ovpn3", - "-Isrc/main/cpp/openvpn3/client", "-Isrc/main/cpp/openvpn3/", - "-o", "${getOpenvpn3SwigFiles()}/ovpncli_wrap.cxx", "-oh", "${getOpenvpn3SwigFiles()}/ovpncli_wrap.h", - "src/main/cpp/openvpn3/javacli/ovpncli.i")) -} - -/* Hack-o-rama but it works good enough and documentation is surprisingly sparse */ - -val swigTask = tasks.named("generateOpenVPN3Swig") -val preBuildTask = tasks.getByName("preBuild") -val assembleTask = tasks.getByName("assemble") - -assembleTask.dependsOn(swigTask) -preBuildTask.dependsOn(swigTask) - - diff --git a/main/src/ovpn3/java/de/blinkt/openvpn/core/OpenVPNThreadv3.java b/main/src/ui/java/de/blinkt/openvpn/core/OpenVPNThreadv3.java index 4c96e4d6..2ddd4ce2 100644 --- a/main/src/ovpn3/java/de/blinkt/openvpn/core/OpenVPNThreadv3.java +++ b/main/src/ui/java/de/blinkt/openvpn/core/OpenVPNThreadv3.java @@ -3,18 +3,23 @@ package de.blinkt.openvpn.core; import android.annotation.SuppressLint; import android.content.Context; import android.provider.Settings; -import android.util.Base64; -import de.blinkt.openvpn.R; -import de.blinkt.openvpn.VpnProfile; -import net.openvpn.ovpn3.*; +import net.openvpn.ovpn3.ClientAPI_Config; +import net.openvpn.ovpn3.ClientAPI_EvalConfig; +import net.openvpn.ovpn3.ClientAPI_Event; +import net.openvpn.ovpn3.ClientAPI_ExternalPKICertRequest; +import net.openvpn.ovpn3.ClientAPI_ExternalPKISignRequest; +import net.openvpn.ovpn3.ClientAPI_LogInfo; import net.openvpn.ovpn3.ClientAPI_OpenVPNClient; -import net.openvpn.ovpn3.ClientAPI_DynamicChallenge; +import net.openvpn.ovpn3.ClientAPI_ProvideCreds; +import net.openvpn.ovpn3.ClientAPI_Status; +import net.openvpn.ovpn3.ClientAPI_TransportStats; -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; import java.util.Locale; +import de.blinkt.openvpn.R; +import de.blinkt.openvpn.VpnProfile; + import static de.blinkt.openvpn.VpnProfile.AUTH_RETRY_NOINTERACT; public class OpenVPNThreadv3 extends ClientAPI_OpenVPNClient implements Runnable, OpenVPNManagement { |