Skip to content

Commit

Permalink
Allow custom fpcup-url
Browse files Browse the repository at this point in the history
  • Loading branch information
ollydev committed Aug 14, 2021
1 parent 81f4d1d commit c180b2f
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 80 deletions.
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ inputs:
required: true
fpc-branch:
required: true
fpcup-url:
required: false
runs:
using: 'node12'
main: 'dist/index/index.js'
Expand Down
95 changes: 55 additions & 40 deletions dist/index/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60096,44 +60096,61 @@ const cache = __nccwpck_require__(7799);
const process = __nccwpck_require__(1765);
const path = __nccwpck_require__(5622);

const dir = path.normalize(path.resolve('../laz')).replace(/\\/g, "/");
const cacheKey = '[' + process.platform + '][' + core.getInput('cpu') + '][' + core.getInput('fpc-branch') + '][' + core.getInput('laz-branch') + ']';
var fpcup_downloads = {};

async function bash(command_line) {
await exec.exec('bash', ['-c', command_line.join(' ')]);
fpcup_downloads['linux'] = {
'x86_64': 'https://github.com/LongDirtyAnimAlf/Reiniero-fpcup/releases/download/v2.0.1/fpclazup-x86_64-linux',
'aarch64': 'https://github.com/LongDirtyAnimAlf/Reiniero-fpcup/releases/download/v2.0.1/fpclazup-x86_64-linux'
}

async function install_fpcup(cpu) {
fpcup_downloads['win32'] = {
'i386': 'https://github.com/LongDirtyAnimAlf/Reiniero-fpcup/releases/download/v2.0.1/fpclazup-i386-win32.exe',
'x86_64': 'https://github.com/LongDirtyAnimAlf/Reiniero-fpcup/releases/download/v2.0.1/fpclazup-x86_64-win64.exe'
}

var dict = {};
fpcup_downloads['darwin'] = {
'x86_64': 'https://github.com/LongDirtyAnimAlf/Reiniero-fpcup/releases/download/v2.0.1/fpclazup-x86_64-darwin'
}

dict['linux'] = {
'x86_64': 'https://github.com/LongDirtyAnimAlf/Reiniero-fpcup/releases/download/v2.0.0e/fpclazup-x86_64-linux',
'aarch64': 'https://github.com/LongDirtyAnimAlf/Reiniero-fpcup/releases/download/v2.0.0e/fpclazup-x86_64-linux'
}
var cacheKey = '';
var fpcupURL, fpcupPath = '';

dict['win32'] = {
'i386': 'https://github.com/LongDirtyAnimAlf/Reiniero-fpcup/releases/download/v2.0.0e/fpclazup-i386-win32.exe',
'x86_64': 'https://github.com/LongDirtyAnimAlf/Reiniero-fpcup/releases/download/v2.0.0e/fpclazup-x86_64-win64.exe'
}
async function init(platform, cpu, fpcup, fpcBranch, lazBranch) {

dict['darwin'] = {
'x86_64': 'https://github.com/LongDirtyAnimAlf/Reiniero-fpcup/releases/download/v2.0.0e/fpclazup-x86_64-darwin'
}

try {
console.log('Downloading: ', dict[process.platform][cpu]);
} catch {
throw new Error('Invalid cpu "' + cpu + '" on platform "' + process.platform + '"');
}

await toolcache.downloadTool(dict[process.platform][cpu], 'fpcup');
fpcupURL = fpcup;
if (fpcupURL == '') {
try {
fpcupURL = fpcup_downloads[platform][cpu];
} catch {
throw new Error('Invalid cpu "' + cpu + '" on platform "' + platform + '"');
}
}

cacheKey = '[' + fpcupURL + '][' + cpu + '][' + fpcBranch + '][' + lazBranch + ']';

fpcupPath = path.resolve('../laz');
fpcupPath = path.normalize(fpcupPath).replace(/\\/g, "/");

console.log('cacheKey: ', cacheKey);
console.log('fpcupURL: ', fpcupURL);
console.log('fpcupPath: ', fpcupPath);
}

async function bash(command_line) {
await exec.exec('bash', ['-c', command_line.join(' ')]);
}

async function install_fpcup() {

console.log('Downloading: ', fpcupPath);

await toolcache.downloadTool(fpcupURL, 'fpcup');
await bash(['chmod +x fpcup']);
}

async function restore_lazarus() {

var key = await cache.restoreCache([dir], cacheKey);
var key = await cache.restoreCache([fpcupPath], cacheKey);
if (key != null) {
console.log('Restored lazarus from cache');
}
Expand All @@ -60145,13 +60162,13 @@ async function install_lazarus() {

console.log('Installing Lazarus');

await bash(['mkdir -p ' + dir]);
await bash(['mkdir -p ' + fpcupPath]);
await bash(['./fpcup',
'--fpcURL=gitlab',
'--lazURL=gitlab',
'--fpcBranch=' + core.getInput('fpc-branch'),
'--lazBranch=' + core.getInput('laz-branch'),
'--installdir=' + dir,
'--installdir=' + fpcupPath,
'--only=docker',
'--noconfirm'
]);
Expand All @@ -60163,16 +60180,16 @@ async function install_cross_compiler(cpu) {

console.log('Installing cross compiler: AArch64');

await toolcache.extractZip(await toolcache.downloadTool('https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases/download/crosslibs_v1.1/CrossLibsLinuxAarch64.zip'), dir);
await toolcache.extractZip(await toolcache.downloadTool('https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases/download/linuxx64crossbins_v1.0/CrossBinsLinuxAarch64.zip'), path.join(dir, 'cross/bin'));
await toolcache.extractZip(await toolcache.downloadTool('https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases/download/crosslibs_v1.1/CrossLibsLinuxAarch64.zip'), fpcupPath);
await toolcache.extractZip(await toolcache.downloadTool('https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases/download/linuxx64crossbins_v1.0/CrossBinsLinuxAarch64.zip'), path.join(fpcupPath, 'cross/bin'));

await bash(['./fpcup',
'--installdir=' + dir,
'--installdir=' + fpcupPath,
'--ostarget=linux',
'--cputarget=aarch64',
'--only=FPCCleanOnly,FPCBuildOnly',
'--crossbindir=' + path.join(dir, 'cross/bin'),
'--crosslibdir=' + path.join(dir, 'cross/lib/aarch64-linux'),
'--crossbindir=' + path.join(fpcupPath, 'cross/bin'),
'--crosslibdir=' + path.join(fpcupPath, 'cross/lib/aarch64-linux'),
'--noconfirm',
'--verbose'
]);
Expand All @@ -60192,23 +60209,21 @@ async function install_dependencies(platform) {

async function run() {

console.log('Install Directory:', dir);
console.log('Cache Key: ', cacheKey);

try {
await init(process.platform, core.getInput('cpu'), core.getInput('fpcup-url'), core.getInput('fpc-branch'), core.getInput('laz-branch'));
await install_dependencies(process.platform);

if (await restore_lazarus() == false) {
await install_fpcup(core.getInput('cpu'));

await install_fpcup();
await install_lazarus();
await install_cross_compiler(core.getInput('cpu'));

core.exportVariable('SAVE_CACHE_DIR', dir);
core.exportVariable('SAVE_CACHE_DIR', fpcupPath);
core.exportVariable('SAVE_CACHE_KEY', cacheKey);
}

core.addPath(path.join(dir, 'lazarus'));
core.addPath(path.join(fpcupPath, 'lazarus'));
} catch (error) {
core.setFailed(error.message);
}
Expand Down
95 changes: 55 additions & 40 deletions source/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,61 @@ const cache = require('@actions/cache');
const process = require('process');
const path = require('path');

const dir = path.normalize(path.resolve('../laz')).replace(/\\/g, "/");
const cacheKey = '[' + process.platform + '][' + core.getInput('cpu') + '][' + core.getInput('fpc-branch') + '][' + core.getInput('laz-branch') + ']';
var fpcup_downloads = {};

async function bash(command_line) {
await exec.exec('bash', ['-c', command_line.join(' ')]);
fpcup_downloads['linux'] = {
'x86_64': 'https://github.com/LongDirtyAnimAlf/Reiniero-fpcup/releases/download/v2.0.1/fpclazup-x86_64-linux',
'aarch64': 'https://github.com/LongDirtyAnimAlf/Reiniero-fpcup/releases/download/v2.0.1/fpclazup-x86_64-linux'
}

async function install_fpcup(cpu) {
fpcup_downloads['win32'] = {
'i386': 'https://github.com/LongDirtyAnimAlf/Reiniero-fpcup/releases/download/v2.0.1/fpclazup-i386-win32.exe',
'x86_64': 'https://github.com/LongDirtyAnimAlf/Reiniero-fpcup/releases/download/v2.0.1/fpclazup-x86_64-win64.exe'
}

var dict = {};
fpcup_downloads['darwin'] = {
'x86_64': 'https://github.com/LongDirtyAnimAlf/Reiniero-fpcup/releases/download/v2.0.1/fpclazup-x86_64-darwin'
}

dict['linux'] = {
'x86_64': 'https://github.com/LongDirtyAnimAlf/Reiniero-fpcup/releases/download/v2.0.0e/fpclazup-x86_64-linux',
'aarch64': 'https://github.com/LongDirtyAnimAlf/Reiniero-fpcup/releases/download/v2.0.0e/fpclazup-x86_64-linux'
}
var cacheKey = '';
var fpcupURL, fpcupPath = '';

dict['win32'] = {
'i386': 'https://github.com/LongDirtyAnimAlf/Reiniero-fpcup/releases/download/v2.0.0e/fpclazup-i386-win32.exe',
'x86_64': 'https://github.com/LongDirtyAnimAlf/Reiniero-fpcup/releases/download/v2.0.0e/fpclazup-x86_64-win64.exe'
}
async function init(platform, cpu, fpcup, fpcBranch, lazBranch) {

dict['darwin'] = {
'x86_64': 'https://github.com/LongDirtyAnimAlf/Reiniero-fpcup/releases/download/v2.0.0e/fpclazup-x86_64-darwin'
}

try {
console.log('Downloading: ', dict[process.platform][cpu]);
} catch {
throw new Error('Invalid cpu "' + cpu + '" on platform "' + process.platform + '"');
}

await toolcache.downloadTool(dict[process.platform][cpu], 'fpcup');
fpcupURL = fpcup;
if (fpcupURL == '') {
try {
fpcupURL = fpcup_downloads[platform][cpu];
} catch {
throw new Error('Invalid cpu "' + cpu + '" on platform "' + platform + '"');
}
}

cacheKey = '[' + fpcupURL + '][' + cpu + '][' + fpcBranch + '][' + lazBranch + ']';

fpcupPath = path.resolve('../laz');
fpcupPath = path.normalize(fpcupPath).replace(/\\/g, "/");

console.log('cacheKey: ', cacheKey);
console.log('fpcupURL: ', fpcupURL);
console.log('fpcupPath: ', fpcupPath);
}

async function bash(command_line) {
await exec.exec('bash', ['-c', command_line.join(' ')]);
}

async function install_fpcup() {

console.log('Downloading: ', fpcupPath);

await toolcache.downloadTool(fpcupURL, 'fpcup');
await bash(['chmod +x fpcup']);
}

async function restore_lazarus() {

var key = await cache.restoreCache([dir], cacheKey);
var key = await cache.restoreCache([fpcupPath], cacheKey);
if (key != null) {
console.log('Restored lazarus from cache');
}
Expand All @@ -56,13 +73,13 @@ async function install_lazarus() {

console.log('Installing Lazarus');

await bash(['mkdir -p ' + dir]);
await bash(['mkdir -p ' + fpcupPath]);
await bash(['./fpcup',
'--fpcURL=gitlab',
'--lazURL=gitlab',
'--fpcBranch=' + core.getInput('fpc-branch'),
'--lazBranch=' + core.getInput('laz-branch'),
'--installdir=' + dir,
'--installdir=' + fpcupPath,
'--only=docker',
'--noconfirm'
]);
Expand All @@ -74,16 +91,16 @@ async function install_cross_compiler(cpu) {

console.log('Installing cross compiler: AArch64');

await toolcache.extractZip(await toolcache.downloadTool('https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases/download/crosslibs_v1.1/CrossLibsLinuxAarch64.zip'), dir);
await toolcache.extractZip(await toolcache.downloadTool('https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases/download/linuxx64crossbins_v1.0/CrossBinsLinuxAarch64.zip'), path.join(dir, 'cross/bin'));
await toolcache.extractZip(await toolcache.downloadTool('https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases/download/crosslibs_v1.1/CrossLibsLinuxAarch64.zip'), fpcupPath);
await toolcache.extractZip(await toolcache.downloadTool('https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases/download/linuxx64crossbins_v1.0/CrossBinsLinuxAarch64.zip'), path.join(fpcupPath, 'cross/bin'));

await bash(['./fpcup',
'--installdir=' + dir,
'--installdir=' + fpcupPath,
'--ostarget=linux',
'--cputarget=aarch64',
'--only=FPCCleanOnly,FPCBuildOnly',
'--crossbindir=' + path.join(dir, 'cross/bin'),
'--crosslibdir=' + path.join(dir, 'cross/lib/aarch64-linux'),
'--crossbindir=' + path.join(fpcupPath, 'cross/bin'),
'--crosslibdir=' + path.join(fpcupPath, 'cross/lib/aarch64-linux'),
'--noconfirm',
'--verbose'
]);
Expand All @@ -103,23 +120,21 @@ async function install_dependencies(platform) {

async function run() {

console.log('Install Directory:', dir);
console.log('Cache Key: ', cacheKey);

try {
await init(process.platform, core.getInput('cpu'), core.getInput('fpcup-url'), core.getInput('fpc-branch'), core.getInput('laz-branch'));
await install_dependencies(process.platform);

if (await restore_lazarus() == false) {
await install_fpcup(core.getInput('cpu'));

await install_fpcup();
await install_lazarus();
await install_cross_compiler(core.getInput('cpu'));

core.exportVariable('SAVE_CACHE_DIR', dir);
core.exportVariable('SAVE_CACHE_DIR', fpcupPath);
core.exportVariable('SAVE_CACHE_KEY', cacheKey);
}

core.addPath(path.join(dir, 'lazarus'));
core.addPath(path.join(fpcupPath, 'lazarus'));
} catch (error) {
core.setFailed(error.message);
}
Expand Down

0 comments on commit c180b2f

Please sign in to comment.