You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by ro...@apache.org on 2020/12/29 13:29:05 UTC

[buildstream] branch willsalmon/simpleOutSource created (now 44bba47)

This is an automated email from the ASF dual-hosted git repository.

root pushed a change to branch willsalmon/simpleOutSource
in repository https://gitbox.apache.org/repos/asf/buildstream.git.


      at 44bba47  quick test test

This branch includes the following new commits:

     new c6298bc  Sandbox: CWD was not being created for workspaces
     new 836727b  New Integration test for workspace command-subdir
     new 8f865d1  Add conf-root variable to builds
     new 35c0387  Adding Out of Source Build Examples
     new a774a34  Adding Tests for Out of Source Build examples
     new 783637a  Extended the Documentation to cover out of source builds
     new 26cf2e5  Added a news item for building out of the source directory
     new f2017d0  wip docs
     new 44bba47  quick test test

The 9 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[buildstream] 02/09: New Integration test for workspace command-subdir

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

root pushed a commit to branch willsalmon/simpleOutSource
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 836727ba6366224d7bedc15a34c767cfa8964b39
Author: William Salmon <wi...@codethink.co.uk>
AuthorDate: Fri Sep 14 11:37:47 2018 +0100

    New Integration test for workspace command-subdir
    
    Build stream was only creating command-subdir for non workspace builds
    this has now been fixed, and this regression test should support the
    feature.
    
    For issue #512 in Gitlab.
---
 .../project/elements/workspace/workspace-commanddir.bst | 17 +++++++++++++++++
 tests/integration/workspace.py                          | 17 +++++++++++++++++
 2 files changed, 34 insertions(+)

diff --git a/tests/integration/project/elements/workspace/workspace-commanddir.bst b/tests/integration/project/elements/workspace/workspace-commanddir.bst
new file mode 100644
index 0000000..d963346
--- /dev/null
+++ b/tests/integration/project/elements/workspace/workspace-commanddir.bst
@@ -0,0 +1,17 @@
+kind: manual
+description: Workspace mount test
+
+depends:
+  - filename: base.bst
+    type: build
+
+sources:
+  - kind: local
+    path: files/workspace-mount-src/
+
+variables:
+  command-subdir: build
+
+config:
+  build-commands:
+    - cc -c ../hello.c
diff --git a/tests/integration/workspace.py b/tests/integration/workspace.py
index 102d053..bcbcd67 100644
--- a/tests/integration/workspace.py
+++ b/tests/integration/workspace.py
@@ -34,6 +34,23 @@ def test_workspace_mount(cli, tmpdir, datafiles):
 
 @pytest.mark.integration
 @pytest.mark.datafiles(DATA_DIR)
+def test_workspace_commanddir(cli, tmpdir, datafiles):
+    project = os.path.join(datafiles.dirname, datafiles.basename)
+    workspace = os.path.join(cli.directory, 'workspace')
+    element_name = 'workspace/workspace-commanddir.bst'
+
+    res = cli.run(project=project, args=['workspace', 'open', element_name, workspace])
+    assert res.exit_code == 0
+
+    res = cli.run(project=project, args=['build', element_name])
+    assert res.exit_code == 0
+
+    assert os.path.exists(os.path.join(cli.directory, 'workspace'))
+    assert os.path.exists(os.path.join(cli.directory, 'workspace', 'build'))
+
+
+@pytest.mark.integration
+@pytest.mark.datafiles(DATA_DIR)
 def test_workspace_updated_dependency(cli, tmpdir, datafiles):
     project = os.path.join(datafiles.dirname, datafiles.basename)
     workspace = os.path.join(cli.directory, 'workspace')


[buildstream] 04/09: Adding Out of Source Build Examples

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

root pushed a commit to branch willsalmon/simpleOutSource
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 35c038704fe125b02686cc8f2a930723cf9b3df1
Author: William Salmon <wi...@codethink.co.uk>
AuthorDate: Mon Sep 10 15:46:46 2018 +0100

    Adding Out of Source Build Examples
    
    Three examples covering out of source builds for:
     * basic autotools
     * basic cmake
     * autotools from a folder inside the source folder
    
    This is also the first cmake example.
    
    For issue #512 in Gitlab.
---
 doc/examples/cmake/elements/base.bst               |   5 +
 doc/examples/cmake/elements/base/alpine.bst        |  13 ++
 doc/examples/cmake/elements/hello.bst              |  14 ++
 doc/examples/cmake/files/hello/CMakeLists.txt      |  14 ++
 doc/examples/cmake/files/hello/main.c              |   7 +
 doc/examples/cmake/project.conf                    |  13 ++
 .../elements/base.bst                              |   5 +
 .../elements/base/alpine.bst                       |  13 ++
 .../elements/hello.bst                             |  15 +++
 .../project.conf                                   |  13 ++
 .../elements/base.bst                              |   5 +
 .../elements/base/alpine.bst                       |  13 ++
 .../elements/hello.bst                             |  14 ++
 .../files/hello/Makefile.am                        |   1 +
 .../files/hello/README                             |   0
 .../files/hello/configure.ac                       |   6 +
 .../files/hello/src/Makefile.am                    |   2 +
 .../files/hello/src/hello.c                        |  20 +++
 .../files/hello/src/libhello.c                     |   9 ++
 .../files/hello/src/libhello.h                     |   8 ++
 .../out-of-source-build-helloworld/project.conf    |  13 ++
 doc/sessions/cmake.run                             |  20 +++
 doc/sessions/outofsource-autotools-shell.run       |  20 +++
 doc/sessions/outofsource-helloworld-shell.run      |  20 +++
 doc/source/examples/cmake.rst                      | 145 +++++++++++++++++++++
 .../out-of-source-autotool-in-source-tree.rst      | 141 ++++++++++++++++++++
 .../examples/out-of-source-build-helloworld.rst    | 140 ++++++++++++++++++++
 doc/source/using_examples.rst                      |   3 +
 28 files changed, 692 insertions(+)

