You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The ``if`` field is a boolean expression that is evaluated to determine if the dependency should be included. An expression consists of three parts: left value, operator, and right value.
392
392
393
-
The left value could be
393
+
Here's a detailed comparison table for the ``if`` field:
394
394
395
-
- keyword ``idf_version``: the version of ESP-IDF that is used to build the component
396
-
- keyword ``target``: the current target selected for the project
397
-
- a string
398
-
- `environment variables`_
395
+
.. list-table:: Supported Comparison Types
396
+
:header-rows: 1
399
397
400
-
The right value could be
398
+
- - Left Value Type
399
+
- Operators
400
+
- Right Value Type
401
401
402
-
- a string
403
-
- a list of strings
402
+
- - keyword ``idf_version``
403
+
- N/A
404
+
- string that represents :ref:`version ranges <version-range-specifications>`
404
405
405
-
The operator to compare with a string could be
406
+
- - keyword ``target``
407
+
- ``!=``, ``==``
408
+
- string
406
409
407
-
- ``<=``
408
-
- ``<``
409
-
- ``>=``
410
-
- ``>``
411
-
- ``~=``
412
-
- ``~``
413
-
- ``=``
414
-
- ``^``
415
-
- ``!=``
416
-
- ``==``
410
+
- - keyword ``target``
411
+
- ``in``, ``not in``
412
+
- list of strings
417
413
418
-
The operator to compare with a list of strings could be
414
+
- - arbitrary string
415
+
- ``!=``, ``==``
416
+
- string
419
417
420
-
- ``not in``
421
-
- ``in``
418
+
- - arbitrary string
419
+
- ``in``, ``not in``
420
+
- list of strings
421
+
422
+
- - `environment variables`_
423
+
- N/A
424
+
- string that represents :ref:`Version Ranges <version-range-specifications>`
425
+
426
+
- - `environment variables`_
427
+
- ``!=``, ``==``
428
+
- string
429
+
430
+
- - `environment variables`_
431
+
- ``in``, ``not in``
432
+
- list of strings
433
+
434
+
- - `kconfig options`_
435
+
- ``==``, ``!=``
436
+
- string
437
+
438
+
- - `kconfig options`_
439
+
- ``in``, ``not in``
440
+
- list of strings
441
+
442
+
- - `kconfig options`_
443
+
- ``==``, ``!=``, ``<=``, ``<``, ``>=``, ``>``
444
+
- decimal integer or hexadecimal integer (e.g. ``0x1234``)
445
+
446
+
- - `kconfig options`_
447
+
- ``!=``, ``==``
448
+
- boolean (``True``, ``False``)
449
+
450
+
.. versionadded:: 2.2.0
451
+
452
+
- Support `kconfig options`_ as left value (requires ESP-IDF v5.5+)
453
+
- Support ``boolean``, ``integer`` and ``hexadecimal integer`` data types for `kconfig options`_
454
+
455
+
.. warning::
456
+
457
+
Since kconfig supports data types, you MUST use double quotes for strings while comparing with kconfig options. Otherwise, the component manager will treat the value as an integer, and raise an error if the value is not parsable as an integer.
458
+
459
+
Double quotes are not required for strings when not comparing with kconfig options, but we recommend using them for consistency.
460
+
461
+
.. warning::
462
+
463
+
If you specified `environment variables`_ as the left value of the if clause, and the environment variable is not set, an error will be raised.
464
+
465
+
If you specified `kconfig options`_ as the left value of the if clause, but the kconfig is included in your project, or components, an error will be raised.
422
466
423
467
To make a complex boolean expression, you can use nested parentheses with boolean operators ``&&`` and ``||``.
424
468
@@ -429,22 +473,22 @@ To make a complex boolean expression, you can use nested parentheses with boolea
429
473
version: "~1.0.0"
430
474
rules:
431
475
- if: "idf_version >=3.3,<5.0"
432
-
- if: "target in [esp32, esp32c3]"
476
+
- if: target in ["esp32", "esp32c3"]
433
477
# the above two conditions equals to
434
-
- if: idf_version >=3.3,<5.0 && target in [esp32, esp32c3]
478
+
- if: idf_version >=3.3,<5.0 && target in ["esp32", "esp32c3"]
435
479
436
-
The left value of the if clause could be `environment variables`_. If the environment variable is not set, an error will be raised.
480
+
.. hint::
437
481
438
-
One possible use-case is to test it in the CI/CD pipeline. For example:
482
+
One possible use-case of `environment variables`_ is to test it in the CI/CD pipeline. For example:
439
483
440
-
.. code:: yaml
484
+
.. code:: yaml
441
485
442
-
dependencies:
443
-
optional_component:
444
-
matches:
445
-
- if: "$TESTING_COMPONENT in [foo, bar]"
486
+
dependencies:
487
+
optional_component:
488
+
matches:
489
+
- if: "$TESTING_COMPONENT in [foo, bar]"
446
490
447
-
The dependency will only be included when the environment variable ``TESTING_COMPONENT`` is set to ``foo`` or ``bar``.
491
+
The dependency will only be included when the environment variable ``TESTING_COMPONENT`` is set to ``foo`` or ``bar``.
448
492
449
493
``version`` (if clause)
450
494
-----------------------
@@ -472,6 +516,10 @@ Environment Variables
472
516
473
517
Environment variables are not allowed in manifests when uploading components to the ESP Component Registry.
474
518
519
+
.. warning::
520
+
521
+
Environment variables should only contain alphanumeric characters and underscores, and should not start with a number.
522
+
475
523
You can use environment variables for the attributes that support them. The component manager will replace the environment variables with their values. Use the following syntax:
476
524
477
525
- ``$VAR``
@@ -481,6 +529,61 @@ If you need to use a literal dollar sign (``$``), escape it with another dollar
481
529
482
530
.. _local-source:
483
531
532
+
Kconfig Options
533
+
===============
534
+
535
+
You can use Kconfig options for the attributes that support them. All Kconfig options are prefixed with ``$kconfig.``, and don't have to include the ``CONFIG_`` prefix.
536
+
537
+
For example, to compare with the Kconfig option ``CONFIG_MY_OPTION``, use ``$kconfig.MY_OPTION``.
538
+
539
+
Besides, only Kconfig options that are defined in the ESP-IDF project and the direct dependency components are supported. For example
This works, since ``CONFIG_BOOTLOADER_LOG_LEVEL_WARN`` is defined in the ESP-IDF project.
550
+
551
+
.. code:: yaml
552
+
553
+
dependencies:
554
+
example/cmp:
555
+
version: "*"
556
+
matches:
557
+
- if: "$kconfig.MY_OPTION == True"
558
+
559
+
This will not work, since ``CONFIG_MY_OPTION`` is not defined in the ESP-IDF project.
560
+
561
+
.. code:: yaml
562
+
563
+
dependencies:
564
+
espressif/mdns:
565
+
version: "1.8.1"
566
+
567
+
example/cmp:
568
+
version: "*"
569
+
matches:
570
+
- if: "$kconfig.MDNS_MAX_SERVICES == 10"
571
+
572
+
This works, since ``CONFIG_MDNS_MAX_SERVICES`` is defined in the ``espressif/mdns`` component, and ``espressif/mdns`` is a direct dependency of your project.
573
+
574
+
.. code:: yaml
575
+
576
+
dependencies:
577
+
cmp_a:
578
+
version: "*"
579
+
580
+
example/cmp:
581
+
version: "*"
582
+
matches:
583
+
- if: "$kconfig.OPTION_FROM_CMP_B == True"
584
+
585
+
This will not work, even if ``CONFIG_OPTION_FROM_CMP_B`` is defined in the ``cmp_b`` component, and ``cmp_a`` depends on ``cmp_b``, since `cmp_b` is not a direct dependency of your project.
0 commit comments