github google/fruit v3.0.0
Fruit 3.0.0

latest releases: v3.7.1, v3.7.0, v3.6.0...
7 years ago

This is the third major release of Fruit.

This release introduces backwards-incompatible changes (see below). If you have a significant amount of code to port from Fruit 2.0.x, consider first porting to Fruit 2.1.0. See the 2.1.0 release notes for more information and a suggested migration process.

Backwards-incompatible changes

  • PartialComponent::install(), Injector's constructors and NormalizedComponent's constructor now take a Component-returning function and the arguments that it should be called with, instead of taking the resulting Component.
  • Installed components are now de-duplicated, i.e. calling install(getFooComponent) twice in Fruit 3.x only ends up calling getFooComponent() once and only adds that component's bindings once (as opposed to calling install(getFooComponent()) in Fruit 2.x). This can lead to different behavior if getFooComponent has side-effects or if it binds multibindings. See the reference documentation for more details (e.g. what happens if the component function has arguments).
  • Component objects are no longer copy-constructible (but they are still move-able).
  • GCC <5.0.0 is no longer supported.
  • Injector's unsafeGet() method has been removed.
  • When building Fruit from source:
    • You must now explicitly specify CMAKE_BUILD_TYPE (e.g. -DCMAKE_BUILD_TYPE=Release).
    • You must now have boost's hashmap/hashset libraries installed. You can opt-out (and switch back to the STL implementation) by calling CMake with the -DFRUIT_USES_BOOST=False flag; this removes this dependency but it reduces injection performance. In any case, once Fruit is built you don't need to have boost's hashmap/hashset libraries installed in order to compile code using Fruit.
    • If you're running Fruit tests as part of the build, you must now run them via py.test instead of CTest (e.g. you can run them with cd $PATH_TO_FRUIT/tests; py.test-3 -n auto). See CONTRIBUTING.md for more information.

Significant changes

  • Fruit is now supported on Windows, using the MSVC compiler or MinGW's GCC.
  • Fruit now supports binding const& values in PartialComponent::bindInstance (before it only supported binding non-const references)
  • Component installation loops (e.g. a getFooComponent that installs getBarComponent that installs getFooComponent) are now caught and reported as run-time errors, while these bugs would have caused a stack overflow with Fruit 2.x.
  • Significant improvements in performance and executable size (for more details see the Benchmarks page of the wiki)

Other user-visible changes

  • The INJECT macro now has a saner behavior when mistakenly used in a non-public section of the class (before this would have silently made the constructor and everything that followed public until the next public/private/protected specifier). A side-effect of this is that the FruitAssistedTypedef and FruitAnnotatedTypedef typedefs defined by the INJECT macro are now public (instead of private). These are just implementation details of the INJECT macro, they should not be used outside Fruit.
  • Report more readable Fruit-related compile-time errors, including:
    • When a pointer is passed to bindInstance()
    • "Binding not found" errors for abstract classes.
    • When fruit::Required<> is passed multiple times to a fruit::[Normalized]Component<> or when it's not passed as the first template argument.
  • Fix a bug where a clashing binding was ignored instead of causing a compile error.
  • When compiling Fruit with Bazel, the workspace root should now be $FRUIT_SOURCES_DIR/extras/bazel_root instead of $FRUIT_SOURCES_DIR. It's now easier to use Fruit from other projects compiled with Bazel.

Significant internal changes

  • Fruit's end-to-end tests have been ported to python (from a mix of C++ and bash), allowing multiple testcases to be defined in a single test file, and making it possible and easy to share setup/checks between tests, and to have parameterized tests. This helped increase Fruit's test coverage. Fruit 3.0.0 has >350 tests (that become >1200 after expanding parameterized tests).

Installation

See the installation instructions here for how to compile from source and for links to pre-built binary packages for various Linux distributions.

Don't miss a new fruit release

NewReleases is sending notifications on new releases.