Versioning
The IDF Component Manager enforces a strict versioning scheme on all components it manages. Component versioning allows ESP-IDF applications to have more fine-grained control on what features and bug fixes are included in a particular managed component. Furthermore, the IDF Component Manager implements a version solver that allows ESP-IDF applications to specify multiple versions based on a range of versions for a particular component dependency. The version solver will automatically select the most appropriate version of the component based on a predefined set of rules. This document describes the versioning scheme and the rules used by the version solver.
Versioning Scheme
A managed component’s version number contains the following fields:
major.minor.patch~revision-prerelease+build
Field |
Optional |
Description |
---|---|---|
Major |
N |
There are incompatible API changes between two major versions. |
Minor |
N |
There are new features with compatible APIs between two minor versions. |
Patch |
N |
There are only bug fixes between two patch versions. |
Revision |
Y |
|
Pre-release |
Y |
|
Build |
Y |
|
A full version number containing all fields such as 0.1.2~3-dev4.7+git5.66
would be parsed into the following:
major
:int
0minor
:int
1patch
:int
2revision
:int
3prerelease
: (str
“dev4”,int
7)build
: (str
“git5”,int
66)
Note
CLI commands compote component pack
and compote component upload
accept --version=git
to read version from the current git tag. However, ~
is not allowed in git tags. Therefore, you must replace ~
with .
in the git tag if your version contains revision. For example, for version 0.1.2~3
use git tag 0.1.2.3
or v0.1.2.3
.
Version Precedence
When the version solver compares two different version numbers, the solver determines the preeminent version by comparing each field of the two versions from left to right. The version with the leftmost larger field will be the preeminent version. For example:
Expression |
Explanation |
---|---|
|
First compare the |
|
|
|
|
|
|
|
The default value of the revision field is |
|
|
|
|
|
|
|
|
|
|
Warning
Build version is a special case. According to semantic versioning, build
must be ignored when determining version precedence. If two version numbers only differ in the build
field, the comparison will yield an unexpected result.
Range Specifications
When specifying a range of versions for a component dependency (in an idf_component.yml), the range specification should be one of the following:
A clause
A comma separated list of clauses (No extra spaces)
Clauses
A typical clause includes one operator and one version number. If the clause does not have an operator, the clause will default to the ==
operator. For example, the clause 1.2.3
is equivalent to the clause ==1.2.3
.
Comparison Clause
Comparison clauses use one of the following operators: >=
, >
, ==
, <
, <=
, !=
For more detailed information regarding comparing two version numbers, please refer to the earlier section
Wildcard Clause
A wildcard clause uses the symbol *
in one or more fields of the version number. Usually the *
symbol means it could be replaced with anything in this field.
Warning
You may only use the *
symbol in the major
, minor
, and patch
field.
You may also use the wildcard symbol in the comparison clauses, which make them into wildcard clauses. For example:
==0.1.*
is equal to>=0.1.0,<0.2.0
.>=0.1.*
is equal to>=0.1.0
.==1.*
or==1.*.*
is equal to>=1.0.0,<2.0.0
.>=1.*
or>=1.*.*
is equal to>=1.0.0
.*
,==*
or>=*
is equal to>=0.0.0
.
Compatible Release Clause
Compatible release clauses always use the ~=
operator. It matches the version that is expected to be compatible with the specified version.
For example:
~=1.2.3-alpha4
is equal to>=1.2.3-alpha4,==1.2.*
.~=1.2.3
is equal to>=1.2.3,==1.2.*
.~=1.2
is equal to>=1.2.0,==1.*
.~=1
is equal to>=1.0,==1.*
.
Compatible Minor Release Clause
Compatible minor release clauses always use the ~
operator. Usually it allows patch-level changes, but it would also allow minor level changes if only a major version is specified.
For example:
~1.2.3-alpha4
is equal to>=1.2.3-alpha4,==1.2.*
.~1.2.3
is equal to>=1.2.3,==1.2.*
.~1.2
is equal to>=1.2.0,==1.2.*
.~1
is equal to>=1.0,==1.*
.
Compatible Major Release Clause
Compatible major release clauses always use the ^
operator. It allows the changes that do not modify the left-most non-zero version.
For example:
^1.2.3-alpha4
is equal to>=1.2.3-alpha4,==1.*
.^1.2.3
is equal to>=1.2.3,==1.*
.^1.2
is equal to>=1.2.0,==1.*
.^1
is equal to>=1.0,==1.*
.^0.2.3-alpha4
is equal to>=0.2.3-alpha4,==0.2.*
.^0.2.3
is equal to>=0.2.3,==0.2.*
.^0.2
is equal to>=0.2.0,==0.2.*
.^0
is equal to>=0.0.0,==0.0.0*
.
Version Solving
An ESP-IDF project with component dependencies will specify those dependencies via one or more manifest files (i.e., idf_component.yml
), where each dependency will have a range representing the component version(s) of that dependency. Version solving is the process of collecting all component dependencies of an ESP-IDF project, and calculating the most appropriate component version of each dependency. The version solving process generally involves the following steps:
Collect all the local manifest files from your main component and subcomponents.
Collect all the root dependencies from the manifest files.
Recursively collect all the available versions of each root dependency.
Calculate the version solving solution.