Objective-C++ Application
The Objective-C++ Application Plugin provides the tasks, configurations and conventions for a building Objective-C++ application.
Usage
plugins {
id 'dev.nokee.objective-cpp-application'
}
plugins {
id("dev.nokee.objective-cpp-application")
}
Build variants
The Objective-C++ Application Plugin understands the following dimensions. Read the introduction to build variants for more information.
- Operating system family - defaults to the build host
-
The operating system family expresses which environment the application targets. The supported operating system family are Windows, Linux, and macOS.
- Machine architecture - defaults to the build host
-
The machine architecture expresses which architecture the application targets. The supported architecture are Intel instruction set for both 32 and 64 bit often referred as x86 and x86-64.
Both dimensions are configured together as part of the target machine. It expresses which machines the application expects to run. Nokee uses the target machine to decide which toolchain to choose based on availability on the host machine.
The target machine can be configured as follows:
application {
targetMachines = [
machines.linux.x86_64,
machines.windows.x86, machines.windows.x86_64,
machines.macOS.x86_64
]
}
application {
targetMachines.set(listOf(machines.linux.x86_64,
machines.windows.x86, machines.windows.x86_64,
machines.macOS.x86_64))
}
Tasks
The following diagram shows the relationships between tasks added by this plugin.
Variant-dependent Tasks
The Objective-C++ Application Plugin creates tasks based on the variants of the application component. Read the introduction to build variants for more information. The following diagram shows the relationship between variant-dependent tasks.
compileVariantObjectiveCpp
(e.g.compileWindowsObjectiveCpp
andcompileLinuxObjectiveCpp
) - ObjectiveCppCompile-
Depends on: All tasks that contribute source files to the compilation
-
Compiles Objective-C++ source files using the selected compiler.
objectsVariant
(e.g.objectsWindows
andobjectsLinux
) - Task (lifecycle)-
Depends on:
compileVariantObjectiveCpp
-
Aggregates tasks that compile the source files to object files for the specific variant of this application.
linkVariant
(e.g.linkWindows
andlinkLinux
) - LinkExecutable-
Depends on: All tasks which contribute to the link executable, including
linkVariant
andcreateVariant
tasks from projects that are resolved via project dependencies -
Links executable from compiled object files using the selected linker.
executableVariant
(e.g.executableWindows
andexecutableLinux
) - Task (lifecycle)-
Depends on:
linkVariant
-
Aggregates tasks that creates the executable binary for the specific variant of this application.
assembleVariant
(e.g.assembleWindows
andassembleLinux
) - Task (lifecycle)-
Depends on:
linkVariant
Aggregates tasks that assemble the specific variant of this application.
Lifecycle Tasks
The Objective-C++ Application Plugin attaches some of its tasks to the standard lifecycle tasks documented in the Base Plugin chapter - which the Objective-C++ Application Plugin applies automatically:
assemble
- Task (lifecycle)-
Depends on: link task for the current host, if present
-
Aggregate task that assembles the variant of the application for the current host (if present) in the project. This task is added by the Base Plugin.
check
- Task (lifecycle)-
Aggregate task that performs verification tasks, such as running the tests. Some plugins add their own verification task to
check
. This task is added by the Base Plugin. build
- Task (lifecycle)-
Depends on:
check
,assemble
-
Aggregate tasks that perform a full build of the project. This task is added by the Base Plugin.
clean
- Delete-
Deletes the build directory and everything in it, i.e. the path specified by the
Project.getBuildDir()
project property. This task is added by the Base Plugin.
Dependency management
Just like the tasks created by the Objective-C++ Application Plugin, multiple configurations are created based on the variants of the application component. Read the introduction to build variants for more information. The following graph describes the configurations added by the Objective-C++ Application Plugin:
-
The configurations in white are the ones a user should use to declare dependencies
-
The configurations in pink, also known as consumable denoted by (C), are the ones used when a component runs against the library
-
The configurations in blue, also known as resolvable denoted by (R), are internal to the component, for its own use
The following configurations are used to declare dependencies:
implementation
-
Used for declaring implementation dependencies for all variants of the main component. This is where you should declare dependencies of any variants.
variantImplementation
(e.g.windowsImplementation
andlinuxImplementation
) extendsimplementation
-
Used for declaring implementation dependencies for a specific variant of the main component. This is where you should declare dependencies of the specific variant.
The following configurations are used by downstream consumers that depend on the application component:
variantRuntimeElements
(e.g.windowsRuntimeElements
andlinuxRuntimeElements
) extendsvariantImplementation
-
Used for executing the application. This configuration is meant to be used by consumers, to retrieve all the elements necessary to run the application.
The following configurations are used by the application itself:
variantHeaderSearchPaths
(e.g.windowsHeaderSearchPaths
andlinuxHeaderSearchPaths
) extendsvariantImplementation
-
Used for compiling the application. This configuration contains the compile include roots of the application and is therefore used when invoking the Objective-C++ compiler to compile it.
variantLinkLibraries
(e.g.windowsLinkLibraries
andlinuxLinkLibraries
) extendsvariantImplementation
-
Used for linking the application. This configuration contains the libraries of the application and is therefore used when invoking the Objective-C++ linker to link it.
variantRuntimeLibraries
(e.g.windowsRuntimeLibraries
andlinuxRuntimeLibraries
) extendsvariantImplementation
-
Used for executing the application. This configuration contains the runtime libraries of the application.
Conventions
The Objective-C++ Application Plugin adds conventions for sources and tasks, shown below.
Project layout
The Objective-C++ Application Plugin assumes the project layout shown below. None of these directories need to exist or have anything in them. The Objective-C++ Application Plugin will compile whatever it finds and ignore anything missing.
src/main/objcpp
-
Objective-C++ source with extension of
.mm
src/main/headers
-
Headers - headers needed to compile the application
Compile Task
The Objective-C++ Application Plugin adds a ObjectiveCppCompile instance for each variant of the application component to build (e.g. compileWindowsObjectiveCpp
and compileLinuxObjectiveCpp
).
Read the introduction to build variants for more information.
Some of the most common configuration options are shown below.
compilerArgs |
[] |
headerSearchPaths |
|
toolChain |
Link Task
The Objective-C++ Application Plugin adds a LinkExecutable instance for each variant of the application — e.g. linkWindows
and linkLinux
.
Read the introduction to build variants for more information.
Some of the most common configuration options are shown below.
linkedFile |
|
linkerArgs |
[] |
toolChain |