Skip to content

Commit

Permalink
Update dependencies and build RClone in a go module.
Browse files Browse the repository at this point in the history
This commit updates build tools, android gradle plugin and RClone to
their latest version.

Also, the RClone build recipe now creates a go module instead of git.
his will make sure dependencies are pinned to the version expected by
RClone.
  • Loading branch information
gilbsgilbs committed Aug 12, 2020
1 parent ef1a368 commit ff4c5ce
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 19 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ jobs:
run: |
BUILD_TOOLS_VERSION="$(grep -E "^io\.github\.x0b\.rcx\.buildToolsVersion=" gradle.properties | cut -d'=' -f2)"
NDK_VERSION="$(grep -E "^io\.github\.x0b\.rcx\.ndkVersion=" gradle.properties | cut -d'=' -f2)"
yes | sudo "${ANDROID_HOME}/tools/bin/sdkmanager" "build-tools;${BUILD_TOOLS_VERSION}" "ndk;${NDK_VERSION}"
yes | sudo "${ANDROID_HOME}/tools/bin/sdkmanager" --licenses
sudo "${ANDROID_HOME}/tools/bin/sdkmanager" "build-tools;${BUILD_TOOLS_VERSION}" "ndk;${NDK_VERSION}"
- name: Build app
run: ./gradlew assembleOssDebug
- name: Upload APK
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
*.apk
*.ap_

# Built libraries
*.so

# Files for the ART/Dalvik VM
*.dex

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.LayoutInflater;
Expand All @@ -18,7 +16,6 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.browser.customtabs.CustomTabsIntent;
import androidx.fragment.app.Fragment;
import androidx.preference.PreferenceManager;
import ca.pkay.rcloneexplorer.MainActivity;
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:4.0.0'
classpath 'com.android.tools.build:gradle:4.0.1'

for (String taskName : getGradle().getStartParameter().getTaskNames()) {
if (taskName.endsWith('RcxDebug') || taskName.endsWith('RcxRelease')) {
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ android.useAndroidX=true
# android.enableR8=true
org.gradle.jvmargs=-Xmx1536m

io.github.x0b.rcx.rCloneVersion=1.51.0
io.github.x0b.rcx.buildToolsVersion=30.0.1
io.github.x0b.rcx.rCloneVersion=1.52.3
io.github.x0b.rcx.buildToolsVersion=29.0.3
io.github.x0b.rcx.ndkVersion=21.3.6528147

# When configured, Gradle will run in incubating parallel mode.
Expand Down
2 changes: 1 addition & 1 deletion rclone/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/gopath
/cache
29 changes: 18 additions & 11 deletions rclone/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import java.nio.file.Paths
ext {
NDK_VERSION = project.properties['io.github.x0b.rcx.ndkVersion']
RCLONE_VERSION = project.properties['io.github.x0b.rcx.rCloneVersion']
RCLONE_REPOSITORY = 'github.com/rclone/rclone'
GO_PATH = Paths.get(projectDir.absolutePath, 'gopath').toAbsolutePath().toString()
RCLONE_MODULE = 'github.com/rclone/rclone'
CACHE_PATH = Paths.get(projectDir.absolutePath, 'cache').toAbsolutePath().toString()
GOPATH = Paths.get(CACHE_PATH, "gopath").toString()
}

def findSdkDir() {
Expand Down Expand Up @@ -83,29 +84,35 @@ def buildRclone(compiler, arch, abi, env = [:]) {
return {
doLast {
exec {
environment 'GOPATH', GO_PATH
environment 'GOPATH', GOPATH
def crossCompiler = getCrossCompiler(compiler)
environment 'CC', crossCompiler
environment 'CC_FOR_TARGET', crossCompiler
environment 'GOOS', 'android'
environment 'GOARCH', arch
environment 'CGO_ENABLED', '1'
env.each {entry -> environment "$entry.key", "$entry.value"}
commandLine 'go', 'build', '-tags', 'linux', '-o', getLibrclone(abi), RCLONE_REPOSITORY
workingDir CACHE_PATH
commandLine 'go', 'build', '-tags', 'linux', '-o', getLibrclone(abi), RCLONE_MODULE
}
}
}
}

task fetchRclone(type: Exec) {
mkdir GO_PATH
environment 'GOPATH', GO_PATH
commandLine 'go', 'get', '-d', RCLONE_REPOSITORY
task createRcloneModule(type: Exec) {
// We create a fake go module as it's the only way to checkout
// a specific tag.
onlyIf { !Paths.get(CACHE_PATH, 'go.mod').toFile().exists() }
mkdir CACHE_PATH
workingDir CACHE_PATH
environment 'GOPATH', GOPATH
commandLine 'go', 'mod', 'init', 'rclone'
}

task checkoutRclone(type: Exec, dependsOn: fetchRclone) {
workingDir Paths.get(GO_PATH, 'src', *RCLONE_REPOSITORY.split('/'))
commandLine 'git', 'checkout', 'v' + RCLONE_VERSION
task checkoutRclone(type: Exec, dependsOn: createRcloneModule) {
workingDir CACHE_PATH
environment 'GOPATH', GOPATH
commandLine 'go', 'get', '-v', '-d', "${RCLONE_MODULE}@v${RCLONE_VERSION}"
}

task cleanNative {
Expand Down

0 comments on commit ff4c5ce

Please sign in to comment.