[Notes] [Git][BuildStream/buildstream][issue_640-Build-All] 2 commits: _frontend/cli.py: Added build all functionality



Title: GitLab

Phillip Smyth pushed to branch issue_640-Build-All at BuildStream / buildstream

Commits:

19 changed files:

Changes:

  • buildstream/_frontend/cli.py
    ... ... @@ -169,6 +169,31 @@ def override_main(self, args=None, prog_name=None, complete_var=None,
    169 169
     original_main = click.BaseCommand.main
    
    170 170
     click.BaseCommand.main = override_main
    
    171 171
     
    
    172
    +def get_elements(app):
    
    173
    +    directory = app._main_options.get("directory")
    
    174
    +    project = app.project
    
    175
    +    project_conf = project._project_conf
    
    176
    +    output = []
    
    177
    +
    
    178
    +    # The project is not required to have an element-path
    
    179
    +    element_directory = project_conf.get('element-path')
    
    180
    +            
    
    181
    +    # The project may have a default element defined
    
    182
    +    default_element = project_conf.get("defaults", {}).get("target-element", None)
    
    183
    +            
    
    184
    +    if default_element:
    
    185
    +        return (default_element,)
    
    186
    +
    
    187
    +    directory = os.path.abspath(directory)
    
    188
    +    for root, _, files in os.walk(directory):
    
    189
    +        for file in files:
    
    190
    +            if file.endswith(".bst"):
    
    191
    +                rel_dir = os.path.relpath(root, directory)
    
    192
    +                rel_file = os.path.join(rel_dir, file).lstrip("./")
    
    193
    +                rel_file = rel_file.lstrip(element_directory).lstrip('/')
    
    194
    +                output.append(rel_file)
    
    195
    +    return tuple(output)
    
    196
    +
    
    172 197
     
    
    173 198
     ##################################################################
    
    174 199
     #                          Main Options                          #
    
    ... ... @@ -328,7 +353,10 @@ def build(app, elements, all_, track_, track_save, track_all, track_except, trac
    328 353
         if track_all:
    
    329 354
             track_ = elements
    
    330 355
     
    
    356
    +
    
    331 357
         with app.initialized(session_name="Build"):
    
    358
    +        if not elements:
    
    359
    +            elements = get_elements(app)
    
    332 360
             app.stream.build(elements,
    
    333 361
                              track_targets=track_,
    
    334 362
                              track_except=track_except,
    

  • buildstream/_project.py
    ... ... @@ -226,7 +226,7 @@ class Project():
    226 226
                 'element-path', 'variables',
    
    227 227
                 'environment', 'environment-nocache',
    
    228 228
                 'split-rules', 'elements', 'plugins',
    
    229
    -            'aliases', 'name',
    
    229
    +            'aliases', 'name', 'defaults',
    
    230 230
                 'artifacts', 'options',
    
    231 231
                 'fail-on-overlap', 'shell', 'fatal-warnings',
    
    232 232
                 'ref-storage', 'sandbox', 'mirrors', 'remote-execution',
    

  • buildstream/data/projectconfig.yaml
    ... ... @@ -196,4 +196,11 @@ shell:
    196 196
     
    
    197 197
       # Command to run when `bst shell` does not provide a command
    
    198 198
       #
    
    199
    -  command: [ 'sh', '-i' ]
    \ No newline at end of file
    199
    +  command: [ 'sh', '-i' ]
    
    200
    +
    
    201
    +# Default Targets
    
    202
    +#
    
    203
    +defaults:
    
    204
    +
    
    205
    +  # Set a Default element to build when none are defined 
    
    206
    +  target-element: None

  • tests/frontend/buildcheckout.py
    ... ... @@ -60,6 +60,47 @@ def test_build_checkout(datafiles, cli, strict, hardlinks):
    60 60
         assert os.path.exists(filename)
    
    61 61
     
    
    62 62
     
    
    63
    +@pytest.mark.datafiles(os.path.join(os.path.dirname(
    
    64
    +    os.path.realpath(__file__)),
    
    65
    +    "project_world",
    
    66
    +))
    
    67
    +@pytest.mark.parametrize("strict,hardlinks", [
    
    68
    +    ("strict", "copies"),
    
    69
    +    ("strict", "hardlinks"),
    
    70
    +    ("non-strict", "copies"),
    
    71
    +    ("non-strict", "hardlinks"),
    
    72
    +])
    
    73
    +def test_build_default_all_checkout(datafiles, cli, strict, hardlinks):
    
    74
    +    project = os.path.join(datafiles.dirname, datafiles.basename)
    
    75
    +    checkout = os.path.join(cli.directory, 'checkout')
    
    76
    +
    
    77
    +    # First build it
    
    78
    +    result = cli.run(project=project, args=strict_args(['build'], strict))
    
    79
    +    result.assert_success()
    
    80
    +
    
    81
    +    # Assert that after a successful build, the builddir is empty
    
    82
    +    builddir = os.path.join(cli.directory, 'build')
    
    83
    +    assert os.path.isdir(builddir)
    
    84
    +    assert not os.listdir(builddir)
    
    85
    +
    
    86
    +    # Prepare checkout args
    
    87
    +    checkout_args = strict_args(['checkout'], strict)
    
    88
    +    if hardlinks == "hardlinks":
    
    89
    +        checkout_args += ['--hardlinks']
    
    90
    +    checkout_args += ['target.bst', checkout]
    
    91
    +
    
    92
    +    # Now check it out
    
    93
    +    result = cli.run(project=project, args=checkout_args)
    
    94
    +    result.assert_success()
    
    95
    +
    
    96
    +    # Check that the executable hello file is found in the checkout
    
    97
    +    filename = os.path.join(checkout, 'usr', 'bin', 'hello')
    
    98
    +    assert os.path.exists(filename)
    
    99
    +
    
    100
    +    filename = os.path.join(checkout, 'usr', 'include', 'pony.h')
    
    101
    +    assert os.path.exists(filename)
    
    102
    +
    
    103
    +
    
    63 104
     @pytest.mark.datafiles(DATA_DIR)
    
    64 105
     @pytest.mark.parametrize("strict,hardlinks", [
    
    65 106
         ("non-strict", "hardlinks"),
    

  • tests/frontend/project_world/elements/compose-all.bst
    1
    +kind: compose
    
    2
    +
    
    3
    +depends:
    
    4
    +- filename: import-bin.bst
    
    5
    +  type: build
    
    6
    +- filename: import-dev.bst
    
    7
    +  type: build
    
    8
    +
    
    9
    +config:
    
    10
    +  # Dont try running the sandbox, we dont have a
    
    11
    +  # runtime to run anything in this context.
    
    12
    +  integrate: False

  • tests/frontend/project_world/elements/compose-exclude-dev.bst
    1
    +kind: compose
    
    2
    +
    
    3
    +depends:
    
    4
    +- filename: import-bin.bst
    
    5
    +  type: build
    
    6
    +- filename: import-dev.bst
    
    7
    +  type: build
    
    8
    +
    
    9
    +config:
    
    10
    +  # Dont try running the sandbox, we dont have a
    
    11
    +  # runtime to run anything in this context.
    
    12
    +  integrate: False
    
    13
    +
    
    14
    +  # Exclude the dev domain
    
    15
    +  exclude:
    
    16
    +  - devel

  • tests/frontend/project_world/elements/compose-include-bin.bst
    1
    +kind: compose
    
    2
    +
    
    3
    +depends:
    
    4
    +- filename: import-bin.bst
    
    5
    +  type: build
    
    6
    +- filename: import-dev.bst
    
    7
    +  type: build
    
    8
    +
    
    9
    +config:
    
    10
    +  # Dont try running the sandbox, we dont have a
    
    11
    +  # runtime to run anything in this context.
    
    12
    +  integrate: False
    
    13
    +
    
    14
    +  # Only include the runtim
    
    15
    +  include:
    
    16
    +  - runtime

  • tests/frontend/project_world/elements/import-bin.bst
    1
    +kind: import
    
    2
    +sources:
    
    3
    +- kind: local
    
    4
    +  path: files/bin-files

  • tests/frontend/project_world/elements/import-dev.bst
    1
    +kind: import
    
    2
    +sources:
    
    3
    +- kind: local
    
    4
    +  path: files/dev-files

  • tests/frontend/project_world/elements/rebuild-target.bst
    1
    +kind: compose
    
    2
    +
    
    3
    +build-depends:
    
    4
    +- target.bst

  • tests/frontend/project_world/elements/source-bundle/source-bundle-hello.bst
    1
    +kind: import
    
    2
    +description: the kind of this element must implement generate_script() method
    
    3
    +
    
    4
    +sources:
    
    5
    +- kind: local
    
    6
    +  path: files/source-bundle

  • tests/frontend/project_world/elements/target.bst
    1
    +kind: stack
    
    2
    +description: |
    
    3
    +
    
    4
    +  Main stack target for the bst build test
    
    5
    +
    
    6
    +depends:
    
    7
    +- import-bin.bst
    
    8
    +- compose-all.bst

  • tests/frontend/project_world/files/bar

  • tests/frontend/project_world/files/bin-files/usr/bin/hello
    1
    +#!/bin/bash
    
    2
    +
    
    3
    +echo "Hello !"

  • tests/frontend/project_world/files/build-files/buildstream/build/test
    1
    +test

  • tests/frontend/project_world/files/dev-files/usr/include/pony.h
    1
    +#ifndef __PONY_H__
    
    2
    +#define __PONY_H__
    
    3
    +
    
    4
    +#define PONY_BEGIN "Once upon a time, there was a pony."
    
    5
    +#define PONY_END "And they lived happily ever after, the end."
    
    6
    +
    
    7
    +#define MAKE_PONY(story)  \
    
    8
    +  PONY_BEGIN \
    
    9
    +  story \
    
    10
    +  PONY_END
    
    11
    +
    
    12
    +#endif /* __PONY_H__ */

  • tests/frontend/project_world/files/foo

  • tests/frontend/project_world/files/source-bundle/llamas.txt
    1
    +llamas

  • tests/frontend/project_world/project.conf
    1
    +# Project config for frontend build test
    
    2
    +name: test
    
    3
    +
    
    4
    +element-path: elements



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