Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
project = u'Common Package Specification'
copyright = u'2023, Matthew Woehlke'

release = '.'.join(map(str, [0, 9, 0]))
release = '.'.join(map(str, [0, 9, 1]))
version = re.match('\\d+\.\\d+', release).group(0)

language = 'en'
Expand Down
108 changes: 108 additions & 0 deletions schema.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ Typical components include libraries and executables.
A |configuration| holds attributes
that are specific to a particular configuration of a |component|.

:object:`Environment-Variable`\ :hidden:`(Object)`
--------------------------------------------------

An |envvar| holds attributes
that describe an environment variable alteration.

Attributes
''''''''''

Expand All @@ -43,6 +49,34 @@ Attribute names are case insensitive,
although it is recommended that ``.cps`` files
use the capitalization as shown.

:attribute:`Action`
-------------------

:Type: |string| (restricted)
:Applies To: |envvar|
:Required: No

This specifies how an environment variable's specified values
are combined with any existing values of the environment variable.
Note that "existing values" may also refer to values
specified for the same environment variable by other components.

- :string:`prepend`

The specified `Values`_ are inserted before
the environment variable's existing value(s), if any.
This is the default behavior.

- :string:`append`

The specified `Values`_ are inserted after
the environment variable's existing value(s), if any.

- :string:`replace`

The specified `Values`_ replace
the environment variable's existing value(s), if any.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at Meson's environment variable handling, this all looks pretty similar to what we do. I've been convinced that is a sane mechanism.

One thing that I'd like to see is the ability to completely unset an environment variable, since some tools treat an empty environment variable and an unset one differently. I see two ways that could be achieved, replace could be nullable, so that replace: null means "clear this from the environment", or there could be a :bool:'clear' attribute.

:attribute:`C-Runtime-Vendor`
-----------------------------

Expand Down Expand Up @@ -264,6 +298,26 @@ even for Z > Y
(with the understanding that, in such cases, the tool
may miss non-critical information that the CPS provided).

:attribute:`Deduplicate`
------------------------

:Type: |bool| :separator:`or` |string| (restricted)
:Applies To: |envvar|
:Required: No

Specifies whether duplicate values
in the environment variable should be removed.
(Values are separated by the specified `Separator`_.)

If enabled, deduplication takes place *after*
the environment variable has been modified.
If set to :string:`keep-last`,
only the right-most value is retained.
Otherwise (|true| or :string:`keep-first`)
only the left-most value is retained.

The default is |false|.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most tools I'm familiar with keep the last definition of something, not the first. Python's argparse works this way, bash and zsh do this with env (so do Python, Rust, and C/C++) vars (export FOO="1" FOO="2"; echo $FOO will print 2), so I would expect true == 'keep-last', rather than keep-first? But maybe it makes sense to just have this be a union of strings none | keep-first | keep-last with a default of none, since that's simpler and less likely to be misinterpreted?


:attribute:`Default-Components`
-------------------------------

Expand Down Expand Up @@ -575,6 +629,36 @@ Values are a valid |requirement| object or |null|
(equivalent to an empty |requirement| object)
describing the package required.

:attribute:`Runtime-Environment`
--------------------------------

:Type: |map| to [ |string-list| :separator:`or` |envvar| ]
:Applies To: |component|, |configuration|
:Required: No

Specifies environment variables that should be set
when executing an application that uses the component.
Keys are the environment variable names.

If a value is a |string-list|,
the value is treated as the `Values`_ attribute
of an |envvar| object
whose other attributes are unspecified.

:attribute:`Separator`
----------------------

:Type: |string|
:Applies To: |envvar|
:Required: No

Specifies what character or sequence of characters
is used to join multiple values of an environment variable.

If not specified, the default
is :string:`;` on Windows
or :string:`:` otherwise.

:attribute:`Type`
-----------------

Expand Down Expand Up @@ -620,6 +704,22 @@ but does not otherwise map directly to a component
may use a symbolic component
to indicate availability of the feature to users.

:attribute:`Values`
-------------------

:Type: |string-list|
:Applies To: |envvar|
:Required: Yes

Specifies the list of values
to assign to the environment variable.
Values are assigned according to the specified `Action`_
and are joined by the specified `Separator`_.

If a value starts with ``@prefix@``,
the package's install prefix is substituted
(see `Package Searching`_).

:attribute:`Version` :applies-to:`(Package)`
--------------------------------------------

Expand Down Expand Up @@ -732,6 +832,12 @@ Notes

.. |null| replace:: :keyword:`null`

.. |bool| replace:: :type:`boolean`

.. |true| replace:: :keyword:`true`

.. |false| replace:: :keyword:`false`

.. |string| replace:: :type:`string`

.. |list| replace:: :type:`list`
Expand All @@ -752,6 +858,8 @@ Notes

.. |configuration| replace:: :object:`configuration`

.. |envvar| replace:: :object:`environment-variable`

.. ... .. ... .. ... .. ... .. ... .. ... .. ... .. ... .. ... .. ... .. ... ..

.. kate: hl reStructuredText