Actually make headless work on arm aarch64

Following the two comments at
https://code.briarproject.org/briar/briar/-/issues/1854#note_44340

.jar files now get built with

    $ ./gradlew --configure-on-demand briar-headless:x86LinuxJar
    $ ./gradlew --configure-on-demand briar-headless:aarch64LinuxJar

Related to #1854
This commit is contained in:
Nico Alt
2021-03-03 12:00:00 +00:00
parent c5d2661c1d
commit b738bdd14e
3 changed files with 37 additions and 7 deletions

View File

@@ -96,15 +96,21 @@ public class UnixTorPluginFactory implements DuplexPluginFactory {
String architecture = null;
if (isLinux()) {
String arch = System.getProperty("os.arch");
LOG.info("System's os.arch is " + arch);
if (arch.equals("amd64")) {
architecture = "linux-x86_64";
}
else if (arch.equals("aarch64")) {
architecture = "linux-aarch64";
}
}
if (architecture == null) {
LOG.info("Tor is not supported on this architecture");
return null;
}
LOG.info("The selected architecture for Tor is " + architecture);
Backoff backoff = backoffFactory.createBackoff(MIN_POLLING_INTERVAL,
MAX_POLLING_INTERVAL, BACKOFF_BASE);
TorRendezvousCrypto torRendezvousCrypto = new TorRendezvousCryptoImpl();

View File

@@ -11,9 +11,10 @@ The REST API peer comes as a `jar` file
and needs a Java Runtime Environment (JRE) that supports at least Java 8.
It currently works only on GNU/Linux operating systems.
To build the `jar` file, you can do this:
To build the `jar` file, you need to specify the combination of architecture and platform:
$ ./gradlew --configure-on-demand briar-headless:jar
$ ./gradlew --configure-on-demand briar-headless:x86LinuxJar
$ ./gradlew --configure-on-demand briar-headless:aarch64LinuxJar
You can start the peer (and its API server) like this:

View File

@@ -44,18 +44,32 @@ dependencies {
kaptTest "com.google.dagger:dagger-compiler:$daggerVersion"
}
jar {
manifest {
void jarFactory(Jar jarTask, jarArchitecture) {
jarTask.doFirst {
println 'Building ' + jarArchitecture + ' version has started'
}
jarTask.manifest {
attributes(
'Main-Class': 'org.briarproject.briar.headless.MainKt'
)
}
from {
jarTask.setArchiveClassifier(jarArchitecture)
jarTask.from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
doLast() {
{
String[] architectures = ["linux-aarch64", "linux-x86_64"]
for (String arch : architectures) {
if (arch != jarArchitecture) {
exclude "obfs4proxy_" + arch + ".zip"
exclude "tor_" + arch + ".zip"
}
}
}
jarTask.with jar
jarTask.doLast {
// Rename the original jar
File jar = project.jar.archivePath
File jar = jarTask.archivePath
String srcPath = jar.toString().replaceFirst('\\.jar$', '.unsorted.jar')
File srcFile = new File(srcPath)
jar.renameTo(srcFile)
@@ -80,9 +94,18 @@ jar {
}
destStream.close()
srcJarFile.close()
println 'Building ' + jarArchitecture + ' version has finished'
}
}
task aarch64LinuxJar(type: Jar) {
jarFactory(it, 'linux-aarch64')
}
task x86LinuxJar(type: Jar) {
jarFactory(it, 'linux-x86_64')
}
// At the moment for non-Android projects we need to explicitly mark the code generated by kapt
// as 'generated source code' for correct highlighting and resolve in IDE.
idea {