add piston nix pkg for gcc-fortran

This commit is contained in:
Dan Vargas 2022-02-16 10:59:05 -07:00
parent 11882b2085
commit 3fac94b683
11 changed files with 40 additions and 108 deletions

View File

@ -1,26 +0,0 @@
#!/usr/bin/env bash
# Put instructions to build your package in here
[[ -d "bin" ]] && exit 0
PREFIX=$(realpath $(dirname $0))
mkdir -p build obj
cd build
curl "https://ftp.gnu.org/gnu/gcc/gcc-10.2.0/gcc-10.2.0.tar.gz" -o gcc.tar.gz
tar xzf gcc.tar.gz --strip-components=1
./contrib/download_prerequisites
cd ../obj
# === autoconf based ===
../build/configure --prefix "$PREFIX" --enable-languages=c,c++,d,fortran --disable-multilib --disable-bootstrap
make -j$(nproc)
make install -j$(nproc)
cd ../
rm -rf build obj

View File

@ -1,29 +0,0 @@
#!/usr/bin/env bash
# Put instructions to compile source code, remove this file if the language does not require this stage
case "${PISTON_LANGUAGE}" in
c)
rename 's/$/\.c/' "$@" # Add .c extension
gcc -std=c11 *.c -lm
;;
c++)
rename 's/$/\.cpp/' "$@" # Add .cpp extension
g++ -std=c++17 *.cpp
;;
d)
rename 's/.code$/\.d/' "$@" # Add .d extension
gdc *.d
;;
fortran)
rename 's/.code$/\.f90/' "$@" # Add .f90 extension
gfortran *.f90
;;
*)
echo "How did you get here? (${PISTON_LANGUAGE})"
exit 1
;;
esac
chmod +x a.out

View File

@ -1,5 +0,0 @@
#!/usr/bin/env bash
# Put 'export' statements here for environment variables
export PATH=$PWD/bin:$PATH
export LD_LIBRARY_PATH="$PWD/lib:$PWD/lib64" # Need this to properly link Fortran

View File

@ -1,22 +0,0 @@
{
"language": "gcc",
"version": "10.2.0",
"provides": [
{
"language": "c",
"aliases": ["gcc"]
},
{
"language": "c++",
"aliases": ["cpp", "g++"]
},
{
"language": "d",
"aliases": ["gdc"]
},
{
"language": "fortran",
"aliases": ["fortran", "f90"]
}
]
}

View File

@ -1,6 +0,0 @@
#!/usr/bin/env bash
# Put instructions to run the runtime
shift # Discard main filename
./a.out "$@"

View File

@ -1,6 +0,0 @@
#include <stdio.h>
int main(void) {
printf("OK");
return 0;
}

View File

@ -1,6 +0,0 @@
#include <iostream>
int main(void) {
printf("OK");
return 0;
}

View File

@ -1,5 +0,0 @@
import std.stdio;
void main() {
writeln("OK");
}

View File

@ -1,3 +0,0 @@
program test
print "(a)", 'OK'
end program test

View File

@ -48,4 +48,5 @@ args: {
"gcc-c" = import ./gcc-c.nix args;
"gcc-c++" = import ./gcc-c++.nix args;
"gcc-d" = import ./gcc-d.nix args;
"gcc-fortran" = import ./gcc-fortran.nix args;
}

39
runtimes/gcc-fortran.nix Normal file
View File

@ -0,0 +1,39 @@
{pkgs, piston, ...}:
let
pkg = pkgs.gfortran;
in piston.mkRuntime {
language = "fortran";
version = pkg.version;
runtime = "gcc";
aliases = [
"gfortran"
"f90"
];
compile = ''
rename 's/.code$/\.f90/' "$@" # Add .f90 extension
${pkg}/bin/gfortran *.f90
'';
run = ''
shift
./a.out "$@"
'';
tests = [
(piston.mkTest {
files = {
"test.f90" = ''
program test
print "(a)", 'OK'
end program test
'';
};
args = [];
stdin = "";
packages = [];
main = "test.f90";
})
];
}