From 6297b0bcad25f1689d886cea1df6109bae77701c Mon Sep 17 00:00:00 2001 From: Dan Vargas Date: Wed, 16 Feb 2022 10:23:32 -0700 Subject: [PATCH] add piston nix pkg for gcc-c --- runtimes/default.nix | 1 + runtimes/gcc-c.nix | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 runtimes/gcc-c.nix diff --git a/runtimes/default.nix b/runtimes/default.nix index 807d46d..c230450 100644 --- a/runtimes/default.nix +++ b/runtimes/default.nix @@ -45,4 +45,5 @@ args: { "ghc-haskell" = import ./ghc-haskell.nix args; "groovy" = import ./groovy.nix args; "go" = import ./go.nix args; + "gcc-c" = import ./gcc-c.nix args; } diff --git a/runtimes/gcc-c.nix b/runtimes/gcc-c.nix new file mode 100644 index 0000000..d85e677 --- /dev/null +++ b/runtimes/gcc-c.nix @@ -0,0 +1,41 @@ +{pkgs, piston, ...}: +let + pkg = pkgs.gcc; +in piston.mkRuntime { + language = "c"; + version = pkg.version; + runtime = "gcc"; + + aliases = [ + "gcc" + ]; + + compile = '' + rename 's/$/\.c/' "$@" # Add .c extension + ${pkg}/bin/gcc -std=c11 *.c -lm + ''; + + run = '' + shift + ./a.out "$@" + ''; + + tests = [ + (piston.mkTest { + files = { + "test.c" = '' + #include + + int main(void) { + printf("OK"); + return 0; + } + ''; + }; + args = []; + stdin = ""; + packages = []; + main = "test.c"; + }) + ]; +} \ No newline at end of file