diff --git a/runtimes/default.nix b/runtimes/default.nix index c230450..9b01411 100644 --- a/runtimes/default.nix +++ b/runtimes/default.nix @@ -46,4 +46,5 @@ args: { "groovy" = import ./groovy.nix args; "go" = import ./go.nix args; "gcc-c" = import ./gcc-c.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..da575b1 --- /dev/null +++ b/runtimes/gcc-c++.nix @@ -0,0 +1,42 @@ +{pkgs, piston, ...}: +let + pkg = pkgs.gcc; +in piston.mkRuntime { + language = "c++"; + version = pkg.version; + runtime = "gcc"; + + aliases = [ + "cpp" + "g++" + ]; + + compile = '' + rename 's/$/\.cpp/' "$@" # Add .cpp extension + ${pkg}/bin/g++ -std=c++17 *.cpp + ''; + + run = '' + shift + ./a.out "$@" + ''; + + tests = [ + (piston.mkTest { + files = { + "test.cpp" = '' + #include + + int main(void) { + printf("OK"); + return 0; + } + ''; + }; + args = []; + stdin = ""; + packages = []; + main = "test.cpp"; + }) + ]; +} \ No newline at end of file