[Notes] [Git][BuildStream/buildstream][master] 3 commits: _project.py: Fix option resolution in element & source overrides



Title: GitLab

Tristan Van Berkom pushed to branch master at BuildStream / buildstream

Commits:

4 changed files:

Changes:

  • buildstream/_project.py
    ... ... @@ -598,7 +598,10 @@ class Project():
    598 598
             # any conditionals specified for project option declarations,
    
    599 599
             # or conditionally specifying the project name; will be ignored.
    
    600 600
             #
    
    601
    +        # Don't forget to also resolve options in the element and source overrides.
    
    601 602
             output.options.process_node(config)
    
    603
    +        output.options.process_node(output.element_overrides)
    
    604
    +        output.options.process_node(output.source_overrides)
    
    602 605
     
    
    603 606
             # Load base variables
    
    604 607
             output.base_variables = _yaml.node_get(config, Mapping, 'variables')
    

  • tests/format/option-overrides/element.bst
    1
    +kind: autotools

  • tests/format/option-overrides/project.conf
    1
    +# Test case ensuring that we can use options
    
    2
    +# in the element overrides.
    
    3
    +#
    
    4
    +name: test
    
    5
    +
    
    6
    +options:
    
    7
    +  arch:
    
    8
    +    type: arch
    
    9
    +    description: architecture
    
    10
    +    values: [i686, x86_64]
    
    11
    +
    
    12
    +elements:
    
    13
    +  autotools:
    
    14
    +    variables:
    
    15
    +      (?):
    
    16
    +      - arch == 'i686':
    
    17
    +          conf-global: --host=i686-unknown-linux-gnu
    
    18
    +      - arch == 'x86_64':
    
    19
    +          conf-global: --host=x86_64-unknown-linux-gnu

  • tests/format/optionoverrides.py
    1
    +import os
    
    2
    +import pytest
    
    3
    +from buildstream import _yaml
    
    4
    +from tests.testutils.runcli import cli
    
    5
    +
    
    6
    +# Project directory
    
    7
    +DATA_DIR = os.path.dirname(os.path.realpath(__file__))
    
    8
    +
    
    9
    +
    
    10
    +@pytest.mark.datafiles(DATA_DIR)
    
    11
    +@pytest.mark.parametrize("arch", [('i686'), ('x86_64')])
    
    12
    +def test_override(cli, datafiles, arch):
    
    13
    +    project = os.path.join(datafiles.dirname, datafiles.basename, 'option-overrides')
    
    14
    +
    
    15
    +    bst_args = ['--option', 'arch', arch]
    
    16
    +    bst_args += [
    
    17
    +        'show',
    
    18
    +        '--deps', 'none',
    
    19
    +        '--format', '%{vars}',
    
    20
    +        'element.bst'
    
    21
    +    ]
    
    22
    +    result = cli.run(project=project, silent=True, args=bst_args)
    
    23
    +    result.assert_success()
    
    24
    +
    
    25
    +    # See the associated project.conf for the expected values
    
    26
    +    expected_value = '--host={}-unknown-linux-gnu'.format(arch)
    
    27
    +
    
    28
    +    loaded = _yaml.load_data(result.output)
    
    29
    +    assert loaded['conf-global'] == expected_value



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]