2022-01-03 08:57:03 +01:00
|
|
|
import {GRAALVM_PLATFORM} from './constants'
|
|
|
|
import {exec} from '@actions/exec'
|
|
|
|
import {join} from 'path'
|
|
|
|
|
2022-03-03 17:24:24 +01:00
|
|
|
const BASE_FLAGS = ['--non-interactive', 'install', '--no-progress']
|
2022-01-03 08:57:03 +01:00
|
|
|
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(
|
2022-03-03 17:24:24 +01:00
|
|
|
gdsToken: string,
|
2022-01-03 08:57:03 +01:00
|
|
|
graalVMHome: string,
|
|
|
|
components: string[]
|
|
|
|
): Promise<void> {
|
2022-03-03 17:24:24 +01:00
|
|
|
const optionalFlags = []
|
|
|
|
if (gdsToken.length > 0) {
|
|
|
|
optionalFlags.push('--token', gdsToken)
|
|
|
|
}
|
|
|
|
|
|
|
|
await exec('gu', BASE_FLAGS.concat(optionalFlags, components))
|
2022-01-03 08:57:03 +01:00
|
|
|
|
|
|
|
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)}"`)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|