diff --git a/doc/examples/cmake/elements/base.bst b/doc/examples/cmake/elements/base.bst
new file mode 100644
index 0000000..1b85a9e
--- /dev/null
+++ b/doc/examples/cmake/elements/base.bst
@@ -0,0 +1,5 @@
+kind: stack
+description: Base stack
+
+depends:
+- base/alpine.bst
diff --git a/doc/examples/cmake/elements/base/alpine.bst b/doc/examples/cmake/elements/base/alpine.bst
new file mode 100644
index 0000000..cf85df5
--- /dev/null
+++ b/doc/examples/cmake/elements/base/alpine.bst
@@ -0,0 +1,13 @@
+kind: import
+description: |
+
+    Alpine Linux base runtime
+
+sources:
+- kind: tar
+
+  # This is a post doctored, trimmed down system image
+  # of the Alpine linux distribution.
+  #
+  url: alpine:integration-tests-base.v1.x86_64.tar.xz
+  ref: 3eb559250ba82b64a68d86d0636a6b127aa5f6d25d3601a79f79214dc9703639
diff --git a/doc/examples/cmake/elements/hello.bst b/doc/examples/cmake/elements/hello.bst
new file mode 100644
index 0000000..654dad2
--- /dev/null
+++ b/doc/examples/cmake/elements/hello.bst
@@ -0,0 +1,14 @@
+depends:
+- base.bst
+description: |2
+
+  Hello world example from cmake
+kind: cmake
+sources:
+- kind: local
+  path: files/hello
+  directory: Source
+variables:
+  command-subdir: build
+  conf-root: "%{build-root}/Source"
+
diff --git a/doc/examples/cmake/files/hello/CMakeLists.txt b/doc/examples/cmake/files/hello/CMakeLists.txt
new file mode 100644
index 0000000..4176932
--- /dev/null
+++ b/doc/examples/cmake/files/hello/CMakeLists.txt
@@ -0,0 +1,14 @@
+
+# Set the minimum version of CMake that can be used
+# To find the cmake version run
+# $ cmake --version
+cmake_minimum_required(VERSION 2.8)
+
+# Set the project name
+project (hello_buildstreams C)
+
+# Add an executable
+add_executable(hello_buildstream main.c)
+
+
+install(TARGETS hello_buildstream DESTINATION /bin) 
diff --git a/doc/examples/cmake/files/hello/main.c b/doc/examples/cmake/files/hello/main.c
new file mode 100644
index 0000000..3c7b38d
--- /dev/null
+++ b/doc/examples/cmake/files/hello/main.c
@@ -0,0 +1,7 @@
+#include <stdio.h>
+int main()
+{
+   // printf() displays the string inside quotation
+   printf("Hello, World!\n");
+   return 0;
+}
diff --git a/doc/examples/cmake/project.conf b/doc/examples/cmake/project.conf
new file mode 100644
index 0000000..047ab7f
--- /dev/null
+++ b/doc/examples/cmake/project.conf
@@ -0,0 +1,13 @@
+# Unique project name
+name: cmake-out-of-source-build 
+
+# Required BuildStream format version
+format-version: 9
+
+# Subdirectory where elements are stored
+element-path: elements
+
+# Define some aliases for the tarballs we download
+aliases:
+  alpine: https://gnome7.codethink.co.uk/tarballs/
+  gnu: https://ftp.gnu.org/gnu/automake/
diff --git a/doc/examples/out-of-source-autotool-in-source-tree/elements/base.bst b/doc/examples/out-of-source-autotool-in-source-tree/elements/base.bst
new file mode 100644
index 0000000..1b85a9e
--- /dev/null
+++ b/doc/examples/out-of-source-autotool-in-source-tree/elements/base.bst
@@ -0,0 +1,5 @@
+kind: stack
+description: Base stack
+
+depends:
+- base/alpine.bst
diff --git a/doc/examples/out-of-source-autotool-in-source-tree/elements/base/alpine.bst b/doc/examples/out-of-source-autotool-in-source-tree/elements/base/alpine.bst
new file mode 100644
index 0000000..cf85df5
--- /dev/null
+++ b/doc/examples/out-of-source-autotool-in-source-tree/elements/base/alpine.bst
@@ -0,0 +1,13 @@
+kind: import
+description: |
+
+    Alpine Linux base runtime
+
+sources:
+- kind: tar
+
+  # This is a post doctored, trimmed down system image
+  # of the Alpine linux distribution.
+  #
+  url: alpine:integration-tests-base.v1.x86_64.tar.xz
+  ref: 3eb559250ba82b64a68d86d0636a6b127aa5f6d25d3601a79f79214dc9703639
diff --git a/doc/examples/out-of-source-autotool-in-source-tree/elements/hello.bst b/doc/examples/out-of-source-autotool-in-source-tree/elements/hello.bst
new file mode 100644
index 0000000..9b82fe6
--- /dev/null
+++ b/doc/examples/out-of-source-autotool-in-source-tree/elements/hello.bst
@@ -0,0 +1,15 @@
+depends:
+- base.bst
+description: |2
+
+  Hello world example from automake
+kind: autotools
+sources:
+- directory: SourB
+  kind: tar
+  ref: 80da43bb5665596ee389e6d8b64b4f122ea4b92a685b1dbd813cd1f0e0c2d83f
+  url: gnu:automake-1.16.tar.gz
+variables:
+  conf-root: "%{build-root}/SourB/doc/amhello"
+  command-subdir: build
+
diff --git a/doc/examples/out-of-source-autotool-in-source-tree/project.conf b/doc/examples/out-of-source-autotool-in-source-tree/project.conf
new file mode 100644
index 0000000..b6f21d4
--- /dev/null
+++ b/doc/examples/out-of-source-autotool-in-source-tree/project.conf
@@ -0,0 +1,13 @@
+# Unique project name
+name: Out-of-Source-builds-in-autotool-in-Source-tree
+
+# Required BuildStream format version
+format-version: 9
+
+# Subdirectory where elements are stored
+element-path: elements
+
+# Define some aliases for the tarballs we download
+aliases:
+  alpine: https://gnome7.codethink.co.uk/tarballs/
+  gnu: https://ftp.gnu.org/gnu/automake/
diff --git a/doc/examples/out-of-source-build-helloworld/elements/base.bst b/doc/examples/out-of-source-build-helloworld/elements/base.bst
new file mode 100644
index 0000000..1b85a9e
--- /dev/null
+++ b/doc/examples/out-of-source-build-helloworld/elements/base.bst
@@ -0,0 +1,5 @@
+kind: stack
+description: Base stack
+
+depends:
+- base/alpine.bst
diff --git a/doc/examples/out-of-source-build-helloworld/elements/base/alpine.bst b/doc/examples/out-of-source-build-helloworld/elements/base/alpine.bst
new file mode 100644
index 0000000..cf85df5
--- /dev/null
+++ b/doc/examples/out-of-source-build-helloworld/elements/base/alpine.bst
@@ -0,0 +1,13 @@
+kind: import
+description: |
+
+    Alpine Linux base runtime
+
+sources:
+- kind: tar
+
+  # This is a post doctored, trimmed down system image
+  # of the Alpine linux distribution.
+  #
+  url: alpine:integration-tests-base.v1.x86_64.tar.xz
+  ref: 3eb559250ba82b64a68d86d0636a6b127aa5f6d25d3601a79f79214dc9703639
diff --git a/doc/examples/out-of-source-build-helloworld/elements/hello.bst b/doc/examples/out-of-source-build-helloworld/elements/hello.bst
new file mode 100644
index 0000000..49e81ae
--- /dev/null
+++ b/doc/examples/out-of-source-build-helloworld/elements/hello.bst
@@ -0,0 +1,14 @@
+depends:
+- base.bst
+description: |2
+
+  Hello world example from automake
+kind: autotools
+sources:
+- directory: Source
+  kind: local
+  path: files/hello
+variables:
+  conf-root: "%{build-root}/Source"
+  command-subdir: build
+
diff --git a/doc/examples/out-of-source-build-helloworld/files/hello/Makefile.am b/doc/examples/out-of-source-build-helloworld/files/hello/Makefile.am
new file mode 100644
index 0000000..af437a6
--- /dev/null
+++ b/doc/examples/out-of-source-build-helloworld/files/hello/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = src
diff --git a/doc/examples/out-of-source-build-helloworld/files/hello/README b/doc/examples/out-of-source-build-helloworld/files/hello/README
new file mode 100644
index 0000000..e69de29
diff --git a/doc/examples/out-of-source-build-helloworld/files/hello/configure.ac b/doc/examples/out-of-source-build-helloworld/files/hello/configure.ac
new file mode 100644
index 0000000..8cee3f7
--- /dev/null
+++ b/doc/examples/out-of-source-build-helloworld/files/hello/configure.ac
@@ -0,0 +1,6 @@
+AC_INIT([helloworld], [0.1], [will.salmon@codethink.co.uk])
+AM_INIT_AUTOMAKE([-Wall -Werror foreign])
+AC_PROG_CC
+AC_CONFIG_FILES([Makefile
+		 src/Makefile])
+AC_OUTPUT
diff --git a/doc/examples/out-of-source-build-helloworld/files/hello/src/Makefile.am b/doc/examples/out-of-source-build-helloworld/files/hello/src/Makefile.am
new file mode 100644
index 0000000..2a4d8a8
--- /dev/null
+++ b/doc/examples/out-of-source-build-helloworld/files/hello/src/Makefile.am
@@ -0,0 +1,2 @@
+bin_PROGRAMS = hello
+hello_SOURCES = hello.c libhello.c
diff --git a/doc/examples/out-of-source-build-helloworld/files/hello/src/hello.c b/doc/examples/out-of-source-build-helloworld/files/hello/src/hello.c
new file mode 100644
index 0000000..83e762c
--- /dev/null
+++ b/doc/examples/out-of-source-build-helloworld/files/hello/src/hello.c
@@ -0,0 +1,20 @@
+/*
+ * hello.c - Simple hello program
+ */
+#include <stdio.h>
+#include <libhello.h>
+
+int main(int argc, char *argv[])
+{
+  const char *person = NULL;
+
+  if (argc > 1)
+    person = argv[1];
+
+  if (person)
+    hello(person);
+  else
+    hello("stranger");
+
+  return 0;
+}
diff --git a/doc/examples/out-of-source-build-helloworld/files/hello/src/libhello.c b/doc/examples/out-of-source-build-helloworld/files/hello/src/libhello.c
new file mode 100644
index 0000000..759b339
--- /dev/null
+++ b/doc/examples/out-of-source-build-helloworld/files/hello/src/libhello.c
@@ -0,0 +1,9 @@
+/*
+ * libhello.c - The hello library
+ */
+#include <stdio.h>
+
+void hello(const char *person)
+{
+  printf("Hello %s\n", person);
+}
diff --git a/doc/examples/out-of-source-build-helloworld/files/hello/src/libhello.h b/doc/examples/out-of-source-build-helloworld/files/hello/src/libhello.h
new file mode 100644
index 0000000..f714f36
--- /dev/null
+++ b/doc/examples/out-of-source-build-helloworld/files/hello/src/libhello.h
@@ -0,0 +1,8 @@
+/*
+ * libhello.h - The hello library
+ */
+
+/*
+ * A function to say hello to @person
+ */
+void hello(const char *person);
diff --git a/doc/examples/out-of-source-build-helloworld/project.conf b/doc/examples/out-of-source-build-helloworld/project.conf
new file mode 100644
index 0000000..9b33a6e
--- /dev/null
+++ b/doc/examples/out-of-source-build-helloworld/project.conf
@@ -0,0 +1,13 @@
+# Unique project name
+name: our-of-source-build-helloworld 
+
+# Required BuildStream format version
+format-version: 9
+
+# Subdirectory where elements are stored
+element-path: elements
+
+# Define some aliases for the tarballs we download
+aliases:
+  alpine: https://gnome7.codethink.co.uk/tarballs/
+  gnu: https://ftp.gnu.org/gnu/automake/
diff --git a/doc/sessions/cmake.run b/doc/sessions/cmake.run
new file mode 100644
index 0000000..3241166
--- /dev/null
+++ b/doc/sessions/cmake.run
@@ -0,0 +1,20 @@
+
+commands:
+# Make it fetch first
+- directory: ../examples/cmake
+  command: fetch hello.bst
+
+# Capture a `bst show` of the variables
+- directory: ../examples/cmake
+  output: ../source/sessions/cmake-show-variables.html
+  command: show --deps none --format "%{vars}" hello.bst
+
+# Capture a `bst build`
+- directory: ../examples/cmake
+  output: ../source/sessions/cmake-build.html
+  command: build hello.bst
+
+# Capture a shell output
+- directory: ../examples/cmake
+  output: ../source/sessions/cmake-shell.html
+  command: shell hello.bst --  hello_buildstream 
diff --git a/doc/sessions/outofsource-autotools-shell.run b/doc/sessions/outofsource-autotools-shell.run
new file mode 100644
index 0000000..facab5b
--- /dev/null
+++ b/doc/sessions/outofsource-autotools-shell.run
@@ -0,0 +1,20 @@
+
+commands:
+# Make it fetch first
+- directory: ../examples/out-of-source-autotool-in-source-tree
+  command: fetch hello.bst
+
+# Capture a `bst show` of the variables
+- directory: ../examples/out-of-source-autotool-in-source-tree
+  output: ../source/sessions/outofsource-autotool-show-variables.html
+  command: show --deps none --format "%{vars}" hello.bst
+
+# Capture a `bst build`
+- directory: ../examples/out-of-source-autotool-in-source-tree
+  output: ../source/sessions/outofsource-autotools-build.html
+  command: build hello.bst
+
+# Capture a shell output
+- directory: ../examples/out-of-source-autotool-in-source-tree
+  output: ../source/sessions/outofsource-autotools-shell.html
+  command: shell hello.bst --  hello
diff --git a/doc/sessions/outofsource-helloworld-shell.run b/doc/sessions/outofsource-helloworld-shell.run
new file mode 100644
index 0000000..df15bff
--- /dev/null
+++ b/doc/sessions/outofsource-helloworld-shell.run
@@ -0,0 +1,20 @@
+
+commands:
+# Make it fetch first
+- directory: ../examples/out-of-source-build-helloworld
+  command: fetch hello.bst
+
+# Capture a `bst show` of the variables
+- directory: ../examples/out-of-source-build-helloworld
+  output: ../source/sessions/outofsource-helloworld-show-variables.html
+  command: show --deps none --format "%{vars}" hello.bst
+
+# Capture a `bst build`
+- directory: ../examples/out-of-source-build-helloworld
+  output: ../source/sessions/outofsource-helloworld-build.html
+  command: build hello.bst
+
+# Capture a shell output
+- directory: ../examples/out-of-source-build-helloworld
+  output: ../source/sessions/outofsource-helloworld-shell.html
+  command: shell hello.bst --  hello
diff --git a/doc/source/examples/cmake.rst b/doc/source/examples/cmake.rst
new file mode 100644
index 0000000..e124257
--- /dev/null
+++ b/doc/source/examples/cmake.rst
@@ -0,0 +1,145 @@
+
+.. _examples_cmake:
+
+Using Cmake
+===========
+
+Intro
+-----
+
+This example aims to show:
+
+ * How to use cmake elements
+ * How to use Out of source element with cmake
+
+The out of source hello world example show the basics of out of source builds but
+this example shows how to apply that to cmake, a more complex build system.
+
+Build stream aims to make out of source builds as easy as posible and so long as
+the build element supports out of source element it should be the same.
+
+The out of source builds are configured by setting:
+ 
+ * `directory` of the source, this sets the source to open in to a folder in the
+   build root.
+ * `command-subdir` variable, sets were the build will be run.
+ * `conf-root` variable, tells the confirmation tool how to get from
+   `command-subdir` to `directory`.
+
+This example:
+ 
+ * Sets `directory` to `Source` in `elements/hello.bst`
+ * Sets `command-subdir` to `build` in `elements/hello.bst`
+ * Sets `conf-root` to `"%{build-root}/Source"` in `elements/hello.bst`
+
+This way we can change `command-subdir` with out having to change `conf-root`
+but we could have set `conf-root` to `../Source` but then we would have to
+change it if `command-subdir` changed to `.` or `sub/folder`
+
+
+Prerequisites
+-------------
+All the necessary elements are in the example folder
+
+Project structure
+-----------------
+
+The following is a simple :ref:`project <projectconf>` definition:
+
+``project.conf``
+~~~~~~~~~~~~~~~~
+
+.. literalinclude:: ../../examples/cmake/project.conf
+   :language: yaml
+
+Note that we’ve added a :ref:`source alias <project_source_aliases>` for
+the ``https://gnome7.codethink.co.uk/tarballs/`` repository to download the 
+build tools from, please note that this bootstrap only contains the compiler 
+if you wish to use c++ you will need a different bootstrap.
+
+``elements/base/alpine.bst``
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. literalinclude:: ../../examples/cmake/elements/base/alpine.bst
+   :language: yaml
+
+This is the :mod:`import <elements.import>` element used to import the
+actual Flatpak SDK, it uses an :mod:`tar <sources.tar>` source to
+download and unpack the archive in to the sandbox.
+
+``elements/base.bst``
+~~~~~~~~~~~~~~~~~~~~~
+
+.. literalinclude:: ../../examples/cmake/elements/base.bst
+   :language: yaml
+
+This is just a :mod:`stack <elements.stack>` element for convenience sake.
+
+Often times you will have a more complex base to build things on, and it
+is convenient to just use a :mod:`stack <elements.stack>` element for
+your elements to depend on without needing to know about the inner workings
+of the base system build.
+
+``elements/hello.bst``
+~~~~~~~~~~~~~~~~~~~~~~
+
+.. literalinclude:: ../../examples/cmake/elements/hello.bst
+   :language: yaml
+
+Finally, we show an example of an :mod:`cmake <elements.cmake>` element
+to build our sample "Hello World" program.
+
+We use a :mod:`local <sources.local>` source to obtain the sample
+cmake project, but normally you would probably use a :mod:`git <sources.git>`
+or other source to obtain source code from another repository.
+
+Setting `kind` to `cmake` is enough to trigger the use of cmake and bst will
+formate your build options like ``command-subdir`` and ``conf-root`` for cmake
+but bst dose not provide the cmake program its self, you must specify that you
+want cmake to be a dependency this is done by depending on the`base.bst` element
+that provides cmake.
+
+
+Using the project
+-----------------
+Now that we've explained the basic layout of the project, here are
+just a few things you can try to do with the project.
+
+.. note::
+
+   The following examples assume that you have first changed your working
+   directory to the
+   `project root <https://gitlab.com/BuildStream/buildstream/tree/master/doc/examples/cmake>`_.
+
+
+Build the hello.bst element
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+To build the project, run :ref:`bst build <invoking_build>` in the
+following way:
+
+.. raw:: html
+   :file: ../sessions/cmake-build.html
+
+
+Run the hello world program
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+The hello world program has been built into the standard ``/usr`` prefix,
+and will automatically be in the default ``PATH`` for running things
+in a :ref:`bst shell <invoking_shell>`.
+
+To just run the program, run :ref:`bst shell <invoking_shell>` in the
+following way:
+
+.. raw:: html
+   :file: ../sessions/cmake-shell.html
+
+
+
+
+
+
+
+
+
+
+
diff --git a/doc/source/examples/out-of-source-autotool-in-source-tree.rst b/doc/source/examples/out-of-source-autotool-in-source-tree.rst
new file mode 100644
index 0000000..3565caa
--- /dev/null
+++ b/doc/source/examples/out-of-source-autotool-in-source-tree.rst
@@ -0,0 +1,141 @@
+
+.. _examples_out_of_source_autotool_in_source_tree:
+
+
+Building a autotools project Out of source
+==========================================
+
+Intro
+-----
+
+This example aims to show:
+
+ * How to use Out of source element with autotools were the project to be build
+   is not in the sources root directory.
+
+The out of source hello world example show the basics of out of source builds but
+this example shows how to apply that to in source tree projects.
+
+Build stream aims to make out of source builds as easy as possible and so long as
+the build element supports out of source element it should be the same, so while
+this is a auto tools project the principles of in source tree projects should
+transfer to any buildsystem with support for out of source builds.
+
+
+The out of source builds are configured by setting:
+
+ * `directory` of the source, this sets the source to open in to a folder in the
+   build root.
+ * `command-subdir` variable, sets were the build will be run.
+ * `conf-root` variable, tells the confirmation tool how to get from
+   `command-subdir` to `directory`.
+
+This example:
+
+ * Sets `directory` to `SourB` in `elements/hello.bst`
+ * Sets `command-subdir` to `build` in `elements/hello.bst`
+ * Sets `conf-root` to `"%{build-root}/SourB/doc/amhello"` in `elements/hello.bst`
+
+Commenly we have `conf-root` be the location of the source. Ether in absolute
+terms, eg `%{build-root}/SourB` or in relative terms `../SourB`. But in our case
+the projcet is not in the root of the source, it is in `doc/amhello` within the
+source so we have to set `conf-root` to equal the location of the source plus
+the location of the project within the source. eg. `"%{build-root}/SourB/doc/amhello"`
+
+Prerequisites
+-------------
+All the necessary elements are in the example folder
+
+Project structure
+-----------------
+
+The following is a simple :ref:`project <projectconf>` definition:
+
+``project.conf``
+~~~~~~~~~~~~~~~~
+
+.. literalinclude:: ../../examples/out-of-source-autotool-in-source-tree/project.conf
+   :language: yaml
+
+Note that we’ve added a :ref:`source alias <project_source_aliases>` for
+the ``https://gnome7.codethink.co.uk/tarballs/`` repository to download the 
+build tools from.
+
+``elements/base/alpine.bst``
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. literalinclude:: ../../examples/out-of-source-autotool-in-source-tree/elements/base/alpine.bst
+   :language: yaml
+
+This is the :mod:`import <elements.import>` element used to import the
+actual Flatpak SDK, it uses an :mod:`tar <sources.tar>` source to
+download and unpack the archive in to the sandbox.
+
+``elements/base.bst``
+~~~~~~~~~~~~~~~~~~~~~
+
+.. literalinclude:: ../../examples/out-of-source-autotool-in-source-tree/elements/base.bst
+   :language: yaml
+
+This is just a :mod:`stack <elements.stack>` element for convenience sake.
+
+Often times you will have a more complex base to build things on, and it
+is convenient to just use a :mod:`stack <elements.stack>` element for
+your elements to depend on without needing to know about the inner workings
+of the base system build.
+
+``elements/hello.bst``
+~~~~~~~~~~~~~~~~~~~~~~
+
+.. literalinclude:: ../../examples/out-of-source-autotool-in-source-tree/elements/hello.bst
+   :language: yaml
+
+Finally, we show an example of an :mod:`automake <elements.autotools>` element
+to build our sample "Hello World" program.
+
+We use a :mod:`local <sources.local>` source to obtain the sample
+autotools project, but normally you would probably use a :mod:`git <sources.git>`
+or other source to obtain source code from another repository.
+
+
+Using the project
+-----------------
+Now that we've explained the basic layout of the project, here are
+just a few things you can try to do with the project.
+
+.. note::
+
+   The following examples assume that you have first changed your working
+   directory to the
+   `project root <https://gitlab.com/BuildStream/buildstream/tree/master/doc/examples/out-of-source-autotool-in-source-tree>`_.
+
+Build the hello.bst element
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+To build the project, run :ref:`bst build <invoking_build>` in the
+following way:
+
+.. raw:: html
+   :file: ../sessions/outofsource-autotools-build.html
+
+
+Run the hello world program
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+The hello world program has been built into the standard ``/usr`` prefix,
+and will automatically be in the default ``PATH`` for running things
+in a :ref:`bst shell <invoking_shell>`.
+
+To just run the program, run :ref:`bst shell <invoking_shell>` in the
+following way:
+
+.. raw:: html
+   :file: ../sessions/outofsource-autotools-shell.html
+
+
+
+
+
+
+
+
+
+
diff --git a/doc/source/examples/out-of-source-build-helloworld.rst b/doc/source/examples/out-of-source-build-helloworld.rst
new file mode 100644
index 0000000..58cde5b
--- /dev/null
+++ b/doc/source/examples/out-of-source-build-helloworld.rst
@@ -0,0 +1,140 @@
+
+.. _examples_out_of_source_build_helloworld:
+
+
+Out of source hello world
+=========================
+
+Intro
+-----
+
+This example aims to show:
+
+ * How to use Out of source element with cmake
+
+This example aims to show the basics of out of source builds
+
+Build stream aims to make out of source builds as easy as posible and so long as
+the build element supports out of source element it should be the same.
+
+The out of source builds are configured by setting:
+ 
+ * `directory` of the source, this sets the source to open in to a folder in the
+   build root.
+ * `command-subdir` variable, sets were the build will be run.
+ * `conf-root` variable, tells the confirmation tool how to get from
+   `command-subdir` to `directory`.
+
+This example:
+ 
+ * Sets `directory` to `Source` in `elements/hello.bst`
+ * Sets `command-subdir` to `build` in `elements/hello.bst`
+ * Sets `conf-root` to `"%{build-root}/Source"` in `elements/hello.bst`
+
+This way we can change `command-subdir` with out having to change `conf-root`
+but we could have set `conf-root` to `../Source` but then we would have to
+change it if `command-subdir` changed to `.` or `sub/folder`
+
+
+
+Prerequisites
+-------------
+All the necessary elements are in the example folder
+
+Project structure
+-----------------
+
+The following is a simple :ref:`project <projectconf>` definition:
+
+``project.conf``
+~~~~~~~~~~~~~~~~
+
+.. literalinclude:: ../../examples/out-of-source-build-helloworld/project.conf
+   :language: yaml
+
+Note that we’ve added a :ref:`source alias <project_source_aliases>` for
+the ``https://gnome7.codethink.co.uk/tarballs/`` repository to download the 
+build tools from.
+
+``elements/base/alpine.bst``
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. literalinclude:: ../../examples/out-of-source-build-helloworld/elements/base/alpine.bst
+   :language: yaml
+
+This is the :mod:`import <elements.import>` element used to import the
+actual Flatpak SDK, it uses an :mod:`tar <sources.tar>` source to
+download and unpack the archive in to the sandbox.
+
+``elements/base.bst``
+~~~~~~~~~~~~~~~~~~~~~
+
+.. literalinclude:: ../../examples/out-of-source-build-helloworld/elements/base.bst
+   :language: yaml
+
+This is just a :mod:`stack <elements.stack>` element for convenience sake.
+
+Often times you will have a more complex base to build things on, and it
+is convenient to just use a :mod:`stack <elements.stack>` element for
+your elements to depend on without needing to know about the inner workings
+of the base system build.
+
+``elements/hello.bst``
+~~~~~~~~~~~~~~~~~~~~~~
+
+.. literalinclude:: ../../examples/out-of-source-build-helloworld/elements/hello.bst
+   :language: yaml
+
+Finally, we show an example of an :mod:`automake <elements.autotools>` element
+to build our sample "Hello World" program.
+
+We use a :mod:`local <sources.local>` source to obtain the sample
+autotools project, but normally you would probably use a :mod:`git <sources.git>`
+or other source to obtain source code from another repository.
+
+
+Using the project
+-----------------
+Now that we've explained the basic layout of the project, here are
+just a few things you can try to do with the project.
+
+.. note::
+
+   The following examples assume that you have first changed your working
+   directory to the
+   `project root <https://gitlab.com/BuildStream/buildstream/tree/master/doc/examples/out-of-source-build-helloworld>`_.
+
+Build the hello.bst element
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+To build the project, run :ref:`bst build <invoking_build>` in the
+following way:
+
+.. raw:: html
+   :file: ../sessions/outofsource-helloworld-build.html
+
+Please see the source option `directory` and variables, `command-subdir` and 
+`conf-root` set as described in the introduction.
+
+Run the hello world program
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+The hello world program has been built into the standard ``/usr`` prefix,
+and will automatically be in the default ``PATH`` for running things
+in a :ref:`bst shell <invoking_shell>`.
+
+To just run the program, run :ref:`bst shell <invoking_shell>` in the
+following way:
+
+.. raw:: html
+   :file: ../sessions/outofsource-helloworld-shell.html
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/doc/source/using_examples.rst b/doc/source/using_examples.rst
index 622b09e..b194804 100644
--- a/doc/source/using_examples.rst
+++ b/doc/source/using_examples.rst
@@ -12,3 +12,6 @@ maintained and work as expected.
    examples/flatpak-autotools
    examples/tar-mirror
    examples/git-mirror
