Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ runs:
shell: bash
- name: Configure
run: |-
../repo/configure --enable-protobuf --with-android-sdk="$(pwd)/../sdk" ${{ inputs.configure_extra }}
../repo/configure --enable-protobuf --with-android-sdk="$(pwd)/../sdk" --with-r8="$(pwd)/../r8.jar" ${{ inputs.configure_extra }}
working-directory: build
shell: bash
- name: Build
Expand Down
22 changes: 19 additions & 3 deletions .github/actions/test-build-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ runs:
path: sdk.tar.zstd
- name: Check/Install (SDK)
run: |-
if [ -e sdk/build-tools/29.0.2/dx ] ; then echo "Found SDK." ; exit 0 ; fi
if [ -e sdk/build-tools/29.0.2/aapt2 ] ; then echo "Found SDK." ; exit 0 ; fi

# Check whether cache file exists, then check dx again.
# Check whether cache file exists, then check aapt2 again.
if [ -f "sdk.tar.zstd" ] ; then
zstd --decompress --stdout sdk.tar.zstd | tar xf -
if [ -e sdk/build-tools/29.0.2/dx ] ; then echo "Unpacked SDK." ; exit 0 ; fi
if [ -e sdk/build-tools/29.0.2/aapt2 ] ; then echo "Unpacked SDK." ; exit 0 ; fi
fi

# Download.
Expand All @@ -42,3 +42,19 @@ runs:
rm -rf sdk/emulator 2>/dev/null
tar cf - sdk | zstd -T0 -9 > sdk.tar.zstd
shell: bash
# d8 is pinned to an R8 release instead of taken from the SDK: the build-tools
# d8 tracks the SDK release train rather than the Android Gradle Plugin, and
# lags it by years. Keep this version aligned with the AGP release Redex is
# expected to consume the output of.
- name: Cache R8
uses: actions/cache@v5
with:
key: v1-r8-8.8.34
path: r8.jar
- name: Check/Install (R8)
run: |-
if [ -f r8.jar ] ; then echo "Found R8." ; exit 0 ; fi

echo "R8 missing, downloading..."
wget -O r8.jar https://maven.google.com/com/android/tools/r8/8.8.34/r8-8.8.34.jar
shell: bash
29 changes: 19 additions & 10 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -123,21 +123,30 @@ AC_ARG_WITH([android-sdk],
[AC_PATH_PROG([PROTOC], [protoc], [no])])
]
)
# Look for dx & android.jar.
# The R8 jar is pinned rather than taken from the SDK: the d8 bundled with the
# Android build-tools tracks the SDK release train, not the Android Gradle
# Plugin, and its dex output is years behind the d8 that ships in AGP.
AC_ARG_WITH([r8],
[AS_HELP_STRING([--with-r8=/path/to/r8.jar],
[Location of the R8 jar, which provides d8, for testing.])],
[R8_JAR="$withval"],
[]
)
# Look for java, the R8 jar & android.jar.
AS_IF([test "x$NO_ANDROID_HOME" = "xno"],
[],
[
# Do not assume a totally new SDK. Try platform 29.
AC_PATH_PROG(
DX,
dx,
no,
"$ANDROID_HOME/build-tools/29.0.2:$PATH"
)
AS_IF([test "x$DX" = "xno"],
[AC_MSG_ERROR([--with-android-sdk option was specified but does not seem to point at a valid Android SDK installation])]
AC_PATH_PROG([JAVA], [java], [no])
AS_IF([test "x$JAVA" = "xno"],
[AC_MSG_ERROR([java is required to run d8])]
[]
)
AC_CHECK_FILE(
"$R8_JAR",
[AC_SUBST(R8_JAR,"$R8_JAR")],
[AC_MSG_ERROR([--with-r8 must point at an R8 jar providing com.android.tools.r8.D8])]
)
# Do not assume a totally new SDK. Try platform 29.
AC_CHECK_FILE(
"$ANDROID_HOME/platforms/android-29/android.jar",
[
Expand Down
17 changes: 13 additions & 4 deletions test/integ/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
include $(top_srcdir)/Makefile.inc
include $(top_srcdir)/test/Makefile.inc

DX = @DX@
JAVA = @JAVA@
R8_JAR = @R8_JAR@

ANDROID_SDK = @ANDROID_SDK@
ANDROID_PLATFORM_VERSION = @ANDROID_PLATFORM_VERSION@
ANDROID_JAR = $(ANDROID_SDK)/platforms/$(ANDROID_PLATFORM_VERSION)/android.jar

AM_CXXFLAGS = --std=gnu++20
AM_CPPFLAGS = $(COMMON_INCLUDES) $(COMMON_TEST_INCLUDES)
Expand Down Expand Up @@ -215,8 +217,10 @@ EXTRA_uses_app_module_annotation_test_DEPENDENCIES = uses_app_module_annotation-
verifier_artifacts_test_SOURCES = VerifierTest.cpp
EXTRA_verifier_artifacts_test_DEPENDENCIES = verifier_artifacts_test-class.dex

# Note: Should switch to d8, instead.
javac_source_target = -source 8 -target 8
javac_source_target = -source 11 -target 11

# Matches the platform the tests are compiled and run against.
d8_min_api = 29

define create_jar
mkdir -p $@.tmp
Expand All @@ -226,8 +230,13 @@ endef

SUFFIXES = .dex

# d8 only writes into a directory or a zip, always naming the result
# classes.dex, so the single-dex output has to be moved into place.
.jar.dex:
$(DX) --dex --output=$@ $^
mkdir -p $@.tmp
$(JAVA) -cp $(R8_JAR) com.android.tools.r8.D8 --min-api $(d8_min_api) \
--lib $(ANDROID_JAR) --output $@.tmp $^
mv $@.tmp/classes.dex $@

app_module_usage_test-class.jar: AppModuleUsageClass.java
$(create_jar)
Expand Down
Loading