Skip to content

Commit 7103484

Browse files
authored
Merge pull request #15 from Berstanio/fix-armv7-remotebuild
Run dex2oat with rosetta on m1 remote machine (armv7)
2 parents 56ca5ec + 2d5ac35 commit 7103484

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/main/java/org/moe/gradle/remote/Server.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ public URI getSdkDir() {
9999
return Require.nonNull(sdkDir);
100100
}
101101

102+
@Nullable
103+
private Boolean remoteAARCH64;
104+
105+
@NotNull
106+
public boolean isRemoteAARCH64() {
107+
return Require.nonNull(remoteAARCH64);
108+
}
109+
102110
@Nullable
103111
private Task moeRemoteServerSetupTask;
104112

@@ -202,13 +210,19 @@ public void connect() {
202210
throw new GradleException(e.getMessage(), e);
203211
}
204212

213+
fetchArchitecture();
205214
setupUserHome();
206215
setupBuildDir();
207216
prepareServerMOE();
208217
});
209218
});
210219
}
211220

221+
private void fetchArchitecture() {
222+
String arch = exec("get arch", "arch");
223+
remoteAARCH64 = arch.equals("arm64");
224+
}
225+
212226
private void prepareServerMOE() {
213227
final MoeSDK sdk = plugin.getSDK();
214228

src/main/java/org/moe/gradle/tasks/Dex2Oat.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,12 @@ protected void run() {
249249
"mkdir -p `dirname " + remoteDestArt + "` && " +
250250
"mkdir -p `dirname " + remoteDestOat + "`");
251251

252-
remoteServer.exec("dex2oat", dex2oatExec + " " +
252+
String optionalRosetta = "";
253+
if (remoteServer.isRemoteAARCH64() && !Arch.FAMILY_ARM64.equalsIgnoreCase(getArchFamily())) {
254+
optionalRosetta = "arch --x86_64 ";
255+
}
256+
257+
remoteServer.exec("dex2oat", optionalRosetta + dex2oatExec + " " +
253258
"--instruction-set=" + Arch.validateArchFamily(getArchFamily()) + " " +
254259
"--base=0x" + Long.toHexString(getBase()) + " " +
255260
"--compiler-backend=" + validateBackend(getCompilerBackend()) + " " +

0 commit comments

Comments
 (0)