+   examples/out-of-source-build-helloworld
+   examples/out-of-source-autotool-in-source-tree
+   examples/cmake


[buildstream] 03/09: Add conf-root variable to builds

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

root pushed a commit to branch willsalmon/simpleOutSource
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 8f865d186886ba74774aef3a419e01d943c2f215
Author: William Salmon <wi...@codethink.co.uk>
AuthorDate: Mon Sep 10 15:37:02 2018 +0100

    Add conf-root variable to builds
    
    Adding the conf-root variable makes creating out of source builds
    slightly easier.
    
    For issue #512 in Gitlab.
---
 buildstream/_versions.py                    |  2 +-
 buildstream/data/projectconfig.yaml         |  3 +++
 buildstream/plugins/elements/autotools.yaml | 13 +++++++------
 buildstream/plugins/elements/cmake.yaml     |  2 +-
 buildstream/plugins/elements/distutils.yaml |  4 ++--
 buildstream/plugins/elements/meson.yaml     |  2 +-
 buildstream/plugins/elements/pip.yaml       |  2 +-
 buildstream/plugins/elements/qmake.yaml     |  2 +-
 tests/format/variables.py                   |  8 ++++----
 9 files changed, 21 insertions(+), 17 deletions(-)

diff --git a/buildstream/_versions.py b/buildstream/_versions.py
index 9d9d270..8ad2f8c 100644
--- a/buildstream/_versions.py
+++ b/buildstream/_versions.py
@@ -23,7 +23,7 @@
 # This version is bumped whenever enhancements are made
 # to the `project.conf` format or the core element format.
 #
