Skip to content

Commit 441a0d8

Browse files
authored
Merge pull request #481 from sourcegraph/apple-m1
2 parents 9a98c50 + 6569b97 commit 441a0d8

File tree

5 files changed

+43
-17
lines changed

5 files changed

+43
-17
lines changed

bin/coursier

83.5 KB
Binary file not shown.

build.sbt

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import scala.util.control.NoStackTrace
88

99
lazy val V =
1010
new {
11-
val protobuf = "3.15.6"
11+
val protobuf = "3.21.4"
1212
val coursier = "2.0.8"
1313
val bloop = "1.4.7"
1414
val bsp = "2.0.0-M13"
@@ -37,6 +37,7 @@ inThisBuild(
3737
organization := "com.sourcegraph",
3838
homepage := Some(url("https://github.com/sourcegraph/scip-java")),
3939
dynverSeparator := "-",
40+
PB.protocVersion := V.protobuf,
4041
licenses :=
4142
List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")),
4243
developers :=
@@ -239,14 +240,7 @@ lazy val cli = project
239240
// Pre-download Java 8, 11 and 17.
240241
run("coursier", "java-home", "--jvm", "8")
241242
run("coursier", "java-home", "--jvm", "11")
242-
run(
243-
"coursier",
244-
"java-home",
245-
"--jvm",
246-
"temurin:17",
247-
"--jvm-index",
248-
"https://github.com/coursier/jvm-index/blob/master/index.json"
249-
)
243+
run("coursier", "java-home", "--jvm", "17")
250244

251245
// Install `scip-java` binary.
252246
add(script, "/usr/local/bin/scip-java")
@@ -332,9 +326,7 @@ lazy val minimized17 = project
332326
.in(file("tests/minimized/.j17"))
333327
.settings(
334328
minimizedSettings,
335-
javaToolchainJvmIndex :=
336-
Some("https://github.com/coursier/jvm-index/blob/master/index.json"),
337-
javaToolchainVersion := "temurin:17",
329+
javaToolchainVersion := "17",
338330
javacOptions ++= javacModuleOptions
339331
)
340332
.dependsOn(agent, plugin)

project/JavaToolchainPlugin.scala

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ object JavaToolchainPlugin extends AutoPlugin {
6767
// The tools.jar file includes the bytecode for the Java compiler in the com.sun.source package.
6868
// The Java compiler is available by default in Java 9+, so we only need to add tools.jar to the
6969
// bootclasspath for Java 8.
70-
if (home.toString.contains("1.8") && toolsJar.isFile) {
70+
if (version == "8" && toolsJar.isFile) {
7171
List(s"-Xbootclasspath/p:$toolsJar")
7272
} else {
7373
List()
@@ -92,10 +92,31 @@ object JavaToolchainPlugin extends AutoPlugin {
9292
.toList
9393
.flatMap(index => "--jvm-index" :: index :: Nil)
9494
val arguments =
95-
List("java", "-jar", coursier.toString, "java-home", "--jvm", v) ++
96-
index
95+
List(
96+
"java",
97+
"-jar",
98+
coursier.toString,
99+
"java-home",
100+
"--jvm",
101+
v,
102+
"--architecture",
103+
jvmArchitecture(v)
104+
) ++ index
97105
new File(Process(arguments).!!.trim)
98106
}
99107
)
100108
}
109+
110+
private def jvmArchitecture(jvmVersion: String): String =
111+
if (scala.util.Properties.isMac && sys.props("os.arch") == "aarch64")
112+
"amd64"
113+
else
114+
defaultCoursierJVMArchitecture
115+
def defaultCoursierJVMArchitecture: String =
116+
sys.props("os.arch") match {
117+
case "x86_64" =>
118+
"amd64"
119+
case x =>
120+
x
121+
}
101122
}

scip-java/src/main/resources/scip-java/coursier

100644100755
83.5 KB
Binary file not shown.

scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/ScipBuildTool.scala

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,8 @@ class ScipBuildTool(index: IndexCommand) extends BuildTool("SCIP", index) {
503503
"java-home",
504504
"--jvm",
505505
config.jvm,
506-
"--jvm-index",
507-
"https://github.com/coursier/jvm-index/blob/master/index.json"
506+
"--architecture",
507+
jvmArchitecture
508508
)
509509
.call()
510510
.out
@@ -532,6 +532,19 @@ class ScipBuildTool(index: IndexCommand) extends BuildTool("SCIP", index) {
532532
Failure(SubprocessException(result))
533533
}
534534

535+
private def jvmArchitecture: String =
536+
if (scala.util.Properties.isMac && sys.props("os.arch") == "aarch64")
537+
"amd64"
538+
else
539+
defaultCoursierJVMArchitecture
540+
def defaultCoursierJVMArchitecture: String =
541+
sys.props("os.arch") match {
542+
case "x86_64" =>
543+
"amd64"
544+
case x =>
545+
x
546+
}
547+
535548
private def clean(): Unit = {
536549
Files.walkFileTree(targetroot, new DeleteVisitor)
537550
}

0 commit comments

Comments
 (0)