From 3fac94b6836c0cdb3be2fdf90f9bb2facbc3bb75 Mon Sep 17 00:00:00 2001 From: Dan Vargas Date: Wed, 16 Feb 2022 10:59:05 -0700 Subject: [PATCH] add piston nix pkg for gcc-fortran --- packages/gcc/10.2.0/build.sh | 26 --------------------- packages/gcc/10.2.0/compile | 29 ----------------------- packages/gcc/10.2.0/environment | 5 ---- packages/gcc/10.2.0/metadata.json | 22 ----------------- packages/gcc/10.2.0/run | 6 ----- packages/gcc/10.2.0/test.c | 6 ----- packages/gcc/10.2.0/test.cpp | 6 ----- packages/gcc/10.2.0/test.d | 5 ---- packages/gcc/10.2.0/test.f90 | 3 --- runtimes/default.nix | 1 + runtimes/gcc-fortran.nix | 39 +++++++++++++++++++++++++++++++ 11 files changed, 40 insertions(+), 108 deletions(-) delete mode 100755 packages/gcc/10.2.0/build.sh delete mode 100644 packages/gcc/10.2.0/compile delete mode 100644 packages/gcc/10.2.0/environment delete mode 100644 packages/gcc/10.2.0/metadata.json delete mode 100644 packages/gcc/10.2.0/run delete mode 100644 packages/gcc/10.2.0/test.c delete mode 100644 packages/gcc/10.2.0/test.cpp delete mode 100644 packages/gcc/10.2.0/test.d delete mode 100644 packages/gcc/10.2.0/test.f90 create mode 100644 runtimes/gcc-fortran.nix diff --git a/packages/gcc/10.2.0/build.sh b/packages/gcc/10.2.0/build.sh deleted file mode 100755 index 0ed183a..0000000 --- a/packages/gcc/10.2.0/build.sh +++ /dev/null @@ -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 - diff --git a/packages/gcc/10.2.0/compile b/packages/gcc/10.2.0/compile deleted file mode 100644 index a77ba35..0000000 --- a/packages/gcc/10.2.0/compile +++ /dev/null @@ -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 \ No newline at end of file diff --git a/packages/gcc/10.2.0/environment b/packages/gcc/10.2.0/environment deleted file mode 100644 index a0b5a11..0000000 --- a/packages/gcc/10.2.0/environment +++ /dev/null @@ -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 diff --git a/packages/gcc/10.2.0/metadata.json b/packages/gcc/10.2.0/metadata.json deleted file mode 100644 index 367de7c..0000000 --- a/packages/gcc/10.2.0/metadata.json +++ /dev/null @@ -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"] - } - ] -} diff --git a/packages/gcc/10.2.0/run b/packages/gcc/10.2.0/run deleted file mode 100644 index 60ad16b..0000000 --- a/packages/gcc/10.2.0/run +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -# Put instructions to run the runtime - -shift # Discard main filename -./a.out "$@" diff --git a/packages/gcc/10.2.0/test.c b/packages/gcc/10.2.0/test.c deleted file mode 100644 index fafae75..0000000 --- a/packages/gcc/10.2.0/test.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -int main(void) { - printf("OK"); - return 0; -} \ No newline at end of file diff --git a/packages/gcc/10.2.0/test.cpp b/packages/gcc/10.2.0/test.cpp deleted file mode 100644 index 9d0499e..0000000 --- a/packages/gcc/10.2.0/test.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include - -int main(void) { - printf("OK"); - return 0; -} \ No newline at end of file diff --git a/packages/gcc/10.2.0/test.d b/packages/gcc/10.2.0/test.d deleted file mode 100644 index e74851d..0000000 --- a/packages/gcc/10.2.0/test.d +++ /dev/null @@ -1,5 +0,0 @@ -import std.stdio; - -void main() { - writeln("OK"); -} \ No newline at end of file diff --git a/packages/gcc/10.2.0/test.f90 b/packages/gcc/10.2.0/test.f90 deleted file mode 100644 index 99fc062..0000000 --- a/packages/gcc/10.2.0/test.f90 +++ /dev/null @@ -1,3 +0,0 @@ -program test - print "(a)", 'OK' -end program test diff --git a/runtimes/default.nix b/runtimes/default.nix index 23b997e..bd8dbf3 100644 --- a/runtimes/default.nix +++ b/runtimes/default.nix @@ -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; } diff --git a/runtimes/gcc-fortran.nix b/runtimes/gcc-fortran.nix new file mode 100644 index 0000000..7173753 --- /dev/null +++ b/runtimes/gcc-fortran.nix @@ -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"; + }) + ]; +} \ No newline at end of file