-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce native-image-musl feature.
- Loading branch information
Showing
9 changed files
with
228 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import * as core from '@actions/core' | ||
import * as tc from '@actions/tool-cache' | ||
import {IS_LINUX} from './constants' | ||
import {exec} from '@actions/exec' | ||
import {homedir} from 'os' | ||
import {join} from 'path' | ||
import {mkdirP} from '@actions/io' | ||
|
||
export async function enableFeatures(features: string[]): Promise<void> { | ||
for (const feature of features) { | ||
await enableFeature(feature) | ||
} | ||
} | ||
|
||
async function enableFeature(feature: string): Promise<void> { | ||
switch (feature) { | ||
case 'native-image-musl': | ||
await enableNativeImageMusl() | ||
break | ||
default: | ||
core.warning(`Unknown feature requested: ${feature}`) | ||
break | ||
} | ||
} | ||
|
||
async function enableNativeImageMusl(): Promise<void> { | ||
if (!IS_LINUX) { | ||
core.warning('musl is only supported on Linux') | ||
return | ||
} | ||
core.startGroup(`Setting up musl for GraalVM Native Image...`) | ||
const basePath = join(homedir(), '.musl_feature') | ||
await mkdirP(basePath) | ||
|
||
const muslName = 'x86_64-linux-musl-native' | ||
const muslDownloadPath = await tc.downloadTool( | ||
`http://more.musl.cc/10/x86_64-linux-musl/${muslName}.tgz` | ||
) | ||
await tc.extractTar(muslDownloadPath, basePath) | ||
const muslPath = join(basePath, muslName) | ||
core.addPath(join(muslPath, 'bin')) | ||
|
||
const zlibVersion = '1.2.11' | ||
const zlibDownloadPath = await tc.downloadTool( | ||
`https://zlib.net/zlib-${zlibVersion}.tar.gz` | ||
) | ||
await tc.extractTar(zlibDownloadPath, basePath) | ||
const zlibPath = join(basePath, `zlib-${zlibVersion}`) | ||
const zlibBuildOptions = { | ||
cwd: zlibPath, | ||
env: { | ||
...process.env, | ||
CC: join(muslPath, 'bin', 'gcc') | ||
} | ||
} | ||
await exec( | ||
'./configure', | ||
[`--prefix=${muslPath}`, '--static'], | ||
zlibBuildOptions | ||
) | ||
await exec('make', [], zlibBuildOptions) | ||
await exec('make', ['install'], {cwd: zlibPath}) | ||
core.endGroup() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters