Skip to content

Commit

Permalink
Add IBM Semeru (OpenJ9) to the index (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosedp authored Mar 15, 2024
1 parent ce39174 commit f182837
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/GenerateIndex.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ object GenerateIndex {
val adoptIndex0 = Temurin.fullIndex(GhToken.token)
val zuluIndex0 = Zulu.index()
val libericaIndex0 = Liberica.index()
val ibmsemeruIndex0 = IbmSemeru.fullIndex(GhToken.token)

val index = graalvmLegacyIndex0 +
graalvmIndex0 +
oracleIndex0 +
adoptIndex0 +
zuluIndex0 +
libericaIndex0 +
correttoIndex0
correttoIndex0 +
ibmsemeruIndex0

val json = index.json
os.write.over(dest, json)
Expand Down
69 changes: 69 additions & 0 deletions src/IbmSemeru.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
object IbmSemeru {

def fullIndex(ghToken: String): Index = {
val ibmsemeruJdk11Index0 = index(ghToken, "11")
val ibmsemeruJdk17Index0 = index(ghToken, "17")
val ibmsemeruJdk21Index0 = index(ghToken, "21")
ibmsemeruJdk11Index0 + ibmsemeruJdk17Index0 + ibmsemeruJdk21Index0
}

def index(
ghToken: String,
javaVersion: String
): Index = {

val ghOrg = "ibmruntimes"
val ghProj = s"semeru$javaVersion-binaries"
val releases0 = Release.releaseIds(ghOrg, ghProj, ghToken)
.filter(!_.prerelease)

def osOpt(input: String): Option[(String, String)] =
input match
case input if input.startsWith("linux") => Some(("linux", input.stripPrefix("linux_")))
case input if input.startsWith("mac") => Some(("darwin", input.stripPrefix("mac_")))
case input if input.startsWith("windows") =>
Some(("windows", input.stripPrefix("windows_")))
case input if input.startsWith("aix") => Some(("aix", input.stripPrefix("aix_")))
case _ => None

def archOpt(input: String): Option[(String, String)] =
input match
case input if input.startsWith("x64") => Some(("amd64", input.stripPrefix("x64_")))
case input if input.startsWith("aarch64") => Some(("arm64", input.stripPrefix("aarch64_")))
case input if input.startsWith("ppc64le") =>
Some(("ppc64le", input.stripPrefix("ppc64le_")))
case input if input.startsWith("ppc64") => Some(("ppc64", input.stripPrefix("ppc64_")))
case input if input.startsWith("s390x") => Some(("s390x", input.stripPrefix("s390x_")))
case _ => None

def archiveTypeOpt(input: String): Option[(String, String)] =
input match
case input if input.endsWith(".zip") => Some(("zip", input.stripSuffix(".zip")))
case input if input.endsWith(".tar.gz") => Some(("tgz", input.stripSuffix(".tar.gz")))
case _ => None

val indices = releases0
.filter(release => release.tagName.startsWith(s"jdk-$javaVersion"))
.flatMap { release =>
val version = release.tagName.stripPrefix("jdk-")
val assetNamePrefix = s"ibm-semeru-open-jdk_"
val assets = Asset.releaseAssets(ghOrg, ghProj, ghToken, release.tagName)
assets
.filter(asset => asset.name.startsWith(assetNamePrefix))
.flatMap { asset =>
val name0 = asset.name.stripPrefix(assetNamePrefix)
val nameVersion = s"jdk@ibm-semeru-openj9-java$javaVersion"
val opt =
for {
(arch, rem) <- archOpt(name0)
(os, rem0) <- osOpt(rem)
(archiveType, ver) <- archiveTypeOpt(rem0)
} yield Index(os, arch, nameVersion, version, archiveType + "+" + asset.downloadUrl)
opt.toSeq
}
}

indices.foldLeft(Index.empty)(_ + _)
}

}

0 comments on commit f182837

Please sign in to comment.