Introducing build variants

Native projects can typically produce several different binaries, such as debug or release ones, or ones that target particular platforms and processor architectures. Nokee manages this through the concepts of dimensions and variants.

A dimension is simply a category, where each category is orthogonal to the rest. For example, the "build type" dimension is a category that includes debug and release. The "architecture" dimension covers processor architectures like x86-64 and PowerPC. The "linkage" dimension covers executable, shared, static, and bundle.

A variant is a combination of values for these dimensions, consisting of exactly one value for each dimension. You might have a "debug x86-64" or a "release PowerPC" variant.

Nokee has built-in support for several dimensions and several values within each dimension.

API vs implementation

The plugin exposes two configurations that can be used to declare dependencies: api and implementation. The api configuration should be used to declare dependencies which are exported by the library API, whereas the implementation configuration should be used to declare dependencies which are internal to the component.

Example 1. Adding dependencies
build.gradle
library {
    dependencies {
        api "io.qt:core:5.1"
        implementation "io.qt:network:5.1"
    }
}
build.gradle.kts
library {
    dependencies {
        api("io.qt:core:5.1")
        implementation("io.qt:network:5.1")
    }
}

Dependencies appearing in the api configurations will be transitively exposed to consumers of the library, and as such will appear on the compile include root and link libraries of consumers. Dependencies found in the implementation configuration will, on the other hand, not be exposed to consumers, and therefore not leak into the consumer’s compile include root and link libraries. This comes with several benefits:

  • dependencies do not leak into the compile include roots and link libraries of consumers, so they can never accidentally depend on a transitive dependency

  • faster compilation thanks to the reduced include roots and link libraries

  • fewer recompilations when implementation dependencies change since the consumer would not need to be recompiled

Supported Toolchains

Nokee has general support for the three major tool chains on major operating system: Clang [1], GCC [2] and Visual C++ [3] (Windows-only). GCC and Clang installed using Macports and Homebrew have been reported to work fine, but this isn’t tested continuously.

Windows

To build on Windows, install a compatible version of Visual Studio. The native plugins will discover the Visual Studio installations and select the latest version. There is no need to mess around with environment variables or batch scripts. It works fine from a Cygwin shell or the Windows command-line.

Alternatively, we can install Cygwin or MinGW with GCC. Clang isn’t supported currently.

macOS

To build on macOS, install Xcode. The native plugins will discover the Xcode installation using the system PATH.

The native plugins also work with GCC and Clang installed with Macports or Homebrew [4]. To use one of the Macports or Homebrew, you will need to add Macports/Homebrew to the system PATH.

Linux

To build on Linux, install a compatible version of GCC or Clang. The native plugins will discover GCC or Clang using the system PATH.


1. Installed with Xcode on macOS
2. Installed through Cygwin and MinGW for 32- and 64-bits architecture on Windows
3. Installed with Visual Studio 2010 to 2019
4. Macports and Homebrew installation of GCC and Clang is not officially supported