This is a prototype of a CMake-based build tool for Dart native extensions.
Combined with scripts
, this would be comparable to node-gyp
, but with actual
Windows support, and no Python dependency.
DNB is designed to ensure portability across various platforms where Dart runs.
Note: In real projects, filenames would be dnb.yaml
, dnb.macos.yaml
, etc.
This file would be used to build a hypothetical Dart native extension named sample_extension
.
The extension would build to lib/src/libsample_extension.so
(or .dll
, .dylib
, etc.).
In a real project, dnb.yaml
would be a sibling to pubspec.yaml
.
The files kitchen_sink.yaml
and kitchen_sink.macos.yaml
contain every feature planned thusfar.
Most projects will only need to use a small subset of the features, so it will be simple to produce portable
native extensions without too much ugly configuration.
$ dnb --help
$ dnb init # Create a minimal `dnb.yaml` (virtually the same as the one in the example)
$ dnb configure # Generate CMakeLists.txt, run "cmake ."
$ dnb build # Run "cmake --build . -- -j <num_cores>"
$ dnb clean # Run "cmake --build . --target clean"
$ dnb rebuild # Delete CMakeCache.txt, `configure`, then `build`
$ dnb boilerplate foo_extension > lib/src/foo_extension.cc # Generate extension boilerplate C/C++ code
$ dnb -j 4 --target rebuild my_extension # Specify `-j` arg to pass to CMake
$ dnb --cmake="/path/to/cmake" rebuild # Override CMake executable path
$ dnb --watch rebuild # Watch dnb.yaml for changes
$ dnb --debug rebuild # Enable debug-specific flags. Default is release
Ultimately, the command end-users will need to run is dnb rebuild
.
$ dnb --platform=macos rebuild # Specify a specific platform
Platforms:
windows
macos
linux
android
ios
fuchsia
unknown
$ dnb --define foo=bar --define baz
$ dnb -dfoo=bar -dbaz
DART_SHARED_LIB
: Always definedDART_PACKAGE_NAME
: The name of the packageDART_PACKAGE_VERSION
: The package's version string. Defaults to0.0.0
DEBUG
: defined when--debug
is presentNDEBUG
,RELEASE
: defined by default. Undefined when--debug
is present.
DART_SDK
: Defined to the path to your Dart SDK.
Note: There should be an option to specify which directory the
CMakeLists.txt
file should be generated in.