All Projects → ForNeVeR → Cesium

ForNeVeR / Cesium

Licence: MIT license
C compiler for the CLI platform

Programming Languages

C#
18002 projects
c
50402 projects - #5 most used programming language
powershell
5483 projects
shell
77523 projects

Cesium Status Enfer

Cesium is a fully managed C compiler for CLI platform (.NET).

What? Cesium compiles standard C source code to a .NET assembly. No unmanaged/mixed mode (a-lá C++/CLI) code is generated; everything is fully managed (but may be unsafe).

Why? C programs are very useful in the modern world and solve practical tasks. At the same time, deploying C code alongside .NET code may be tricky (especially if your application supports multiple platforms). Cesium is designed to resolve the problems of C code deployment, and lift it to the managed state (so it is cross-platform in the same way as the underlying CIL code it is compiled to).

Implementation Status

TL;DR: is it ready for use?

Unfortunately, not yet. You won't be able to use Cesium for anything useful today. Probably, you'll be able to start after the next milestone is implemented. Stay tuned!

Dashboard

Have a question? Welcome to the discussions section!

Looking to contribute? Check open issues with the "help-wanted" label. Cesium is a big project which lives thanks to its contributors.

Not sure where to contribute? Check open issues with the "good first issue" label.

If you're interested in certain project areas, check the per-area issue labels:

Sneak Peek

Currently, Cesium is able to compile a "Hello, world" C17 example to a .NET assembly:

#include <stdio.h>

int main(int argc, char *argv[])
{
    puts("Hello, world!");
    return 42;
}

The next milestone is #61: sha1collisiondetection, which is 60% complete (note that the progress estimation is preliminary and may be changed in either direction at any moment).

Documentation

Usage

$ dotnet run --project Cesium.Compiler -- <path to the input .c file> --out <path to the output assembly>

For example, this will generate an assembly executable by .NET 6, .NET Framework, or Mono:

$ dotnet run --project Cesium.Compiler -- Cesium.Samples/minimal.c --out out.exe
$ dotnet ./out.exe # run with .NET 6
$ ./out.exe # only on Windows, run with .NET Framework
$ mono ./out.exe # run with Mono

Optional Parameters

  • --framework <framework>: specifies the target framework, defaults to Net
    • NetFramework for .NET Framework
    • NetStandard for .NET Standard
    • Net for .NET 5+
  • --modulekind <moduleKind>: specifies the output module kind; by default, it is autodetected from the output file extension
    • Dll: gets detected from a .dll extension
    • Console: gets detected from an .exe extension
    • Windows: doesn't get detected, so it's only possible to select manually
    • NetModule: is a rudiment from Cecil, not supported

Testing

Want to add new tests to Cesium? Read a separate document on tests.

There are two kinds of tests in Cesium: unit tests and integration tests.

Run the unit tests using this shell command:

$ dotnet test

Run the integration tests using this shell command (PowerShell is required):

$ pwsh -c ./Cesium.IntegrationTests/Run-Tests.ps1 -NoBuild

(don't pass -NoBuild if you want to automatically rebuild the compiler before running the integration tests)

If you debug integration tests and want to run just a single test, use this shell command:

pwsh -c ./Cesium.IntegrationTests/Run-Tests.ps1 -TestCaseName quoted_include_fallback.c

where quoted_include_fallback.c is path within Cesium.IntegrationTests folder.

Publishing

For producing standalone compiler executable run

dotnet publish Cesium.Compiler/Cesium.Compiler.csproj -r win-x64 --self-contained

Then navigate to Cesium.Compiler\bin\Debug\net6.0\win-x64\publish\ and that's your Cesium.

Code Quality (Experimental)

See the Sonar dashboard.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].