-BST_FORMAT_VERSION = 16
+BST_FORMAT_VERSION = 17
 
 
 # The base BuildStream artifact version
diff --git a/buildstream/data/projectconfig.yaml b/buildstream/data/projectconfig.yaml
index 4d2ccc6..bc9e514 100644
--- a/buildstream/data/projectconfig.yaml
+++ b/buildstream/data/projectconfig.yaml
@@ -38,6 +38,9 @@ variables:
   # normally staged
   build-root: /buildstream/%{project-name}/%{element-name}
 
+  # Indicates where the build system should look for configuration files  
+  conf-root: .
+  
   # Indicates the build installation directory in the sandbox
   install-root: /buildstream-install
 
diff --git a/buildstream/plugins/elements/autotools.yaml b/buildstream/plugins/elements/autotools.yaml
index 7adafd4..a6917f8 100644
--- a/buildstream/plugins/elements/autotools.yaml
+++ b/buildstream/plugins/elements/autotools.yaml
@@ -6,11 +6,11 @@ variables:
     export NOCONFIGURE=1;
 
     if [ -x %{conf-cmd} ]; then true;
-    elif [ -x autogen ]; then ./autogen;
-    elif [ -x autogen.sh ]; then ./autogen.sh;
-    elif [ -x bootstrap ]; then ./bootstrap;
-    elif [ -x bootstrap.sh ]; then ./bootstrap.sh;
-    else autoreconf -ivf;
+    elif [ -x %{conf-root}/autogen ]; then %{conf-root}/autogen;
+    elif [ -x %{conf-root}/autogen.sh ]; then %{conf-root}/autogen.sh;
+    elif [ -x %{conf-root}/bootstrap ]; then %{conf-root}/bootstrap;
+    elif [ -x %{conf-root}/bootstrap.sh ]; then %{conf-root}/bootstrap.sh;
+    else autoreconf -ivf %{conf-root};
     fi
 
   # Project-wide extra arguments to be passed to `configure`
