Set up GraalVM components with gu.

This commit is contained in:
Fabio Niephaus 2022-01-03 08:57:03 +01:00
parent c26d35376d
commit b7dfeb8214
No known key found for this signature in database
GPG Key ID: F21CF5275F31DFD6
2 changed files with 48 additions and 0 deletions

38
src/gu.ts Normal file
View File

@ -0,0 +1,38 @@
import {GRAALVM_PLATFORM} from './constants'
import {exec} from '@actions/exec'
import {join} from 'path'
const COMPONENT_TO_POST_INSTALL_HOOK = new Map<string, Map<string, string>>([
[
'linux',
new Map<string, string>([
['ruby', 'languages/ruby/lib/truffle/post_install_hook.sh']
// ['R', 'languages/R/bin/configure_fastr'] (GR-36105: cannot be run non-interactively)
])
],
[
'darwin',
new Map<string, string>([
['ruby', 'languages/ruby/lib/truffle/post_install_hook.sh']
// ['R', 'languages/R/bin/configure_fastr'] (GR-36105: cannot be run non-interactively)
])
]
// No post install hooks for Windows (yet)
])
export async function setUpGUComponents(
graalVMHome: string,
components: string[]
): Promise<void> {
await exec('gu', ['install', '--no-progress'].concat(components))
const platformHooks = COMPONENT_TO_POST_INSTALL_HOOK.get(GRAALVM_PLATFORM)
if (platformHooks) {
for (const component of components) {
const postInstallHook = platformHooks.get(component)
if (postInstallHook) {
await exec(`"${join(graalVMHome, postInstallHook)}"`)
}
}
}
}

View File

@ -4,6 +4,7 @@ import * as graalvm from './graalvm'
import {join} from 'path'
import {mkdirP} from '@actions/io'
import {setUpDependencies} from './dependencies'
import {setUpGUComponents} from './gu'
import {setUpGraalVMTrunk} from './graalvm-trunk'
import {setUpWindowsEnvironment} from './msvc'
@ -50,6 +51,15 @@ async function run(): Promise<void> {
if (setJavaHome) {
core.exportVariable('JAVA_HOME', graalVMHome)
}
// Set up GraalVM components (if any)
if (components.length > 0) {
if (graalvmVersion === c.VERSION_TRUNK) {
// components built from source, nothing to do
} else {
await setUpGUComponents(graalVMHome, components)
}
}
} catch (error) {
if (error instanceof Error) core.setFailed(error.message)
}