A Dartle extension to compile C projects.
It compiles C code into object files incrementally (
then generates a binary executable from the object files (
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
DartleC can be used as a command-line utility to compile C code.
To use it in that way, activate it with
dart pub global activate dartle_c
After this, running
dcc will compile all C files found in a
src directory to the
generating a binary executable named
compileC- Compiles C source code into object files.
linkC- Links object files, creating a binary executable.
cleanC- Deletes the outputs of all other tasks.
linkC depends on
compileC and is the default task. Hence, simply running
will run both tasks as necessary.
To only compile the C source files without generating an executable,
and using a specific
dcc compileC :-cstd=c99
:before the argument to the
compileCtask is necessary because otherwise Dartle uses the argument instead of passing it on to the task.
Notice that Dartle allows calling tasks by typing only their partial names, so for example,
compileC task can be run by typing
dcc comp or
dcc coC. To run
linkC, if no
extra tasks are added, requires only
dcc l (as no other tasks start with an
# show usage and available options
# show all tasks
# enable verbose (`debug`) output
dcc -l debug
dcc, create a
dcc.yaml file at the project root directory with contents as shown
below (all properties are optional):
compiler-args: ["-std=c2x", "-Wall", "-Werror", "-ansi", "-pedantic"]
# instead of source-dirs, you can also list files explicitly:
# source-files: [foo.c, bar.c]
compileris chosen depending on the platform if not provided. You can also set the
CCenvironment variable to choose one.
Task options are added to the
compiler-args provided in the YAML configuration file.
DartleC as a library.
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.
- A Dartle extension to compile C code.