@@ -22,7 +22,8 @@ variables:
   # For backwards compatibility only, do not use.
   conf-extra: ''
 
-  conf-cmd: ./configure
+  conf-cmd: "%{conf-root}/configure"
+  
   conf-args: |
 
     --prefix=%{prefix} \
diff --git a/buildstream/plugins/elements/cmake.yaml b/buildstream/plugins/elements/cmake.yaml
index b51727b..d38a2d2 100644
--- a/buildstream/plugins/elements/cmake.yaml
+++ b/buildstream/plugins/elements/cmake.yaml
@@ -23,7 +23,7 @@ variables:
 
   cmake: |
 
-    cmake -B%{build-dir} -H. -G"%{generator}" %{cmake-args}
+    cmake -B%{build-dir} -H"%{conf-root}" -G"%{generator}" %{cmake-args}
 
   make: cmake --build %{build-dir} -- ${JOBS}
   make-install: env DESTDIR="%{install-root}" cmake --build %{build-dir} --target install
diff --git a/buildstream/plugins/elements/distutils.yaml b/buildstream/plugins/elements/distutils.yaml
index 7cb6f3a..cec7da6 100644
--- a/buildstream/plugins/elements/distutils.yaml
+++ b/buildstream/plugins/elements/distutils.yaml
@@ -8,7 +8,7 @@ variables:
 
   python-build: |
 
-    %{python} setup.py build
+    %{python} %{conf-root}/setup.py build
 
   install-args: |
 
@@ -17,7 +17,7 @@ variables:
 
   python-install: |
 
-    %{python} setup.py install %{install-args}
+    %{python} %{conf-root}/setup.py install %{install-args}
 
 
 config:
diff --git a/buildstream/plugins/elements/meson.yaml b/buildstream/plugins/elements/meson.yaml
index 7af9a76..9636d76 100644
--- a/buildstream/plugins/elements/meson.yaml
+++ b/buildstream/plugins/elements/meson.yaml
@@ -28,7 +28,7 @@ variables:
     --mandir=%{mandir} \
     --infodir=%{infodir} %{meson-extra} %{meson-global} %{meson-local}
 
-  meson: meson %{build-dir} %{meson-args}
+  meson: meson %{conf-root} %{build-dir} %{meson-args}
 
   ninja: |
     ninja -j ${NINJAJOBS} -C %{build-dir}
diff --git a/buildstream/plugins/elements/pip.yaml b/buildstream/plugins/elements/pip.yaml
index 19a226e..b2b3d38 100644
--- a/buildstream/plugins/elements/pip.yaml
+++ b/buildstream/plugins/elements/pip.yaml
@@ -14,7 +14,7 @@ config:
   #
   install-commands:
   - |
-    %{pip} install --no-deps --root=%{install-root} --prefix=%{prefix} .
+    %{pip} install --no-deps --root=%{install-root} --prefix=%{prefix} %{conf-root} 
 
   # Commands for stripping debugging information out of
   # installed binaries
