Files
setup-graalvm/src/features/musl.ts

47 lines
1.7 KiB
TypeScript
Raw Normal View History

import * as c from '../constants.js'
2022-01-20 17:49:45 +01:00
import * as core from '@actions/core'
import * as tc from '@actions/tool-cache'
import { exec } from '../utils.js'
2025-02-10 09:16:33 +01:00
import { join } from 'path'
2022-03-01 11:45:43 +01:00
const MUSL_NAME = 'x86_64-linux-musl-native'
const MUSL_VERSION = '10.2.1'
2022-01-20 17:49:45 +01:00
export async function setUpNativeImageMusl(): Promise<void> {
2022-11-02 14:00:51 +01:00
if (!c.IS_LINUX) {
2022-01-20 17:49:45 +01:00
core.warning('musl is only supported on Linux')
return
}
2022-03-01 11:45:43 +01:00
let toolPath = tc.find(MUSL_NAME, MUSL_VERSION)
if (toolPath) {
core.info(`Found ${MUSL_NAME} ${MUSL_VERSION} in tool-cache @ ${toolPath}`)
2022-03-01 11:45:43 +01:00
} else {
core.startGroup(`Setting up musl for GraalVM Native Image...`)
2022-03-01 11:45:43 +01:00
const muslDownloadPath = await tc.downloadTool(
`https://github.com/graalvm/setup-graalvm/releases/download/x86_64-linux-musl-${MUSL_VERSION}/${MUSL_NAME}.tgz`
2022-03-01 11:45:43 +01:00
)
const muslExtractPath = await tc.extractTar(muslDownloadPath)
const muslPath = join(muslExtractPath, MUSL_NAME)
const zlibCommit = 'ec3df00224d4b396e2ac6586ab5d25f673caa4c2'
2025-02-10 09:16:33 +01:00
const zlibDownloadPath = await tc.downloadTool(`https://github.com/madler/zlib/archive/${zlibCommit}.tar.gz`)
2022-03-01 11:45:43 +01:00
const zlibExtractPath = await tc.extractTar(zlibDownloadPath)
const zlibPath = join(zlibExtractPath, `zlib-${zlibCommit}`)
2022-03-01 11:45:43 +01:00
const zlibBuildOptions = {
cwd: zlibPath,
env: {
...process.env,
CC: join(muslPath, 'bin', 'gcc')
2022-03-01 11:45:43 +01:00
}
2022-01-20 17:49:45 +01:00
}
2025-02-10 09:16:33 +01:00
await exec('./configure', [`--prefix=${muslPath}`, '--static'], zlibBuildOptions)
2022-03-01 11:45:43 +01:00
await exec('make', [], zlibBuildOptions)
2025-02-10 09:16:33 +01:00
await exec('make', ['install'], { cwd: zlibPath })
core.info(`Adding ${MUSL_NAME} ${MUSL_VERSION} to tool-cache ...`)
toolPath = await tc.cacheDir(muslPath, MUSL_NAME, MUSL_VERSION)
2022-03-01 11:45:43 +01:00
core.endGroup()
2022-01-20 17:49:45 +01:00
}
2022-03-01 11:45:43 +01:00
core.addPath(join(toolPath, 'bin'))
2022-01-20 17:49:45 +01:00
}