From b83880baa979982d483ab9ef6be78ac579b27bcf Mon Sep 17 00:00:00 2001 From: Aditya Singh Date: Tue, 14 Oct 2025 02:48:08 +0530 Subject: [PATCH] feat: Added C++ Runtime --- Makefile | 5 ++++- livecode_server/config.py | 5 +++++ runtimes/cpp/Dockerfile | 10 ++++++++++ runtimes/cpp/run.sh | 9 +++++++++ tests/runtimes/test_cpp_hello.yml | 10 ++++++++++ 5 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 runtimes/cpp/Dockerfile create mode 100644 runtimes/cpp/run.sh create mode 100644 tests/runtimes/test_cpp_hello.yml diff --git a/Makefile b/Makefile index 47d3b8c..aff0460 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,10 @@ default: run build-c-runtime: docker build -t fossunited/falcon-c ./runtimes/c -setup: build-c-runtime +build-cpp-runtime: + docker build -t fossunited/falcon-cpp ./runtimes/cpp + +setup: build-c-runtime build-cpp-runtime docker pull fossunited/falcon-python:3.9 docker pull fossunited/falcon-golang docker pull fossunited/falcon-rust diff --git a/livecode_server/config.py b/livecode_server/config.py index cc40877..cbfa249 100644 --- a/livecode_server/config.py +++ b/livecode_server/config.py @@ -35,6 +35,11 @@ "command": [], "code_filename": "main.c" }, + "cpp": { + "image": "fossunited/falcon-cpp", + "command": [], + "code_filename": "main.cpp" + }, "joy": { "image": "falcon-joy", "command": ["python", "/opt/start.py"], diff --git a/runtimes/cpp/Dockerfile b/runtimes/cpp/Dockerfile new file mode 100644 index 0000000..58cd354 --- /dev/null +++ b/runtimes/cpp/Dockerfile @@ -0,0 +1,10 @@ +FROM debian:bullseye-slim +RUN apt-get update && \ + apt-get install -y build-essential && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* +COPY run.sh /usr/local/bin/run.sh +RUN chmod +x /usr/local/bin/run.sh +WORKDIR /app +ENTRYPOINT ["/usr/local/bin/run.sh"] + diff --git a/runtimes/cpp/run.sh b/runtimes/cpp/run.sh new file mode 100644 index 0000000..7d6fdff --- /dev/null +++ b/runtimes/cpp/run.sh @@ -0,0 +1,9 @@ +#!/bin/sh +set -e + +SOURCE_FILE="main.cpp" +OUTPUT_BINARY="/tmp/a.out" + +g++ "${SOURCE_FILE}" -o "${OUTPUT_BINARY}" +exec "${OUTPUT_BINARY}" + diff --git a/tests/runtimes/test_cpp_hello.yml b/tests/runtimes/test_cpp_hello.yml new file mode 100644 index 0000000..5d4b6d0 --- /dev/null +++ b/tests/runtimes/test_cpp_hello.yml @@ -0,0 +1,10 @@ +runtime: cpp +code: | + #include + int main() { + std::cout << "Hello from C++ runtime!" << std::endl; + return 0; + } +expected_output: "Hello from C++ runtime!\n" + +