diff --git a/buildstream/plugins/elements/qmake.yaml b/buildstream/plugins/elements/qmake.yaml
index e527d45..38bf2da 100644
--- a/buildstream/plugins/elements/qmake.yaml
+++ b/buildstream/plugins/elements/qmake.yaml
@@ -2,7 +2,7 @@
 
 variables:
 
-  qmake: qmake -makefile
+  qmake: qmake -makefile %{conf-root}
   make: make
   make-install: make -j1 INSTALL_ROOT="%{install-root}" install
 
diff --git a/tests/format/variables.py b/tests/format/variables.py
index d01d87e..26bb3db 100644
--- a/tests/format/variables.py
+++ b/tests/format/variables.py
@@ -19,10 +19,10 @@ DATA_DIR = os.path.join(
 @pytest.mark.parametrize("target,varname,expected", [
     ('autotools.bst', 'make-install', "make -j1 DESTDIR=\"/buildstream-install\" install"),
     ('cmake.bst', 'cmake',
-     "cmake -B_builddir -H. -G\"Unix Makefiles\" -DCMAKE_INSTALL_PREFIX:PATH=\"/usr\" \\\n" +
+     "cmake -B_builddir -H\".\" -G\"Unix Makefiles\" " + "-DCMAKE_INSTALL_PREFIX:PATH=\"/usr\" \\\n" +
      "-DCMAKE_INSTALL_LIBDIR=lib   "),
     ('distutils.bst', 'python-install',
-     "python3 setup.py install --prefix \"/usr\" \\\n" +
+     "python3 ./setup.py install --prefix \"/usr\" \\\n" +
      "--root \"/buildstream-install\""),
     ('makemaker.bst', 'configure', "perl Makefile.PL PREFIX=/buildstream-install/usr"),
     ('modulebuild.bst', 'configure', "perl Build.PL --prefix \"/buildstream-install/usr\""),
@@ -45,10 +45,10 @@ def test_defaults(cli, datafiles, tmpdir, target, varname, expected):
 @pytest.mark.parametrize("target,varname,expected", [
     ('autotools.bst', 'make-install', "make -j1 DESTDIR=\"/custom/install/root\" install"),
     ('cmake.bst', 'cmake',
-     "cmake -B_builddir -H. -G\"Ninja\" -DCMAKE_INSTALL_PREFIX:PATH=\"/opt\" \\\n" +
+     "cmake -B_builddir -H\".\" -G\"Ninja\" " + "-DCMAKE_INSTALL_PREFIX:PATH=\"/opt\" \\\n" +
      "-DCMAKE_INSTALL_LIBDIR=lib   "),
     ('distutils.bst', 'python-install',
-     "python3 setup.py install --prefix \"/opt\" \\\n" +
+     "python3 ./setup.py install --prefix \"/opt\" \\\n" +
      "--root \"/custom/install/root\""),
     ('makemaker.bst', 'configure', "perl Makefile.PL PREFIX=/custom/install/root/opt"),
     ('modulebuild.bst', 'configure', "perl Build.PL --prefix \"/custom/install/root/opt\""),


[buildstream] 01/09: Sandbox: CWD was not being created for workspaces

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

root pushed a commit to branch willsalmon/simpleOutSource
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit c6298bc05d46061bff837b18f28a9b4507e73443
Author: William Salmon <wi...@codethink.co.uk>
AuthorDate: Thu Sep 13 16:47:44 2018 +0100

    Sandbox: CWD was not being created for workspaces
    
    The code was creating the cwd folder but when the workspace was
    mounted in to the buildroot it was hiding the folder created in it
    behind the bind mounted workspace.
    
    However by using the bubblewarp `--dir` directive to ensure that cwd
    exists we can cover both workspace and non workspace situations with
    the same method.
    
    For issue #512 in Gitlab.
---
 buildstream/sandbox/_sandboxbwrap.py  | 12 ++++--------
 buildstream/sandbox/_sandboxchroot.py |  3 +--
 buildstream/sandbox/sandbox.py        |  4 +++-
 3 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/buildstream/sandbox/_sandboxbwrap.py b/buildstream/sandbox/_sandboxbwrap.py
index 5effadf..8c406e5 100644
--- a/buildstream/sandbox/_sandboxbwrap.py
+++ b/buildstream/sandbox/_sandboxbwrap.py
@@ -108,9 +108,6 @@ class SandboxBwrap(Sandbox):
             bwrap_command += ['--unshare-uts', '--hostname', 'buildstream']
             bwrap_command += ['--unshare-ipc']
 
-        if cwd is not None:
-            bwrap_command += ['--chdir', cwd]
-
         # Give it a proc and tmpfs
         bwrap_command += [
             '--proc', '/proc',
@@ -151,6 +148,10 @@ class SandboxBwrap(Sandbox):
         if flags & SandboxFlags.ROOT_READ_ONLY:
             bwrap_command += ["--remount-ro", "/"]
 
+        if cwd is not None:
+            bwrap_command += ['--dir', cwd]
+            bwrap_command += ['--chdir', cwd]
+
         # Set UID and GUI
         if self.user_ns_available:
             bwrap_command += ['--unshare-user']
@@ -179,11 +180,6 @@ class SandboxBwrap(Sandbox):
         with ExitStack() as stack:
             stack.enter_context(mount_map.mounted(self))
 
-            # Ensure the cwd exists
-            if cwd is not None:
-                workdir = os.path.join(root_mount_source, cwd.lstrip(os.sep))
-                os.makedirs(workdir, exist_ok=True)
-
             # If we're interactive, we want to inherit our stdin,
             # otherwise redirect to /dev/null, ensuring process
             # disconnected from terminal.
diff --git a/buildstream/sandbox/_sandboxchroot.py b/buildstream/sandbox/_sandboxchroot.py
index b3a2a6d..f19052b 100644
--- a/buildstream/sandbox/_sandboxchroot.py
+++ b/buildstream/sandbox/_sandboxchroot.py
@@ -100,9 +100,8 @@ class SandboxChroot(Sandbox):
 
             # Ensure the cwd exists
             if cwd is not None:
-                workdir = os.path.join(root_mount_source, cwd.lstrip(os.sep))
+                workdir = os.path.join(rootfs, cwd.lstrip(os.sep))
                 os.makedirs(workdir, exist_ok=True)
-
             status = self.chroot(rootfs, command, stdin, stdout,
                                  stderr, cwd, env, flags)
 
diff --git a/buildstream/sandbox/sandbox.py b/buildstream/sandbox/sandbox.py
index 42cfb9a..83714ef 100644
--- a/buildstream/sandbox/sandbox.py
+++ b/buildstream/sandbox/sandbox.py
@@ -223,7 +223,9 @@ class Sandbox():
         .. note::
 
            The optional *cwd* argument will default to the value set with
-           :func:`~buildstream.sandbox.Sandbox.set_work_directory`
+           :func:`~buildstream.sandbox.Sandbox.set_work_directory` and this
+           function must make sure the directory will be created if it does
+           not exist yet, even if a workspace is being used.
         """
         raise ImplError("Sandbox of type '{}' does not implement run()"
                         .format(type(self).__name__))


[buildstream] 06/09: Extended the Documentation to cover out of source builds

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

root pushed a commit to branch willsalmon/simpleOutSource
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 783637a3fc4fa80448ef1c8fb3daa2a575ab38fa
Author: William Salmon <wi...@codethink.co.uk>
AuthorDate: Tue Sep 11 11:40:56 2018 +0100

    Extended the Documentation to cover out of source builds
    
    For issue #512 in Gitlab.
---
 buildstream/buildelement.py | 41 +++++++++++++++++++++++++++++++++++++++++
 buildstream/source.py       | 13 +++++++++++++
 2 files changed, 54 insertions(+)

diff --git a/buildstream/buildelement.py b/buildstream/buildelement.py
index 5447c13..9103b1b 100644
--- a/buildstream/buildelement.py
+++ b/buildstream/buildelement.py
@@ -23,6 +23,47 @@ BuildElement - Abstract class for build elements
 The BuildElement class is a convenience element one can derive from for
 implementing the most common case of element.
 
+Built-in functionality
+----------------------
+
+The BuildElement base class provides built in functionality that could be
+overridden by the individual plugins.
+
+This section will give a brief summary of how some of the common features work,
+some of them or the variables they use will be further detailed in the following
+sections.
+
+* Location for running commands
+
+ The ``command-subdir`` variable sets where the build commands will be executed,
+ if the directory does not exist it will be created, it is defined relative to
+ the buildroot.
+
+* Location for configuring the project
+
+ The ``conf-root`` is defined by default as ``.`` and is the location that
+ specific build element can use to look for build configuration files, currently
+ autotools, cmake, distutils, meson, pip and qmake use this.
+
+ The configuration commands are run in ``command-subdir`` and by default
+ ``conf-root`` is ``.`` so if ``conf-root`` is not set the configuration files
+ in ``command-subdir`` will be used.
+
+ By setting ``conf-root`` to ``"%{build-root}/Source/conf_location"`` and your
+ source elements ``directory`` variable to ``Source`` then the configuration
+ files in the directory ``conf_location`` with in your Source will be used.
+ However the location where your configuration command will be run will still
+ be wherever you set your ``command-subdir`` to be.
+
+ The ``conf-root`` variable is available since
+ :ref:`format version 17 <project_format_version>`
+
+* Install Location
+
+  You should not change the ``install-root`` variable as it is a special
+  writeable location in the sandbox but it is useful when writing custom
+  install instructions as it may need to be supplied as the ``DESTDIR``, please
+  see the cmake build element for example.
 
 Abstract method implementations
 -------------------------------
diff --git a/buildstream/source.py b/buildstream/source.py
index 6768f6c..702415d 100644
--- a/buildstream/source.py
+++ b/buildstream/source.py
@@ -20,6 +20,19 @@
 Source - Base source class
 ==========================
 
+Built-in functionality
+----------------------
+
+The Source base class provides built in functionality that could be overridden
+by the individual plugins.
+
+* Directory
+
+  The ``directory`` variable can be set for all sources of a type in project.conf
+  or per source within a element.
+
+  This sets the location with in the build root that the content of the source
+  will be loaded in to. If the location dose not exist it will be created.
 
 .. _core_source_abstract_methods:
 


[buildstream] 07/09: Added a news item for building out of the source directory

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

root pushed a commit to branch willsalmon/simpleOutSource
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 26cf2e5765eb11a5528b2cd1e804c4065f0e39b6
Author: William Salmon <wi...@codethink.co.uk>
AuthorDate: Thu Oct 4 16:54:21 2018 +0100

    Added a news item for building out of the source directory
    
    For issue #512 in Gitlab.
---
 NEWS | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/NEWS b/NEWS
index acbdf2a..7e88f4a 100644
--- a/NEWS
+++ b/NEWS
@@ -27,6 +27,9 @@ buildstream 1.3.1
   o Generate Docker images from built artifacts using
     `contrib/bst-docker-import` script.
 
+  o Added Documentation on how to create out of source builds. This includes the
+    new the `conf-root` variable to make the process easier. And there has been
+    a bug fix to workspaces so they can be build in workspaces too.
 
 =================
 buildstream 1.1.5


[buildstream] 05/09: Adding Tests for Out of Source Build examples

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

root pushed a commit to branch willsalmon/simpleOutSource
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit a774a3450ec568176e415f0be4cd4cae6d54129b
Author: William Salmon <wi...@codethink.co.uk>
AuthorDate: Mon Sep 10 16:54:31 2018 +0100

    Adding Tests for Out of Source Build examples
    
    For issue #512 in Gitlab.
---
 tests/examples/autotools-outofsource.py  | 50 ++++++++++++++++++++++++++++++++
 tests/examples/cmake.py                  | 45 ++++++++++++++++++++++++++++
 tests/examples/helloworld-outofsource.py | 45 ++++++++++++++++++++++++++++
 3 files changed, 140 insertions(+)

diff --git a/tests/examples/autotools-outofsource.py b/tests/examples/autotools-outofsource.py
new file mode 100644
index 0000000..91262ea
--- /dev/null
+++ b/tests/examples/autotools-outofsource.py
@@ -0,0 +1,50 @@
+import os
+import pytest
+
+from tests.testutils import cli_integration as cli
+from tests.testutils.integration import assert_contains
+from tests.testutils.site import IS_LINUX
+
+pytestmark = pytest.mark.integration
+
+DATA_DIR = os.path.join(
+    os.path.dirname(os.path.realpath(__file__)), '..', '..', 'doc', 'examples',
+    'out-of-source-autotool-in-source-tree'
+)
+
+
+# Tests a build of the autotools amhello project on a alpine-linux base runtime
+@pytest.mark.skipif(not IS_LINUX, reason='Only available on linux')
+@pytest.mark.datafiles(DATA_DIR)
+def test_autotools_build(cli, tmpdir, datafiles):
+    project = os.path.join(datafiles.dirname, datafiles.basename)
+    checkout = os.path.join(cli.directory, 'checkout')
+
+    # Check that the project can be built correctly.
+    result = cli.run(project=project, args=['build', 'hello.bst'])
+    result.assert_success()
+
+    result = cli.run(project=project, args=['checkout', 'hello.bst', checkout])
+    result.assert_success()
+
+    assert_contains(checkout, ['/usr', '/usr/lib', '/usr/bin',
+                               '/usr/share', '/usr/lib/debug',
+                               '/usr/lib/debug/usr', '/usr/lib/debug/usr/bin',
+                               '/usr/lib/debug/usr/bin/hello',
+                               '/usr/bin/hello',
+                               '/usr/share/doc', '/usr/share/doc/amhello',
+                               '/usr/share/doc/amhello/README'])
+
+
+# Test running an executable built with autotools.
+@pytest.mark.skipif(not IS_LINUX, reason='Only available on linux')
+@pytest.mark.datafiles(DATA_DIR)
+def test_autotools_run(cli, tmpdir, datafiles):
+    project = os.path.join(datafiles.dirname, datafiles.basename)
+
+    result = cli.run(project=project, args=['build', 'hello.bst'])
+    result.assert_success()
+
+    result = cli.run(project=project, args=['shell', 'hello.bst', 'hello'])
+    result.assert_success()
+    assert result.output == 'Hello World!\nThis is amhello 1.0.\n'
diff --git a/tests/examples/cmake.py b/tests/examples/cmake.py
new file mode 100644
index 0000000..656cfb0
--- /dev/null
+++ b/tests/examples/cmake.py
@@ -0,0 +1,45 @@
+import os
+import pytest
+
+from tests.testutils import cli_integration as cli
+from tests.testutils.integration import assert_contains
+from tests.testutils.site import IS_LINUX
+
+pytestmark = pytest.mark.integration
+
+DATA_DIR = os.path.join(
+    os.path.dirname(os.path.realpath(__file__)), '..', '..', 'doc', 'examples', 'cmake'
+)
+
+
+# Tests a build using cmake with the C complier from alpine-linux base runtime
+@pytest.mark.skipif(not IS_LINUX, reason='Only available on linux')
+@pytest.mark.datafiles(DATA_DIR)
+def test_autotools_build(cli, tmpdir, datafiles):
+    project = os.path.join(datafiles.dirname, datafiles.basename)
+    checkout = os.path.join(cli.directory, 'checkout')
+
+    # Check that the project can be built correctly.
+    result = cli.run(project=project, args=['build', 'hello.bst'])
+    result.assert_success()
+
+    result = cli.run(project=project, args=['checkout', 'hello.bst', checkout])
+    result.assert_success()
+
+    assert_contains(checkout, ['/usr', '/usr/lib', '/usr/bin',
+                               '/usr/share',
+                               '/bin/hello_buildstream'])
+
+
+# Test running an executable built with cmake.
+@pytest.mark.skipif(not IS_LINUX, reason='Only available on linux')
+@pytest.mark.datafiles(DATA_DIR)
+def test_autotools_run(cli, tmpdir, datafiles):
+    project = os.path.join(datafiles.dirname, datafiles.basename)
+
+    result = cli.run(project=project, args=['build', 'hello.bst'])
+    result.assert_success()
+
+    result = cli.run(project=project, args=['shell', 'hello.bst', 'hello_buildstream'])
+    result.assert_success()
+    assert result.output == 'Hello, World!\n'
diff --git a/tests/examples/helloworld-outofsource.py b/tests/examples/helloworld-outofsource.py
new file mode 100644
index 0000000..4bb900f
--- /dev/null
+++ b/tests/examples/helloworld-outofsource.py
@@ -0,0 +1,45 @@
+import os
+import pytest
+
+from tests.testutils import cli_integration as cli
+from tests.testutils.integration import assert_contains
+from tests.testutils.site import IS_LINUX
+
+pytestmark = pytest.mark.integration
+
+DATA_DIR = os.path.join(
+    os.path.dirname(os.path.realpath(__file__)), '..', '..', 'doc', 'examples',
+    'out-of-source-build-helloworld'
+)
+
+
+# Tests a build of the autotools amhello project on a alpine-linux base runtime
+@pytest.mark.skipif(not IS_LINUX, reason='Only available on linux')
+@pytest.mark.datafiles(DATA_DIR)
+def test_autotools_build(cli, tmpdir, datafiles):
+    project = os.path.join(datafiles.dirname, datafiles.basename)
+    checkout = os.path.join(cli.directory, 'checkout')
+
+    # Check that the project can be built correctly.
+    result = cli.run(project=project, args=['build', 'hello.bst'])
+    result.assert_success()
+
+    result = cli.run(project=project, args=['checkout', 'hello.bst', checkout])
+    result.assert_success()
+
+    assert_contains(checkout, ['/usr', '/usr/bin',
+                               '/usr/bin/hello'])
+
+
+# Test running an executable built with autotools.
+@pytest.mark.skipif(not IS_LINUX, reason='Only available on linux')
+@pytest.mark.datafiles(DATA_DIR)
+def test_autotools_run(cli, tmpdir, datafiles):
+    project = os.path.join(datafiles.dirname, datafiles.basename)
+
+    result = cli.run(project=project, args=['build', 'hello.bst'])
+    result.assert_success()
+
+    result = cli.run(project=project, args=['shell', 'hello.bst', '--', 'hello', 'bob'])
+    result.assert_success()
+    assert result.output == 'Hello bob\n'


[buildstream] 08/09: wip docs

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

root pushed a commit to branch willsalmon/simpleOutSource
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit f2017d0463b79ee7eb2c6c2867985de87d9512c0
Author: William Salmon <wi...@codethink.co.uk>
AuthorDate: Wed Oct 10 11:21:46 2018 +0100

    wip docs
---
 doc/source/examples/cmake.rst | 83 +++++--------------------------------------
 1 file changed, 8 insertions(+), 75 deletions(-)

diff --git a/doc/source/examples/cmake.rst b/doc/source/examples/cmake.rst
index e124257..3f31c00 100644
--- a/doc/source/examples/cmake.rst
+++ b/doc/source/examples/cmake.rst
@@ -10,31 +10,6 @@ Intro
 This example aims to show:
 
  * How to use cmake elements
- * How to use Out of source element with cmake
-
-The out of source hello world example show the basics of out of source builds but
-this example shows how to apply that to cmake, a more complex build system.
-
-Build stream aims to make out of source builds as easy as posible and so long as
-the build element supports out of source element it should be the same.
-
-The out of source builds are configured by setting:
- 
- * `directory` of the source, this sets the source to open in to a folder in the
-   build root.
- * `command-subdir` variable, sets were the build will be run.
- * `conf-root` variable, tells the confirmation tool how to get from
-   `command-subdir` to `directory`.
-
-This example:
- 
- * Sets `directory` to `Source` in `elements/hello.bst`
- * Sets `command-subdir` to `build` in `elements/hello.bst`
- * Sets `conf-root` to `"%{build-root}/Source"` in `elements/hello.bst`
-
-This way we can change `command-subdir` with out having to change `conf-root`
-but we could have set `conf-root` to `../Source` but then we would have to
-change it if `command-subdir` changed to `.` or `sub/folder`
 
 
 Prerequisites
@@ -44,41 +19,11 @@ All the necessary elements are in the example folder
 Project structure
 -----------------
 
-The following is a simple :ref:`project <projectconf>` definition:
-
-``project.conf``
-~~~~~~~~~~~~~~~~
-
-.. literalinclude:: ../../examples/cmake/project.conf
-   :language: yaml
-
-Note that we’ve added a :ref:`source alias <project_source_aliases>` for
-the ``https://gnome7.codethink.co.uk/tarballs/`` repository to download the 
-build tools from, please note that this bootstrap only contains the compiler 
-if you wish to use c++ you will need a different bootstrap.
-
-``elements/base/alpine.bst``
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-.. literalinclude:: ../../examples/cmake/elements/base/alpine.bst
-   :language: yaml
-
-This is the :mod:`import <elements.import>` element used to import the
-actual Flatpak SDK, it uses an :mod:`tar <sources.tar>` source to
-download and unpack the archive in to the sandbox.
-
-``elements/base.bst``
-~~~~~~~~~~~~~~~~~~~~~
+This example has a common structure of a base.bst and a base/* folder contating
+a link to something to provide the build elements. The project.comf contains
+aliases to keep things easy to read and the build is controled with a single
+hello.bst element.
 
-.. literalinclude:: ../../examples/cmake/elements/base.bst
-   :language: yaml
-
-This is just a :mod:`stack <elements.stack>` element for convenience sake.
-
-Often times you will have a more complex base to build things on, and it
-is convenient to just use a :mod:`stack <elements.stack>` element for
-your elements to depend on without needing to know about the inner workings
-of the base system build.
 
 ``elements/hello.bst``
 ~~~~~~~~~~~~~~~~~~~~~~
@@ -86,8 +31,8 @@ of the base system build.
 .. literalinclude:: ../../examples/cmake/elements/hello.bst
    :language: yaml
 
-Finally, we show an example of an :mod:`cmake <elements.cmake>` element
-to build our sample "Hello World" program.
+The only diffrence to any other non cmake projcet is the use of the 
+:mod:`cmake <elements.cmake>` element to build our sample "Hello World" program.
 
 We use a :mod:`local <sources.local>` source to obtain the sample
 cmake project, but normally you would probably use a :mod:`git <sources.git>`
@@ -100,10 +45,8 @@ want cmake to be a dependency this is done by depending on the`base.bst` element
 that provides cmake.
 
 
-Using the project
------------------
-Now that we've explained the basic layout of the project, here are
-just a few things you can try to do with the project.
+Expected usage
+--------------
 
 .. note::
 
@@ -133,13 +76,3 @@ following way:
 .. raw:: html
    :file: ../sessions/cmake-shell.html
 
-
-
-
-
-
-
-
-
-
-


[buildstream] 09/09: quick test test

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

root pushed a commit to branch willsalmon/simpleOutSource
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 44bba470efff0f19feebe2355c4d08631b4ed825
Author: William Salmon <wi...@codethink.co.uk>
AuthorDate: Wed Oct 10 11:41:05 2018 +0100

    quick test test
---
 tests/integration/cmake.py | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/tests/integration/cmake.py b/tests/integration/cmake.py
index 3c16b29..6ab83b7 100644
--- a/tests/integration/cmake.py
+++ b/tests/integration/cmake.py
@@ -31,6 +31,22 @@ def test_cmake_build(cli, tmpdir, datafiles):
                                '/usr/lib/debug/usr/bin',
                                '/usr/lib/debug/usr/bin/hello'])
 
+@pytest.mark.datafiles(DATA_DIR)
+def test_cmake_confroot_build(cli, tmpdir, datafiles):
+    project = os.path.join(datafiles.dirname, datafiles.basename)
+    checkout = os.path.join(cli.directory, 'checkout')
+    element_name = 'cmake/cmakeconfroothello.bst'
+
+    result = cli.run(project=project, args=['build', element_name])
+    assert result.exit_code == 0
+
+    result = cli.run(project=project, args=['checkout', element_name, checkout])
+    assert result.exit_code == 0
+
+    assert_contains(checkout, ['/usr', '/usr/bin', '/usr/bin/hello',
+                               '/usr/lib/debug', '/usr/lib/debug/usr',
+                               '/usr/lib/debug/usr/bin',
+                               '/usr/lib/debug/usr/bin/hello'])
 
 @pytest.mark.datafiles(DATA_DIR)
 def test_cmake_run(cli, tmpdir, datafiles):