Skip to content

Commit

Permalink
Merges #8 into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
GrazianoCapelli committed Nov 3, 2023
2 parents 7031000 + 8ab0e89 commit 58c700a
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
33 changes: 33 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,34 @@ android {
lint {
abortOnError false
}


// https://codeberg.org/Bazsalanszky/Eternity/commit/05123c70682e5988ad5f0ff111f97b66a87d8806
// Patch that solves the problem with EventBus and Reproducible Builds

task rearrangeClass(type: Exec) {
commandLine 'python', '../app/scripts/fixEventBus.py'
}

applicationVariants.all { variant ->
if (variant.name == 'release') {
task("compileSingleFile${variant.name.capitalize()}", type: JavaCompile, dependsOn: rearrangeClass) {
def filePath = project.rootDir.absolutePath + '/app/build/generated/ap_generated_sources/release/out/eu/basicairdata/graziano/gpslogger/'
source = files(filePath)
includes = ["**/EventBusIndex.java"]
classpath = variant.getCompileClasspath() + files(project.rootDir.absolutePath + '/app/build/intermediates/javac/release/classes')
destinationDir = file("$buildDir/intermediates/javac/release/classes")
}

tasks.withType(JavaCompile).all { task ->
if (task.name == 'compileReleaseJavaWithJavac') {
task.finalizedBy "compileSingleFile${variant.name.capitalize()}"
}
}
}
}

// end patch
}

dependencies {
Expand All @@ -85,4 +113,9 @@ dependencies {

implementation "org.greenrobot:eventbus:3.3.1"
annotationProcessor "org.greenrobot:eventbus-annotation-processor:3.3.1"
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
32 changes: 32 additions & 0 deletions app/scripts/fixEventBus.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import re
import sys


def rearrange(filename):
with open(filename, 'r') as file:
content = file.read()

# Regex to find the blocks of code to rearrange
pattern = re.compile(r'(putIndex\(new SimpleSubscriberInfo\(.*?\)\);)', re.DOTALL)
blocks = pattern.findall(content)

# Sort blocks based on the class names mentioned in SimpleSubscriberInfo instances
sorted_blocks = sorted(blocks, key=lambda x: re.search(r'SimpleSubscriberInfo\((.*?),', x).group(1))

# Replace the original blocks with the sorted blocks
sorted_content = pattern.sub(lambda match: sorted_blocks.pop(0), content)

with open(filename, 'w') as file:
file.write(sorted_content)


# Project root relative to the script
project_root = __file__[:-len('/app/scripts/fixEventBus.py')]

path = './build/generated/ap_generated_sources/release/out/eu/basicairdata/graziano/gpslogger/EventBusIndex.java'

# Print the path to the file to stderr
print(path, file=sys.stderr)

# Call the function with the path to EventBusIndex.java
rearrange(path)

0 comments on commit 58c700a

Please sign in to comment.