dartle_c 0.1.0 dartle_c: ^0.1.0 copied to clipboard
A Dartle extension to compile code written in the C programming language.
DartleC #
A Dartle extension to compile C projects.
It compiles C code into object files incrementally (compileC
task),
then generates a binary executable from the object files (linkC
task).
DartleC can be used as a command-line utility, dcc
, or as a Dartle library (to integrate with other Dartle-based tools).
Using the executable dcc
#
DartleC can be used as a command-line utility to compile C code.
To use it in that way, activate it with pub
:
dart pub global activate dartle_c
After this, running dcc
will compile all C files found in a src
directory to the out
dir,
generating a binary executable named a.out
.
Configuring dcc
#
To configure dcc
, create a dcc.yaml
file at the project root directory with contents as shown
below (all options are optional):
compiler: gcc
compiler-args: ["-std=c2x", "-Wall", "-Werror", "-ansi", "-pedantic"]
objects-dir: out
source-dirs: [src]
# instead of source-dirs, you can also list files explicitly:
# source-files: [foo.c, bar.c]
output: my-binary
The
compiler
is chosen depending on the platform if not provided. You can also set theCC
environment variable to choose one.
Options can also be passed to the DartleC
tasks.
For example, to pass an option to the C Compiler via the CLI:
$ dcc compile :-Wextra
CLI options are added to the
compiler-args
provided in the YAML configuration file.
Using DartleC
as a library. #
To include DartleC
in your existing Dartle build, or to write your own build system based on
DartleC
, add it as a dependency of your Dart project:
dart pub add dartle_c
Check this project's example for how to use its API.