Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # DNB
- 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.
- # Examples explained
- Note: In real projects, filenames would be `dnb.yaml`, `dnb.macos.yaml`, etc.
- ## `dnb.yaml`
- 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`.
- ## Kitchen sink
- 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.
- # Usage
- ```bash
- $ 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`.
- ## Cross-compiling
- ```bash
- $ dnb --platform=macos rebuild # Specify a specific platform
- ```
- Platforms:
- * `windows`
- * `macos`
- * `linux`
- * `android`
- * `ios`
- * `fuchsia`
- * `unknown`
- ## Definitions on-the-fly
- ```bash
- $ dnb --define foo=bar --define baz
- $ dnb -dfoo=bar -dbaz
- ```
- # Default definitions
- * `DART_SHARED_LIB`: Always defined
- * `DART_PACKAGE_NAME`: The name of the package
- * `DART_PACKAGE_VERSION`: The package's version string. Defaults to `0.0.0`
- * `DEBUG`: defined when `--debug` is present
- * `NDEBUG`, `RELEASE`: defined by default. Undefined when `--debug` is present.
- # Environment variables
- * `DART_SDK`: Defined to the path to your Dart SDK.
Add Comment
Please, Sign In to add comment