ccode_runner
ccode_runner is a component designed to run arbitrary program code on local devices. It compiles or interprets code and sends the output, making it an essential part of the cpast ecosystem.
Features
- Multi-language Support: Supports various programming languages including Rust, Python, C, C++, Java, Ruby, and JavaScript.
- Compilation and Interpretation: Handles both ahead-of-time compilation and just-in-time interpretation.
- Optimized Execution: Uses precompilation and caching to optimize execution times.
- Execution Limits: Configure time and memory limits to prevent runaway processes and excessive resource consumption.
Getting Started
Prerequisites
Ensure you have the necessary compilers and interpreters installed for the languages you intend to use.
Installation
Clone the repository and navigate to the ccode_runner directory:
Usage
To use ccode_runner, you need to integrate it within your cpast testing workflow. Below is an example of how to use it:
use ProgramStore;
use Path;
Using Execution Limits
You can configure time and memory limits to prevent infinite loops and excessive resource consumption:
Platform Support:
- Time limits: Supported on all platforms (Unix, Windows, macOS)
- Memory limits: Supported on all platforms
- Unix/Linux/macOS: Native OS enforcement via
setrlimit(RLIMIT_AS) - Windows: Active monitoring and enforcement via process memory tracking
- Unix/Linux/macOS: Native OS enforcement via
Note: Execution limits apply only to program execution, not compilation. Compilation always runs without limits to ensure successful builds.
use ProgramStore;
use ExecutionLimits;
use Path;
Supported Languages
- Rust:
.rs - Python:
.py - C:
.c - C++:
.cpp,.cxx,.c++,.cc,.C - Java:
.java - JavaScript:
.js - Ruby:
.rb
Compilation and Execution
ccode_runner uses different strategies for different languages:
- Ahead-of-Time Compilation: For languages like C, C++, Rust, and Java.
- Just-in-Time Interpretation: For languages like Python, Ruby, and JavaScript.
- Ahead-of-Time Interpreted: For Java, which requires converting to intermediate bytecode before execution.
ccode_runner is well suited when repeated compilation might be required for one code like in case for cpast, it intelligently skips those cases for you, making it lot faster!
Contributing
We welcome contributions! Please read our Contributing Guidelines for more details.