[Notes] [Git][BuildStream/buildstream][willsalmon/simpleOutSource] 4 commits: Add conf-root variable to builds



Title: GitLab

Will Salmon pushed to branch willsalmon/simpleOutSource at BuildStream / buildstream

Commits:

29 changed files:

Changes:

  • buildstream/buildelement.py
    ... ... @@ -23,6 +23,38 @@ BuildElement - Abstract class for build elements
    23 23
     The BuildElement class is a convenience element one can derive from for
    
    24 24
     implementing the most common case of element.
    
    25 25
     
    
    26
    +Built-in functionality
    
    27
    +----------------------
    
    28
    +
    
    29
    +The BuildElement base class provides built in functionality that could be overridden by the
    
    30
    +individual plugins.
    
    31
    +
    
    32
    +This section will give a brief summary of how some of the common features work, some of them or the variables they
    
    33
    +use will be further detailed in the following sections.
    
    34
    +
    
    35
    +* Location for running commands
    
    36
    +
    
    37
    + The ``command-subdir`` variable sets where the build commands will be executed, if the directory dose not exist it
    
    38
    + will be created, it is defined relative to the buildroot.
    
    39
    +
    
    40
    +* Location for configuring the project
    
    41
    +
    
    42
    + The ``conf-root`` is defined by default as ``./`` and is the location that specific build element can use to look
    
    43
    + for build configuration files, currently autotools and cmake use this.
    
    44
    +
    
    45
    + The configuration commands are run in ``command-subdir`` and by default ``conf-root`` is ``./`` so if
    
    46
    + ``conf-root`` is not set the configuration files in ``command-subdir`` will be used.
    
    47
    +
    
    48
    + By setting ``source-directory`` to ``"%{build-root}/Source"`` and your source elements ``directory`` variable to
    
    49
    + ``Source`` then the configuration files in the directory ``source-subdir`` with-in your Source will be used.
    
    50
    + However the location where your configuration command will be run will still be wherever you set your
    
    51
    + ``command-subdir`` to be.
    
    52
    +
    
    53
    +* Install Location
    
    54
    +
    
    55
    +  You should not change the ``install-root`` variable as it is a special writeable location in the sandbox but it is
    
    56
    +  useful when writing custom install instructions as it may need to be supplied as the ``DESTDIR``, please see the
    
    57
    +  cmake build element for example.
    
    26 58
     
    
    27 59
     Abstract method implementations
    
    28 60
     -------------------------------
    

  • buildstream/data/projectconfig.yaml
    ... ... @@ -38,6 +38,9 @@ variables:
    38 38
       # normally staged
    
    39 39
       build-root: /buildstream/%{project-name}/%{element-name}
    
    40 40
     
    
    41
    +  # Indicates where the build system should look for configuration files  
    
    42
    +  conf-root: .
    
    43
    +  
    
    41 44
       # Indicates the build installation directory in the sandbox
    
    42 45
       install-root: /buildstream-install
    
    43 46
     
    

  • buildstream/plugins/elements/autotools.yaml
    ... ... @@ -6,11 +6,11 @@ variables:
    6 6
         export NOCONFIGURE=1;
    
    7 7
     
    
    8 8
         if [ -x %{conf-cmd} ]; then true;
    
    9
    -    elif [ -x autogen ]; then ./autogen;
    
    10
    -    elif [ -x autogen.sh ]; then ./autogen.sh;
    
    11
    -    elif [ -x bootstrap ]; then ./bootstrap;
    
    12
    -    elif [ -x bootstrap.sh ]; then ./bootstrap.sh;
    
    13
    -    else autoreconf -ivf;
    
    9
    +    elif [ -x %{conf-root}/autogen ]; then %{conf-root}/./autogen;
    
    10
    +    elif [ -x %{conf-root}/autogen.sh ]; then %{conf-root}/./autogen.sh;
    
    11
    +    elif [ -x %{conf-root}/bootstrap ]; then %{conf-root}/./bootstrap;
    
    12
    +    elif [ -x %{conf-root}/bootstrap.sh ]; then %{conf-root}/./bootstrap.sh;
    
    13
    +    else autoreconf -ivf %{conf-root};
    
    14 14
         fi
    
    15 15
     
    
    16 16
       # Project-wide extra arguments to be passed to `configure`
    
    ... ... @@ -22,7 +22,8 @@ variables:
    22 22
       # For backwards compatibility only, do not use.
    
    23 23
       conf-extra: ''
    
    24 24
     
    
    25
    -  conf-cmd: ./configure
    
    25
    +  conf-cmd: "%{conf-root}/./configure"
    
    26
    +  
    
    26 27
       conf-args: |
    
    27 28
     
    
    28 29
         --prefix=%{prefix} \
    

  • buildstream/plugins/elements/cmake.yaml
    ... ... @@ -23,7 +23,7 @@ variables:
    23 23
     
    
    24 24
       cmake: |
    
    25 25
     
    
    26
    -    cmake -B%{build-dir} -H. -G"%{generator}" %{cmake-args}
    
    26
    +    cmake -B%{build-dir} -H"%{conf-root}" -G"%{generator}" %{cmake-args}
    
    27 27
     
    
    28 28
       make: cmake --build %{build-dir} -- ${JOBS}
    
    29 29
       make-install: env DESTDIR="%{install-root}" cmake --build %{build-dir} --target install
    

  • buildstream/source.py
    ... ... @@ -20,6 +20,19 @@
    20 20
     Source - Base source class
    
    21 21
     ==========================
    
    22 22
     
    
    23
    +Built-in functionality
    
    24
    +----------------------
    
    25
    +
    
    26
    +The Source base class provides built in functionality that could be overridden by the
    
    27
    +individual plugins.
    
    28
    +
    
    29
    +* Directory
    
    30
    +
    
    31
    +  The ``directory`` variable can be set for all sources of a type in project.conf
    
    32
    +  or per source within a element.
    
    33
    +
    
    34
    +  This sets the location with in the build root that the content of the source will be
    
    35
    +  loaded in to. If the location dose not exist it will be created.
    
    23 36
     
    
    24 37
     .. _core_source_abstract_methods:
    
    25 38
     
    

  • doc/examples/cmake/elements/base.bst
    1
    +kind: stack
    
    2
    +description: Base stack
    
    3
    +
    
    4
    +depends:
    
    5
    +- base/alpine.bst

  • doc/examples/cmake/elements/base/alpine.bst
    1
    +kind: import
    
    2
    +description: |
    
    3
    +
    
    4
    +    Alpine Linux base runtime
    
    5
    +
    
    6
    +sources:
    
    7
    +- kind: tar
    
    8
    +
    
    9
    +  # This is a post doctored, trimmed down system image
    
    10
    +  # of the Alpine linux distribution.
    
    11
    +  #
    
    12
    +  url: alpine:integration-tests-base.v1.x86_64.tar.xz
    
    13
    +  ref: 3eb559250ba82b64a68d86d0636a6b127aa5f6d25d3601a79f79214dc9703639

  • doc/examples/cmake/elements/hello.bst
    1
    +depends:
    
    2
    +- base.bst
    
    3
    +description: |2
    
    4
    +
    
    5
    +  Hello world example from cmake
    
    6
    +kind: cmake
    
    7
    +sources:
    
    8
    +- kind: local
    
    9
    +  path: files/hello
    
    10
    +  directory: Source
    
    11
    +variables:
    
    12
    +  command-subdir: build
    
    13
    +  conf-root: "%{build-root}/Source"
    
    14
    +

  • doc/examples/cmake/files/hello/CMakeLists.txt
    1
    +
    
    2
    +# Set the minimum version of CMake that can be used
    
    3
    +# To find the cmake version run
    
    4
    +# $ cmake --version
    
    5
    +cmake_minimum_required(VERSION 2.8)
    
    6
    +
    
    7
    +# Set the project name
    
    8
    +project (hello_buildstreams C)
    
    9
    +
    
    10
    +# Add an executable
    
    11
    +add_executable(hello_buildstream main.c)
    
    12
    +
    
    13
    +
    
    14
    +install(TARGETS hello_buildstream DESTINATION /bin) 

  • doc/examples/cmake/files/hello/main.c
    1
    +#include <stdio.h>
    
    2
    +int main()
    
    3
    +{
    
    4
    +   // printf() displays the string inside quotation
    
    5
    +   printf("Hello, World!\n");
    
    6
    +   return 0;
    
    7
    +}

  • doc/examples/cmake/project.conf
    1
    +# Unique project name
    
    2
    +name: cmake-out-of-source-build 
    
    3
    +
    
    4
    +# Required BuildStream format version
    
    5
    +format-version: 9
    
    6
    +
    
    7
    +# Subdirectory where elements are stored
    
    8
    +element-path: elements
    
    9
    +
    
    10
    +# Define some aliases for the tarballs we download
    
    11
    +aliases:
    
    12
    +  alpine: https://gnome7.codethink.co.uk/tarballs/
    
    13
    +  gnu: https://ftp.gnu.org/gnu/automake/

  • doc/examples/out-of-source-autotool-in-source-tree/elements/base.bst
    1
    +kind: stack
    
    2
    +description: Base stack
    
    3
    +
    
    4
    +depends:
    
    5
    +- base/alpine.bst

  • doc/examples/out-of-source-autotool-in-source-tree/elements/base/alpine.bst
    1
    +kind: import
    
    2
    +description: |
    
    3
    +
    
    4
    +    Alpine Linux base runtime
    
    5
    +
    
    6
    +sources:
    
    7
    +- kind: tar
    
    8
    +
    
    9
    +  # This is a post doctored, trimmed down system image
    
    10
    +  # of the Alpine linux distribution.
    
    11
    +  #
    
    12
    +  url: alpine:integration-tests-base.v1.x86_64.tar.xz
    
    13
    +  ref: 3eb559250ba82b64a68d86d0636a6b127aa5f6d25d3601a79f79214dc9703639

  • doc/examples/out-of-source-autotool-in-source-tree/elements/hello.bst
    1
    +depends:
    
    2
    +- base.bst
    
    3
    +description: |2
    
    4
    +
    
    5
    +  Hello world example from automake
    
    6
    +kind: autotools
    
    7
    +sources:
    
    8
    +- directory: SourB
    
    9
    +  kind: tar
    
    10
    +  ref: 80da43bb5665596ee389e6d8b64b4f122ea4b92a685b1dbd813cd1f0e0c2d83f
    
    11
    +  url: gnu:automake-1.16.tar.gz
    
    12
    +variables:
    
    13
    +  conf-root: "%{build-root}/SourB/doc/amhello"
    
    14
    +  command-subdir: build
    
    15
    +

  • doc/examples/out-of-source-autotool-in-source-tree/project.conf
    1
    +# Unique project name
    
    2
    +name: Out-of-Source-builds-in-autotool-in-Source-tree
    
    3
    +
    
    4
    +# Required BuildStream format version
    
    5
    +format-version: 9
    
    6
    +
    
    7
    +# Subdirectory where elements are stored
    
    8
    +element-path: elements
    
    9
    +
    
    10
    +# Define some aliases for the tarballs we download
    
    11
    +aliases:
    
    12
    +  alpine: https://gnome7.codethink.co.uk/tarballs/
    
    13
    +  gnu: https://ftp.gnu.org/gnu/automake/

  • doc/examples/out-of-source-build-helloworld/elements/base.bst
    1
    +kind: stack
    
    2
    +description: Base stack
    
    3
    +
    
    4
    +depends:
    
    5
    +- base/alpine.bst

  • doc/examples/out-of-source-build-helloworld/elements/base/alpine.bst
    1
    +kind: import
    
    2
    +description: |
    
    3
    +
    
    4
    +    Alpine Linux base runtime
    
    5
    +
    
    6
    +sources:
    
    7
    +- kind: tar
    
    8
    +
    
    9
    +  # This is a post doctored, trimmed down system image
    
    10
    +  # of the Alpine linux distribution.
    
    11
    +  #
    
    12
    +  url: alpine:integration-tests-base.v1.x86_64.tar.xz
    
    13
    +  ref: 3eb559250ba82b64a68d86d0636a6b127aa5f6d25d3601a79f79214dc9703639

  • doc/examples/out-of-source-build-helloworld/elements/hello.bst
    1
    +depends:
    
    2
    +- base.bst
    
    3
    +description: |2
    
    4
    +
    
    5
    +  Hello world example from automake
    
    6
    +kind: autotools
    
    7
    +sources:
    
    8
    +- directory: Source
    
    9
    +  kind: local
    
    10
    +  path: files/hello
    
    11
    +variables:
    
    12
    +  conf-root: "%{build-root}/Source"
    
    13
    +  command-subdir: build
    
    14
    +

  • doc/examples/out-of-source-build-helloworld/files/hello/Makefile.am
    1
    +SUBDIRS = src

  • doc/examples/out-of-source-build-helloworld/files/hello/README

  • doc/examples/out-of-source-build-helloworld/files/hello/configure.ac
    1
    +AC_INIT([helloworld], [0.1], [will salmon codethink co uk])
    
    2
    +AM_INIT_AUTOMAKE([-Wall -Werror foreign])
    
    3
    +AC_PROG_CC
    
    4
    +AC_CONFIG_FILES([Makefile
    
    5
    +		 src/Makefile])
    
    6
    +AC_OUTPUT

  • doc/examples/out-of-source-build-helloworld/files/hello/src/Makefile.am
    1
    +bin_PROGRAMS = hello
    
    2
    +hello_SOURCES = hello.c libhello.c

  • doc/examples/out-of-source-build-helloworld/files/hello/src/hello.c
    1
    +/*
    
    2
    + * hello.c - Simple hello program
    
    3
    + */
    
    4
    +#include <stdio.h>
    
    5
    +#include <libhello.h>
    
    6
    +
    
    7
    +int main(int argc, char *argv[])
    
    8
    +{
    
    9
    +  const char *person = NULL;
    
    10
    +
    
    11
    +  if (argc > 1)
    
    12
    +    person = argv[1];
    
    13
    +
    
    14
    +  if (person)
    
    15
    +    hello(person);
    
    16
    +  else
    
    17
    +    hello("stranger");
    
    18
    +
    
    19
    +  return 0;
    
    20
    +}

  • doc/examples/out-of-source-build-helloworld/files/hello/src/libhello.c
    1
    +/*
    
    2
    + * libhello.c - The hello library
    
    3
    + */
    
    4
    +#include <stdio.h>
    
    5
    +
    
    6
    +void hello(const char *person)
    
    7
    +{
    
    8
    +  printf("Hello %s\n", person);
    
    9
    +}

  • doc/examples/out-of-source-build-helloworld/files/hello/src/libhello.h
    1
    +/*
    
    2
    + * libhello.h - The hello library
    
    3
    + */
    
    4
    +
    
    5
    +/*
    
    6
    + * A function to say hello to @person
    
    7
    + */
    
    8
    +void hello(const char *person);

  • doc/examples/out-of-source-build-helloworld/project.conf
    1
    +# Unique project name
    
    2
    +name: our-of-source-build-helloworld 
    
    3
    +
    
    4
    +# Required BuildStream format version
    
    5
    +format-version: 9
    
    6
    +
    
    7
    +# Subdirectory where elements are stored
    
    8
    +element-path: elements
    
    9
    +
    
    10
    +# Define some aliases for the tarballs we download
    
    11
    +aliases:
    
    12
    +  alpine: https://gnome7.codethink.co.uk/tarballs/
    
    13
    +  gnu: https://ftp.gnu.org/gnu/automake/

  • tests/examples/autotools-outofsource.py
    1
    +import os
    
    2
    +import pytest
    
    3
    +
    
    4
    +from tests.testutils import cli_integration as cli
    
    5
    +from tests.testutils.integration import assert_contains
    
    6
    +from tests.testutils.site import IS_LINUX
    
    7
    +
    
    8
    +pytestmark = pytest.mark.integration
    
    9
    +
    
    10
    +DATA_DIR = os.path.join(
    
    11
    +    os.path.dirname(os.path.realpath(__file__)), '..', '..', 'doc', 'examples',
    
    12
    +    'out-of-source-autotool-in-source-tree'
    
    13
    +)
    
    14
    +
    
    15
    +
    
    16
    +# Tests a build of the autotools amhello project on a alpine-linux base runtime
    
    17
    +@pytest.mark.skipif(not IS_LINUX, reason='Only available on linux')
    
    18
    +@pytest.mark.datafiles(DATA_DIR)
    
    19
    +def test_autotools_build(cli, tmpdir, datafiles):
    
    20
    +    project = os.path.join(datafiles.dirname, datafiles.basename)
    
    21
    +    checkout = os.path.join(cli.directory, 'checkout')
    
    22
    +
    
    23
    +    # Check that the project can be built correctly.
    
    24
    +    result = cli.run(project=project, args=['build', 'hello.bst'])
    
    25
    +    result.assert_success()
    
    26
    +
    
    27
    +    result = cli.run(project=project, args=['checkout', 'hello.bst', checkout])
    
    28
    +    result.assert_success()
    
    29
    +
    
    30
    +    assert_contains(checkout, ['/usr', '/usr/lib', '/usr/bin',
    
    31
    +                               '/usr/share', '/usr/lib/debug',
    
    32
    +                               '/usr/lib/debug/usr', '/usr/lib/debug/usr/bin',
    
    33
    +                               '/usr/lib/debug/usr/bin/hello',
    
    34
    +                               '/usr/bin/hello',
    
    35
    +                               '/usr/share/doc', '/usr/share/doc/amhello',
    
    36
    +                               '/usr/share/doc/amhello/README'])
    
    37
    +
    
    38
    +
    
    39
    +# Test running an executable built with autotools.
    
    40
    +@pytest.mark.skipif(not IS_LINUX, reason='Only available on linux')
    
    41
    +@pytest.mark.datafiles(DATA_DIR)
    
    42
    +def test_autotools_run(cli, tmpdir, datafiles):
    
    43
    +    project = os.path.join(datafiles.dirname, datafiles.basename)
    
    44
    +
    
    45
    +    result = cli.run(project=project, args=['build', 'hello.bst'])
    
    46
    +    result.assert_success()
    
    47
    +
    
    48
    +    result = cli.run(project=project, args=['shell', 'hello.bst', 'hello'])
    
    49
    +    result.assert_success()
    
    50
    +    assert result.output == 'Hello World!\nThis is amhello 1.0.\n'

  • tests/examples/cmake.py
    1
    +import os
    
    2
    +import pytest
    
    3
    +
    
    4
    +from tests.testutils import cli_integration as cli
    
    5
    +from tests.testutils.integration import assert_contains
    
    6
    +from tests.testutils.site import IS_LINUX
    
    7
    +
    
    8
    +pytestmark = pytest.mark.integration
    
    9
    +
    
    10
    +DATA_DIR = os.path.join(
    
    11
    +    os.path.dirname(os.path.realpath(__file__)), '..', '..', 'doc', 'examples', 'cmake'
    
    12
    +)
    
    13
    +
    
    14
    +
    
    15
    +# Tests a build using cmake with the C complier from alpine-linux base runtime
    
    16
    +@pytest.mark.skipif(not IS_LINUX, reason='Only available on linux')
    
    17
    +@pytest.mark.datafiles(DATA_DIR)
    
    18
    +def test_autotools_build(cli, tmpdir, datafiles):
    
    19
    +    project = os.path.join(datafiles.dirname, datafiles.basename)
    
    20
    +    checkout = os.path.join(cli.directory, 'checkout')
    
    21
    +
    
    22
    +    # Check that the project can be built correctly.
    
    23
    +    result = cli.run(project=project, args=['build', 'hello.bst'])
    
    24
    +    result.assert_success()
    
    25
    +
    
    26
    +    result = cli.run(project=project, args=['checkout', 'hello.bst', checkout])
    
    27
    +    result.assert_success()
    
    28
    +
    
    29
    +    assert_contains(checkout, ['/usr', '/usr/lib', '/usr/bin',
    
    30
    +                               '/usr/share',
    
    31
    +                               '/bin/hello_buildstream'])
    
    32
    +
    
    33
    +
    
    34
    +# Test running an executable built with cmake.
    
    35
    +@pytest.mark.skipif(not IS_LINUX, reason='Only available on linux')
    
    36
    +@pytest.mark.datafiles(DATA_DIR)
    
    37
    +def test_autotools_run(cli, tmpdir, datafiles):
    
    38
    +    project = os.path.join(datafiles.dirname, datafiles.basename)
    
    39
    +
    
    40
    +    result = cli.run(project=project, args=['build', 'hello.bst'])
    
    41
    +    result.assert_success()
    
    42
    +
    
    43
    +    result = cli.run(project=project, args=['shell', 'hello.bst', 'hello_buildstream'])
    
    44
    +    result.assert_success()
    
    45
    +    assert result.output == 'Hello, World!\n'

  • tests/format/variables.py
    ... ... @@ -19,7 +19,7 @@ DATA_DIR = os.path.join(
    19 19
     @pytest.mark.parametrize("target,varname,expected", [
    
    20 20
         ('autotools.bst', 'make-install', "make -j1 DESTDIR=\"/buildstream-install\" install"),
    
    21 21
         ('cmake.bst', 'cmake',
    
    22
    -     "cmake -B_builddir -H. -G\"Unix Makefiles\" -DCMAKE_INSTALL_PREFIX:PATH=\"/usr\" \\\n" +
    
    22
    +     "cmake -B_builddir -H\".\" -G\"Unix Makefiles\" " + "-DCMAKE_INSTALL_PREFIX:PATH=\"/usr\" \\\n" +
    
    23 23
          "-DCMAKE_INSTALL_LIBDIR=lib   "),
    
    24 24
         ('distutils.bst', 'python-install',
    
    25 25
          "python3 setup.py install --prefix \"/usr\" \\\n" +
    
    ... ... @@ -45,7 +45,7 @@ def test_defaults(cli, datafiles, tmpdir, target, varname, expected):
    45 45
     @pytest.mark.parametrize("target,varname,expected", [
    
    46 46
         ('autotools.bst', 'make-install', "make -j1 DESTDIR=\"/custom/install/root\" install"),
    
    47 47
         ('cmake.bst', 'cmake',
    
    48
    -     "cmake -B_builddir -H. -G\"Ninja\" -DCMAKE_INSTALL_PREFIX:PATH=\"/opt\" \\\n" +
    
    48
    +     "cmake -B_builddir -H\".\" -G\"Ninja\" " + "-DCMAKE_INSTALL_PREFIX:PATH=\"/opt\" \\\n" +
    
    49 49
          "-DCMAKE_INSTALL_LIBDIR=lib   "),
    
    50 50
         ('distutils.bst', 'python-install',
    
    51 51
          "python3 setup.py install --prefix \"/opt\" \\\n" +
    



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