Support 32-bit Julia binaries

This commit is contained in:
Sascha Mann
2019-08-21 15:34:52 +02:00
parent 6f01df9c38
commit a7c1edc063
3 changed files with 42 additions and 30 deletions

View File

@@ -5,6 +5,10 @@ inputs:
version: version:
description: 'The Julia version to download (if necessary) and use. Example: 1.0.4' description: 'The Julia version to download (if necessary) and use. Example: 1.0.4'
default: '1.0.4' default: '1.0.4'
arch:
description: 'Architecture of the Julia binaries. Defaults to x64.'
required: false
default: 'x64'
runs: runs:
using: 'node12' using: 'node12'
main: 'lib/setup-julia.js' main: 'lib/setup-julia.js'

View File

@@ -26,39 +26,42 @@ core.debug(`platform: ${osPlat}`);
function getMajorMinorVersion(version) { function getMajorMinorVersion(version) {
return version.split('.').slice(0, 2).join('.'); return version.split('.').slice(0, 2).join('.');
} }
function getDownloadURL(version) { function getDownloadURL(version, arch) {
const baseURL = 'https://julialang-s3.julialang.org/bin'; const baseURL = 'https://julialang-s3.julialang.org/bin';
let platform, arch; let platform;
const versionDir = getMajorMinorVersion(version); const versionDir = getMajorMinorVersion(version);
if (osPlat === 'win32') { // Windows if (osPlat === 'win32') { // Windows
platform = 'winnt'; platform = 'winnt';
arch = 'x64';
} }
else if (osPlat === 'darwin') { // macOS else if (osPlat === 'darwin') { // macOS
if (arch == 'x86') {
throw '32-bit Julia is not available on macOS';
}
platform = 'mac'; platform = 'mac';
arch = 'x64';
} }
else if (osPlat === 'linux') { // Linux else if (osPlat === 'linux') { // Linux
platform = 'linux'; platform = 'linux';
arch = 'x64';
} }
else { else {
throw `Platform ${osPlat} is not supported`; throw `Platform ${osPlat} is not supported`;
} }
return `${baseURL}/${platform}/${arch}/${versionDir}/${getFileName(version)}`; return `${baseURL}/${platform}/${arch}/${versionDir}/${getFileName(version, arch)}`;
} }
function getFileName(version) { function getFileName(version, arch) {
let versionExt, ext; let versionExt, ext;
if (osPlat === 'win32') { // Windows if (osPlat === 'win32') { // Windows
versionExt = '-win64'; versionExt = arch == 'x64' ? '-win64' : '-win32';
ext = 'exe'; ext = 'exe';
} }
else if (osPlat === 'darwin') { // macOS else if (osPlat === 'darwin') { // macOS
if (arch == 'x86') {
throw '32-bit Julia is not available on macOS';
}
versionExt = '-mac64'; versionExt = '-mac64';
ext = 'dmg'; ext = 'dmg';
} }
else if (osPlat === 'linux') { // Linux else if (osPlat === 'linux') { // Linux
versionExt = '-linux-x86_64'; versionExt = arch == 'x64' ? '-linux-x86_64' : '-linux-i686';
ext = 'tar.gz'; ext = 'tar.gz';
} }
else { else {
@@ -66,10 +69,10 @@ function getFileName(version) {
} }
return `julia-${version}${versionExt}.${ext}`; return `julia-${version}${versionExt}.${ext}`;
} }
function installJulia(version) { function installJulia(version, arch) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
// Download Julia // Download Julia
const downloadURL = getDownloadURL(version); const downloadURL = getDownloadURL(version, arch);
core.debug(`downloading Julia from ${downloadURL}`); core.debug(`downloading Julia from ${downloadURL}`);
const juliaDownloadPath = yield tc.downloadTool(downloadURL); const juliaDownloadPath = yield tc.downloadTool(downloadURL);
// Install it // Install it
@@ -93,15 +96,16 @@ function run() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
try { try {
const version = core.getInput('version'); const version = core.getInput('version');
core.debug(`selected Julia version: ${version}`); const arch = core.getInput('arch');
core.debug(`selected Julia version: ${arch}/${version}`);
// Search in cache // Search in cache
let juliaPath; let juliaPath;
juliaPath = tc.find('julia', version); juliaPath = tc.find('julia', version, arch);
if (!juliaPath) { if (!juliaPath) {
core.debug(`could not find Julia ${version} in cache`); core.debug(`could not find Julia ${version} in cache`);
const juliaInstallationPath = yield installJulia(version); const juliaInstallationPath = yield installJulia(version, arch);
// Add it to cache // Add it to cache
juliaPath = yield tc.cacheDir(juliaInstallationPath, 'julia', version); juliaPath = yield tc.cacheDir(juliaInstallationPath, 'julia', version, arch);
core.debug(`added Julia to cache: ${juliaPath}`); core.debug(`added Julia to cache: ${juliaPath}`);
} }
else { else {

View File

@@ -13,38 +13,41 @@ function getMajorMinorVersion(version: string): string {
return version.split('.').slice(0, 2).join('.') return version.split('.').slice(0, 2).join('.')
} }
function getDownloadURL(version: string): string { function getDownloadURL(version: string, arch: string): string {
const baseURL = 'https://julialang-s3.julialang.org/bin' const baseURL = 'https://julialang-s3.julialang.org/bin'
let platform: string, arch: string let platform: string
const versionDir = getMajorMinorVersion(version) const versionDir = getMajorMinorVersion(version)
if (osPlat === 'win32') { // Windows if (osPlat === 'win32') { // Windows
platform = 'winnt' platform = 'winnt'
arch = 'x64'
} else if (osPlat === 'darwin') { // macOS } else if (osPlat === 'darwin') { // macOS
if (arch == 'x86') {
throw '32-bit Julia is not available on macOS'
}
platform = 'mac' platform = 'mac'
arch = 'x64'
} else if (osPlat === 'linux') { // Linux } else if (osPlat === 'linux') { // Linux
platform = 'linux' platform = 'linux'
arch = 'x64'
} else { } else {
throw `Platform ${osPlat} is not supported` throw `Platform ${osPlat} is not supported`
} }
return `${baseURL}/${platform}/${arch}/${versionDir}/${getFileName(version)}` return `${baseURL}/${platform}/${arch}/${versionDir}/${getFileName(version, arch)}`
} }
function getFileName(version: string): string { function getFileName(version: string, arch: string): string {
let versionExt: string, ext: string let versionExt: string, ext: string
if (osPlat === 'win32') { // Windows if (osPlat === 'win32') { // Windows
versionExt = '-win64' versionExt = arch == 'x64' ? '-win64' : '-win32'
ext = 'exe' ext = 'exe'
} else if (osPlat === 'darwin') { // macOS } else if (osPlat === 'darwin') { // macOS
if (arch == 'x86') {
throw '32-bit Julia is not available on macOS'
}
versionExt = '-mac64' versionExt = '-mac64'
ext = 'dmg' ext = 'dmg'
} else if (osPlat === 'linux') { // Linux } else if (osPlat === 'linux') { // Linux
versionExt = '-linux-x86_64' versionExt = arch == 'x64' ? '-linux-x86_64' : '-linux-i686'
ext = 'tar.gz' ext = 'tar.gz'
} else { } else {
throw `Platform ${osPlat} is not supported` throw `Platform ${osPlat} is not supported`
@@ -53,9 +56,9 @@ function getFileName(version: string): string {
return `julia-${version}${versionExt}.${ext}` return `julia-${version}${versionExt}.${ext}`
} }
async function installJulia(version: string): Promise<string> { async function installJulia(version: string, arch: string): Promise<string> {
// Download Julia // Download Julia
const downloadURL = getDownloadURL(version) const downloadURL = getDownloadURL(version, arch)
core.debug(`downloading Julia from ${downloadURL}`) core.debug(`downloading Julia from ${downloadURL}`)
const juliaDownloadPath = await tc.downloadTool(downloadURL) const juliaDownloadPath = await tc.downloadTool(downloadURL)
@@ -79,18 +82,19 @@ async function installJulia(version: string): Promise<string> {
async function run() { async function run() {
try { try {
const version = core.getInput('version') const version = core.getInput('version')
core.debug(`selected Julia version: ${version}`) const arch = core.getInput('arch')
core.debug(`selected Julia version: ${arch}/${version}`)
// Search in cache // Search in cache
let juliaPath: string; let juliaPath: string;
juliaPath = tc.find('julia', version) juliaPath = tc.find('julia', version, arch)
if (!juliaPath) { if (!juliaPath) {
core.debug(`could not find Julia ${version} in cache`) core.debug(`could not find Julia ${version} in cache`)
const juliaInstallationPath = await installJulia(version); const juliaInstallationPath = await installJulia(version, arch);
// Add it to cache // Add it to cache
juliaPath = await tc.cacheDir(juliaInstallationPath, 'julia', version) juliaPath = await tc.cacheDir(juliaInstallationPath, 'julia', version, arch)
core.debug(`added Julia to cache: ${juliaPath}`) core.debug(`added Julia to cache: ${juliaPath}`)
} else { } else {
core.debug(`using cached version of Julia: ${juliaPath}`) core.debug(`using cached version of Julia: ${juliaPath}`)