diff --git a/src/gu.ts b/src/gu.ts new file mode 100644 index 0000000..fd400d0 --- /dev/null +++ b/src/gu.ts @@ -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>([ + [ + 'linux', + new Map([ + ['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([ + ['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 { + 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)}"`) + } + } + } +} diff --git a/src/main.ts b/src/main.ts index 1af24c4..e6ffda7 100644 --- a/src/main.ts +++ b/src/main.ts @@ -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 { 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) }