Guest User

Untitled

a guest
May 27th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. # DNB
  2. This is a prototype of a CMake-based build tool for Dart native extensions.
  3. Combined with `scripts`, this would be comparable to `node-gyp`, but with actual
  4. Windows support, and no Python dependency.
  5.  
  6. DNB is designed to ensure portability across various platforms where Dart runs.
  7.  
  8. # Examples explained
  9. Note: In real projects, filenames would be `dnb.yaml`, `dnb.macos.yaml`, etc.
  10.  
  11. ## `dnb.yaml`
  12. This file would be used to build a hypothetical Dart native extension named `sample_extension`.
  13. The extension would build to `lib/src/libsample_extension.so` (or `.dll`, `.dylib`, etc.).
  14.  
  15. In a real project, `dnb.yaml` would be a sibling to `pubspec.yaml`.
  16.  
  17. ## Kitchen sink
  18. The files `kitchen_sink.yaml` and `kitchen_sink.macos.yaml` contain every feature planned thusfar.
  19. Most projects will only need to use a small subset of the features, so it will be simple to produce portable
  20. native extensions without too much ugly configuration.
  21.  
  22. # Usage
  23. ```bash
  24. $ dnb --help
  25. $ dnb init # Create a minimal `dnb.yaml` (virtually the same as the one in the example)
  26. $ dnb configure # Generate CMakeLists.txt, run "cmake ."
  27. $ dnb build # Run "cmake --build . -- -j <num_cores>"
  28. $ dnb clean # Run "cmake --build . --target clean"
  29. $ dnb rebuild # Delete CMakeCache.txt, `configure`, then `build`
  30. $ dnb boilerplate foo_extension > lib/src/foo_extension.cc # Generate extension boilerplate C/C++ code
  31. $ dnb -j 4 --target rebuild my_extension # Specify `-j` arg to pass to CMake
  32. $ dnb --cmake="/path/to/cmake" rebuild # Override CMake executable path
  33. $ dnb --watch rebuild # Watch dnb.yaml for changes
  34. $ dnb --debug rebuild # Enable debug-specific flags. Default is release
  35. ```
  36.  
  37. Ultimately, the command end-users will need to run is `dnb rebuild`.
  38.  
  39. ## Cross-compiling
  40. ```bash
  41. $ dnb --platform=macos rebuild # Specify a specific platform
  42. ```
  43.  
  44. Platforms:
  45. * `windows`
  46. * `macos`
  47. * `linux`
  48. * `android`
  49. * `ios`
  50. * `fuchsia`
  51. * `unknown`
  52.  
  53. ## Definitions on-the-fly
  54. ```bash
  55. $ dnb --define foo=bar --define baz
  56. $ dnb -dfoo=bar -dbaz
  57. ```
  58.  
  59. # Default definitions
  60. * `DART_SHARED_LIB`: Always defined
  61. * `DART_PACKAGE_NAME`: The name of the package
  62. * `DART_PACKAGE_VERSION`: The package's version string. Defaults to `0.0.0`
  63. * `DEBUG`: defined when `--debug` is present
  64. * `NDEBUG`, `RELEASE`: defined by default. Undefined when `--debug` is present.
  65.  
  66. # Environment variables
  67. * `DART_SDK`: Defined to the path to your Dart SDK.
Add Comment
Please, Sign In to add comment